diff options
Diffstat (limited to 'kvmx-create')
-rwxr-xr-x | kvmx-create | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/kvmx-create b/kvmx-create index cb0f3c4..abcec83 100755 --- a/kvmx-create +++ b/kvmx-create @@ -113,7 +113,7 @@ function kvmx_config { kvmx_user_config ssh_support y "Administration using passwordless SSH (y/n)" kvmx_user_config ssh_custom y "Setup a custom SSH keypair (y/n)" kvmx_user_config user user "Initial user name" - kvmx_user_config password $RANDOM "Initial user password" + kvmx_user_config password $default_password "Initial user password" if [ ! -z "$image_base" ]; then image="$image_base/$hostname/box.img" @@ -179,12 +179,34 @@ function kvmx_create_vmdebootstrap { function kvmx_create_custom { WORK="`mktemp -d`" + # Determine kernel architecture if [ "$arch" == "i386" ]; then kernel_arch="686" else kernel_arch="$arch" fi + # Check the host distro + host_distro="`head -n 1 /etc/issue | cut -d ' ' -f 1 | tr '[:upper:]' '[:lower:]'`" + + # Determine distro and kernel package name + if echo $mirror | grep 'ubuntu'; then + distro="ubuntu" + kernel_package="linux-image-generic" + + if [ "$host_distro" == "debian" ]; then + kvmx_install_package ubuntu-archive-keyring + fi + else + #elif echo $mirror | grep 'debian'; then + distro="debian" + kernel_package="linux-image-$kernel_arch" + + if [ "$host_distro" == "ubuntu" ]; then + kvmx_install_package debian-archive-keyring + fi + fi + # Check for requirements. for req in debootstrap parted; do kvmx_install_package $req @@ -210,7 +232,7 @@ function kvmx_create_custom { # Initial system install. echo "Installing base system..." kvmx_sudo_run LC_ALL=C DEBIAN_FRONTEND=noninteractive debootstrap \ - --arch=$arch --include linux-image-$kernel_arch $version $WORK/ $mirror + --arch=$arch $version $WORK/ $mirror # Initial configuration. echo "Applying initial configuration..." @@ -230,9 +252,23 @@ function kvmx_create_custom { echo "/dev/vda2 / ext4 errors=remount-ro 0 1" | $SUDO tee $WORK/etc/fstab > /dev/null # Apt - if [ "$version" != "sid" ]; then - echo "deb http://security.debian.org/ $version/updates main contrib non-free" | $SUDO tee -a $WORK/etc/apt/sources.list - echo "deb-src http://security.debian.org/ $version/updates main contrib non-free" | $SUDO tee -a $WORK/etc/apt/sources.list + if [ "$distro" == "debian" ]; then + if [ "$version" != "sid" ]; then + echo "deb http://security.debian.org/ $version/updates main contrib non-free" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "deb-src http://security.debian.org/ $version/updates main contrib non-free" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + fi + elif [ "$distro" == "ubuntu" ]; then + $SUDO sed -i -e 's/main/main restricted universe multiverse/' $WORK/etc/apt/sources.list + + echo "deb http://archive.ubuntu.com/ubuntu/ ${version}-updates main restricted universe multiverse" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "deb-src http://archive.ubuntu.com/ubuntu/ ${version}-updates main restricted universe multiverse" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "deb http://archive.ubuntu.com/ubuntu/ ${version}-backports main restricted universe multiverse" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "#deb-src http://archive.ubuntu.com/ubuntu/ ${version}-backports main restricted universe multiverse" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "deb http://security.ubuntu.com/ubuntu ${version}-security main restricted universe multiverse" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "#deb-src http://security.ubuntu.com/ubuntu ${version}-security main restricted universe multivers" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "#deb http://archive.canonical.com/ubuntu ${version} partner" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "#deb-src http://archive.canonical.com/ubuntu ${version} partner" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null + echo "#deb http://extras.ubuntu.com/ubuntu ${version} main" | $SUDO tee -a $WORK/etc/apt/sources.list > /dev/null fi # Mount auxiliary filesystems needed by the bootloader @@ -240,6 +276,14 @@ function kvmx_create_custom { kvmx_sudo_run mount none -t sysfs $WORK/sys kvmx_sudo_run mount -o bind /dev/ $WORK/dev + # Initial upgrade + echo "Updating list of packages..." + kvmx_sudo_run chroot $WORK/ apt-get update + kvmx_sudo_run chroot $WORK/ apt-get dist-upgrade -y + + # Install kernel after mounting /proc + $APT_INSTALL $kernel_package + if [ "$bootloader" == "grub" ]; then $APT_INSTALL grub-pc kvmx_sudo_run chroot $WORK/ update-grub @@ -314,11 +358,6 @@ EOF echo "$LANG UTF-8" | $SUDO tee -a $WORK/etc/locale.gen > /dev/null kvmx_sudo_run chroot $WORK/ locale-gen - # Initial upgrade - #echo "Updating list of packages..." - #kvmx_sudo_run chroot $WORK/ apt-get update - #kvmx_sudo_run chroot $WORK/ apt-get dist-upgrade -y - # Basic packages $APT_INSTALL screen cron lsb-release openssl rsync $APT_INSTALL spice-vdagent qemu-guest-agent |