switch to fsarchiver
This commit is contained in:
parent
cc2e025ae0
commit
6ccbb8af07
@ -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
|
||||
|
||||
|
2
init.sh
2
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
|
||||
|
@ -66,37 +66,44 @@ 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 <<EOF
|
||||
n
|
||||
p
|
||||
|
||||
|
||||
|
||||
w
|
||||
EOF
|
||||
(
|
||||
echo n
|
||||
echo p
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo w
|
||||
) | fdisk /dev/vda
|
||||
mkfs.ext4 /dev/vda1
|
||||
mount_root
|
||||
cd /mnt/
|
||||
wget -O template.tar.xz "$url"
|
||||
tar --numeric-owner -xpJf /mnt/template.tar.xz -C /mnt/
|
||||
rm /mnt/template.tar.xz
|
||||
rm /mnt/etc/fstab
|
||||
wget -O /mnt/template.fsa "$url"
|
||||
fsarchiver restdir /mnt/template.fsa /
|
||||
rm /mnt/template.fsa
|
||||
# TODO: decide for UX if maybe we should allow user to inject fstab
|
||||
echo "" > /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
|
||||
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() {
|
||||
mkdir /mnt
|
||||
|
Loading…
Reference in New Issue
Block a user