41 lines
1.2 KiB
Bash
Executable File
41 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "switching from $(id -un) to root"
|
|
exec sudo "$0" "$@"
|
|
fi
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
DIR="$(dirname "$0")"
|
|
cd ..
|
|
echo $PWD
|
|
|
|
rm -rf './outputs/root'
|
|
if [ ! -d ./outputs/root/bin ]; then
|
|
rm -rf './outputs/root'
|
|
mkdir -p ./outputs/root/
|
|
debootstrap questing ./outputs/root https://us.archive.ubuntu.com/ubuntu
|
|
fi
|
|
if mountpoint -q "./outputs/chroot/proc/"; then
|
|
umount -lf "./outputs/chroot/proc/"
|
|
fi
|
|
rm -rf './outputs/chroot'
|
|
mkdir -p ./outputs/chroot/
|
|
if mountpoint -q "./outputs/root/proc/"; then
|
|
umount -lf "./outputs/root/proc/"
|
|
fi
|
|
rsync -a ./outputs/root/ ./outputs/chroot/
|
|
mkdir -p ./outputs/chroot/proc
|
|
mount --bind /proc ./outputs/chroot/proc
|
|
cp ./config/filesystem_chroot_install.sh ./outputs/chroot/filesystem_chroot_install.sh
|
|
chmod +x ./outputs/chroot/filesystem_chroot_install.sh
|
|
chroot ./outputs/chroot /bin/bash -c "/filesystem_chroot_install.sh"
|
|
cp ./config/interfaces.network ./outputs/chroot/etc/systemd/network/10-all.network
|
|
cp ./config/resolved.conf ./outputs/chroot/etc/systemd/resolved.conf
|
|
cd $DIR
|
|
cd ..
|
|
if mountpoint -q "./outputs/chroot/proc/"; then
|
|
umount -lf "./outputs/chroot/proc/"
|
|
fi
|
|
echo 'root filesystem created.'
|