#!/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 $INSTALL_PATH/etc/default/
	fi
}

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

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

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