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 blkid)
|
||||||
install_binary $(which fdisk)
|
install_binary $(which fdisk)
|
||||||
install_binary $(which mkfs.ext4)
|
install_binary $(which mkfs.ext4)
|
||||||
|
install_binary $(which fsarchiver)
|
||||||
install_kmod
|
install_kmod
|
||||||
install_busybox
|
install_busybox
|
||||||
|
|
||||||
|
2
init.sh
2
init.sh
@ -6,7 +6,7 @@ create_certs
|
|||||||
setup_network
|
setup_network
|
||||||
|
|
||||||
# TODO: replace hardcoded URL with guest_api
|
# 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
|
if [[ -f "/tmp/install_url" ]]; then
|
||||||
install_os
|
install_os
|
||||||
else
|
else
|
||||||
|
@ -66,37 +66,44 @@ setup_network() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_os() {
|
install_os() {
|
||||||
local url="$(cat /tmp/install_url)"
|
local url="$(cat /tmp/install_url)" hostname=''
|
||||||
blkid | grep vda1 | grep ext4 && {
|
blkid | grep vda1 | grep ext4 && {
|
||||||
mount_root
|
mount_root
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
fdisk /dev/vda <<EOF
|
(
|
||||||
n
|
echo n
|
||||||
p
|
echo p
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo
|
||||||
w
|
echo w
|
||||||
EOF
|
) | fdisk /dev/vda
|
||||||
mkfs.ext4 /dev/vda1
|
mkfs.ext4 /dev/vda1
|
||||||
mount_root
|
mount_root
|
||||||
cd /mnt/
|
wget -O /mnt/template.fsa "$url"
|
||||||
wget -O template.tar.xz "$url"
|
fsarchiver restdir /mnt/template.fsa /
|
||||||
tar --numeric-owner -xpJf /mnt/template.tar.xz -C /mnt/
|
rm /mnt/template.fsa
|
||||||
rm /mnt/template.tar.xz
|
# TODO: decide for UX if maybe we should allow user to inject fstab
|
||||||
rm /mnt/etc/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
|
# detee_ghu stands for GitHub user and expects format detee_ghu=ghe0
|
||||||
github_ssh_key() {
|
github_ssh_key() {
|
||||||
|
local key=''
|
||||||
github_user=$(cat /proc/cmdline | grep -oE 'detee_ghu=[0-9a-z\_\.\-]+' | cut -d '=' -f2)
|
github_user=$(cat /proc/cmdline | grep -oE 'detee_ghu=[0-9a-z\_\.\-]+' | cut -d '=' -f2)
|
||||||
[[ -z "$github_user" ]] && return 0
|
[[ -z "$github_user" ]] && return 0
|
||||||
mkdir -p /mnt/root/.ssh
|
mkdir -p /mnt/root/.ssh
|
||||||
cd /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
|
chmod 600 authorized_keys
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mount_root() {
|
mount_root() {
|
||||||
mkdir /mnt
|
mkdir /mnt
|
||||||
|
Loading…
Reference in New Issue
Block a user