#!/bin/bash
readonly KERNEL="vmlinuz"
readonly RIGHT_GROUPS="adm,cdrom,sudo,plugdev,lpadmin"

function setup_locale() {
	if [ -f /etc/default/locale ]; then
		cp -f /etc/default/locale $INSTALLPATH/etc/default/
	fi
}

function setup_time() {
	if [ -h /etc/localtime ]; then
		cp -fd /etc/localtime $INSTALLPATH/etc/
	fi
	if [ -f /etc/adjtime ]; then
		cp -f /etc/adjtime $INSTALLPATH/etc/
	fi
}

function setup_console_keymap() {
	if [ -f /etc/default/keyboard ]; then
		cp -f /etc/default/keyboard $INSTALLPATH/etc/default/
	fi
}

function setup_initrd() {
	systempart=$1
	
	if [ $(echo $systempart | cut -c1-7) == "/dev/vd" ]; then
		echo -e "virtio_pci\nvirtio_blk" > $INSTALLPATH/usr/share/initramfs-tools/modules.d/virtio
	fi
	mount --bind /dev $INSTALLPATH/dev
	#TODO virtio
	local status=0; chroot $INSTALLPATH mkinitramfs -o /boot/initrd.img || status=$INITRD_ERROR
	umount $INSTALLPATH/dev
	return $status
}
