2022-03-04 19:33:13 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
# vim: set ts=4 sw=4 sts=4 et :
|
|
|
|
### 04_install_qubes.sh : Prepare chroot instance as a Qubes template
|
2023-08-25 21:44:09 +00:00
|
|
|
echo "--> Alpine linux 04_install_qubes.sh"
|
2022-03-04 19:33:13 +00:00
|
|
|
|
2023-08-25 21:44:09 +00:00
|
|
|
APKTOOLS_CACHE_DIR="${CACHEDIR}/apk_cache"
|
2023-08-26 03:00:57 +00:00
|
|
|
export APK_CACHE_DIR
|
2022-03-04 19:33:13 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
if [ "$VERBOSE" -ge 2 ] || [ "$DEBUG" -gt 0 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
2023-08-25 21:44:09 +00:00
|
|
|
echo " --> Adding Qubes custom repository..."
|
|
|
|
su -c "echo 'https://lab.ilot.io/ayakael/repo-apk/-/raw/v3.18/qubes/r4.1' >> $INSTALLDIR/etc/apk/repositories"
|
|
|
|
wget "https://lab.ilot.io/ayakael/repo-apk/-/raw/v3.18/antoine.martin@protonmail.com-5b3109ad.rsa.pub" -P "$INSTALLDIR"/etc/apk/keys
|
2022-03-04 19:33:13 +00:00
|
|
|
|
|
|
|
echo " --> Synchronize resolv.conf..."
|
|
|
|
cp /etc/resolv.conf "${INSTALLDIR}/etc/resolv.conf"
|
|
|
|
|
2023-08-25 21:44:09 +00:00
|
|
|
echo " --> Updating apk repos..."
|
2023-08-26 03:00:57 +00:00
|
|
|
"${TEMPLATE_CONTENT_DIR}/alpine-chroot" "$INSTALLDIR" /bin/sh -c \
|
2023-08-25 21:44:09 +00:00
|
|
|
"apk update; apk upgrade"
|
2022-03-04 19:33:13 +00:00
|
|
|
|
|
|
|
echo " --> Installing mandatory qubes packages..."
|
2023-08-26 03:00:57 +00:00
|
|
|
"${TEMPLATE_CONTENT_DIR}/alpine-chroot" "$INSTALLDIR" /bin/sh -c \
|
2023-08-25 21:44:09 +00:00
|
|
|
"apk add qubes-vm-dependencies"
|
2022-03-04 19:33:13 +00:00
|
|
|
|
|
|
|
echo " --> Installing recommended qubes apps"
|
2023-08-26 03:00:57 +00:00
|
|
|
"${TEMPLATE_CONTENT_DIR}/alpine-chroot" "$INSTALLDIR" /bin/sh -c \
|
2023-08-25 21:44:09 +00:00
|
|
|
"apk add qubes-vm-recommended"
|
2022-03-04 19:33:13 +00:00
|
|
|
|
|
|
|
echo " --> Updating template fstab file..."
|
|
|
|
cat >> "${INSTALLDIR}/etc/fstab" <<EOF
|
|
|
|
#
|
|
|
|
# /etc/fstab: static file system information
|
|
|
|
#
|
|
|
|
|
|
|
|
# Templates Directories
|
|
|
|
/dev/mapper/dmroot / ext4 defaults,discard,noatime 1 1
|
|
|
|
/dev/xvdb /rw auto noauto,defaults,discard 1 2
|
|
|
|
/dev/xvdc1 swap swap defaults 0 0
|
|
|
|
|
|
|
|
# Template Binds
|
|
|
|
/rw/home /home none noauto,bind,defaults 0 0
|
|
|
|
/rw/usrlocal /usr/local none noauto,bind,defaults 0 0
|
|
|
|
|
|
|
|
# Template Customizations
|
|
|
|
tmpfs /dev/shm tmpfs defaults,size=1G 0 0
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
echo " --> Configuring system to our preferences..."
|
2023-08-25 21:44:09 +00:00
|
|
|
# add hcv0 to inittab
|
2023-08-26 03:00:57 +00:00
|
|
|
echo "hvc0::respawn:/sbin/getty -L hvc0 115200 vt220" >> "$INSTALLDIR"/etc/inittab
|
|
|
|
# add group qubes and user
|
|
|
|
"${TEMPLATE_CONTENT_DIR}/alpine-chroot" "$INSTALLDIR" addgroup user
|
|
|
|
"${TEMPLATE_CONTENT_DIR}/alpine-chroot" "$INSTALLDIR" addgroup qubes
|
2023-08-25 21:44:09 +00:00
|
|
|
# add user:user
|
2023-08-26 03:00:57 +00:00
|
|
|
"${TEMPLATE_CONTENT_DIR}/alpine-chroot" "$INSTALLDIR" adduser -D -S user -g qubes -G user
|
|
|
|
|
2023-08-25 21:44:09 +00:00
|
|
|
# enable services
|
2023-08-26 03:00:57 +00:00
|
|
|
for i in udev udev-trigger xendriverdomain qubes-qrexec-agent qubes-db qubes-meminfo-writer qubes-sysinit qubes-core-early qubes-core crond acpid; do
|
|
|
|
"${TEMPLATE_CONTENT_DIR}/alpine-chroot" "$INSTALLDIR" rc-update add $i default
|
2023-08-25 21:44:09 +00:00
|
|
|
done
|
2023-08-26 03:00:57 +00:00
|
|
|
|
|
|
|
# setup initramfs
|