#!/bin/bash
readonly KERNEL="/boot/vmlinuz"
readonly RIGHT_GROUPS="disk,wheel,video,cdrom,plugdev,scanner"

function setup_locale() {
	cp -f /etc/profile.d/lang.sh $INSTALL_PATH/etc/profile.d/
}

function setup_time() {
	if [ -f /etc/localtime ] && [ -h /etc/localtime-copied-from ]; then
		cp -f /etc/localtime $INSTALL_PATH/etc/
		cp -df /etc/localtime-copied-from $INSTALL_PATH/etc/
	fi
	if [ -f /etc/hardwareclock ]; then
		cp -f /etc/hardwareclock $INSTALL_PATH/etc/
	fi
}

function setup_console_keymap() {
	if [ -f /etc/rc.d/rc.keymap ]; then
		cp -f /etc/rc.d/rc.keymap $INSTALL_PATH/etc/rc.d/
	fi
}

function setup_initrd() {
	systempart=$1
	
	virtopt=""; if [ $(echo $systempart | cut -c1-7) == "/dev/vd" ]; then virtopt="-m virtio_pci:virtio_blk"; fi
	for d in sys proc dev; do mount --bind /$d $INSTALL_PATH/$d; done
	#~ local status=0; chroot $INSTALL_PATH /var/lib/pkgtools/setup/setup.01.mkinitrd || status=$INITRD_ERROR
	cmd=$(chroot $INSTALL_PATH /usr/share/mkinitrd/mkinitrd_command_generator.sh $virtopt)
	local status=0; chroot $INSTALL_PATH $cmd || status=$INITRD_ERROR
	for d in sys proc dev; do umount $INSTALL_PATH/$d; done
	return $status
}
