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

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

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

function setup_console_keymap() {
	if [ -f /etc/rc.d/rc.keymap ]; then
		cp -f /etc/rc.d/rc.keymap $INSTALLPATH/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 $INSTALLPATH/$d; done
	#~ local status=0; chroot $INSTALLPATH /var/lib/pkgtools/setup/setup.01.mkinitrd || status=$INITRD_ERROR
	cmd=$(chroot $INSTALLPATH /usr/share/mkinitrd/mkinitrd_command_generator.sh $virtopt)
	local status=0; chroot $INSTALLPATH $cmd || status=$INITRD_ERROR
	for d in sys proc dev; do umount $INSTALLPATH/$d; done
	return $status
}
