From 34a0c4055072a92a56669a2b3de7e4431f358311 Mon Sep 17 00:00:00 2001 From: lemniskett Date: Mon, 28 Dec 2020 19:15:21 +0700 Subject: [PATCH] Some workarounds for NixOS. --- archbox.bash | 8 ++++++-- archbox.conf | 1 + archboxinit.bash | 4 ++-- chroot_setup.bash | 1 + remount_run.bash | 7 +++++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/archbox.bash b/archbox.bash index 382b495..e585ae5 100755 --- a/archbox.bash +++ b/archbox.bash @@ -28,6 +28,7 @@ OPTIONS: -e, --enter Enters chroot enviroment. -h, --help Displays this help message. --remount-run Remount /run in chroot enviroment. + --mount-runtime-only Mount XDG_RUNTIME_DIR to chroot enviroment. EOF } @@ -69,7 +70,7 @@ case $1 in mount -R /tmp $CHROOT/tmp mount -R /sys $CHROOT/sys mount -R /dev $CHROOT/dev - mount -R /run $CHROOT/run + [[ $MOUNT_RUN = "yes" ]] && mount -R /run $CHROOT/run mount --make-rslave $CHROOT/dev mount --make-rslave $CHROOT/sys mkdir -p $CHROOT/var/lib/dbus @@ -79,7 +80,7 @@ case $1 in mount -R /boot $CHROOT/boot cp /usr/local/share/archbox/chroot_setup.bash $CHROOT/chroot_setup echo $USER > /tmp/archbox_user - chroot $CHROOT /bin/bash -c "/bin/sh /chroot_setup" + chroot $CHROOT /bin/bash -c "/chroot_setup" ;; -e|--enter) storeenv @@ -89,6 +90,9 @@ case $1 in --remount-run) $PRIV /usr/local/share/archbox/bin/remount_run ;; + --mount-runtime-only) + $PRIV /usr/local/share/archbox/bin/remount_run runtimeonly + ;; -h|--help) help_text ;; diff --git a/archbox.conf b/archbox.conf index 4214840..098fdab 100644 --- a/archbox.conf +++ b/archbox.conf @@ -2,6 +2,7 @@ USER="lemniskett" PRIV="sudo" INSTALL_PATH="/var/archlinux" CHROOT="$INSTALL_PATH/root.x86_64" +MOUNT_RUN="yes" # Put your desired enviroment variable here, for example # ENV_VAR="HOME=/var/home/lemniskett" diff --git a/archboxinit.bash b/archboxinit.bash index 0cc6389..5385e9d 100755 --- a/archboxinit.bash +++ b/archboxinit.bash @@ -11,7 +11,7 @@ case $1 in mount --make-rslave $CHROOT/sys mount -R /dev $CHROOT/dev mount --make-rslave $CHROOT/dev - mount -R /run $CHROOT/run + [[ $MOUNT_RUN = "yes" ]] && mount -R /run $CHROOT/run mount -R /lib/modules $CHROOT/lib/modules mount -R /boot $CHROOT/boot mount -R /var/lib/dbus $CHROOT/var/lib/dbus @@ -25,7 +25,7 @@ case $1 in umount -R $CHROOT/tmp umount -R $CHROOT/sys umount -R $CHROOT/dev - umount -R $CHROOT/run + [[ $MOUNT_RUN = "yes" ]] && umount -R $CHROOT/run umount -R $CHROOT/lib/modules umount -R $CHROOT/boot umount -R $CHROOT/var/lib/dbus diff --git a/chroot_setup.bash b/chroot_setup.bash index 25ede46..f49bc77 100755 --- a/chroot_setup.bash +++ b/chroot_setup.bash @@ -9,6 +9,7 @@ msg(){ echo "$(tput bold)$(tput setaf 2)==> $@ $(tput sgr0)" } +PATH=/usr/bin msg "Initializing pacman keyrings..." pacman-key --init pacman-key --populate archlinux diff --git a/remount_run.bash b/remount_run.bash index 11ac28e..a1d1c5d 100755 --- a/remount_run.bash +++ b/remount_run.bash @@ -6,9 +6,16 @@ case $1 in killxdg) umount -l $CHROOT/run fuser -km $(cat /tmp/archbox_xdg_runtime_dir) + exit $? + ;; + runtimeonly) + mkdir -p $CHROOT/$(cat /tmp/archbox_xdg_runtime_dir) + mount --rbind $(cat /tmp/archbox_xdg_runtime_dir) $CHROOT/$(cat /tmp/archbox_xdg_runtime_dir) + exit $? ;; *) umount -l $CHROOT/run mount --rbind /run $CHROOT/run + exit $? ;; esac