diff --git a/create.sh b/create.sh index e4f8894..062be76 100755 --- a/create.sh +++ b/create.sh @@ -17,6 +17,7 @@ install_binary $(which cryptsetup) install_binary $(which blkid) install_binary $(which fdisk) install_binary $(which mkfs.ext4) +install_binary $(which fsarchiver) install_kmod install_busybox diff --git a/init.sh b/init.sh index 9580f53..e53d6dc 100755 --- a/init.sh +++ b/init.sh @@ -6,7 +6,7 @@ create_certs setup_network # TODO: replace hardcoded URL with guest_api -echo "http://192.168.122.226/base_arch2.tar.xz" > /tmp/install_url +echo "http://192.168.122.226/arch_base_dir.fsa" > /tmp/install_url if [[ -f "/tmp/install_url" ]]; then install_os else diff --git a/init_functions.sh b/init_functions.sh index 7321f89..96d20bd 100644 --- a/init_functions.sh +++ b/init_functions.sh @@ -66,36 +66,43 @@ setup_network() { } install_os() { - local url="$(cat /tmp/install_url)" + local url="$(cat /tmp/install_url)" hostname='' blkid | grep vda1 | grep ext4 && { mount_root return 0 } - fdisk /dev/vda < /mnt/etc/fstab + hostname=$(cat /proc/cmdline | grep -oE 'detee_name=[0-9a-z\_\.\-]+' | cut -d '=' -f2) + [[ -n "$hostname" ]] && echo $hostname > /mnt/etc/hostname } # detee_ghu stands for GitHub user and expects format detee_ghu=ghe0 github_ssh_key() { + local key='' github_user=$(cat /proc/cmdline | grep -oE 'detee_ghu=[0-9a-z\_\.\-]+' | cut -d '=' -f2) [[ -z "$github_user" ]] && return 0 mkdir -p /mnt/root/.ssh cd /mnt/root/.ssh - wget -O authorized_keys https://github.com/${github_user}.keys - chmod 600 authorized_keys + touch authorized_keys + key="$(wget -O - https://github.com/${github_user}.keys)" + grep -F "$( echo key | awk '{ print $2 }' )" authorized_keys || { + echo "$key" >> authorized_keys + chmod 600 authorized_keys + } } mount_root() {