From 7fcc8d2ad0f6d97c2ad6478c724512b4ed3a7838 Mon Sep 17 00:00:00 2001 From: Syahrial Agni Prasetya Date: Sat, 6 Mar 2021 12:51:01 +0700 Subject: [PATCH] Separate enter and exec command and some changes. --- archbox.bash | 10 +++++----- enter.bash | 13 +++++++++++++ exec.bash | 3 +-- install.sh | 3 ++- 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 enter.bash diff --git a/archbox.bash b/archbox.bash index e1de6d7..14d8ba3 100644 --- a/archbox.bash +++ b/archbox.bash @@ -82,7 +82,7 @@ case $1 in checkdep sed sed -i 's/CheckSpace/#CheckSpace/g' $CHROOT/etc/pacman.conf msg "Mounting necessary filesystems..." - $PREFIX/share/archbox/bin/archboxinit start + $PREFIX/share/archbox/bin/init start cp $PREFIX/share/archbox/chroot_setup.bash $CHROOT/chroot_setup echo $USER > /tmp/archbox_user chroot $CHROOT /bin/bash -c "/chroot_setup" @@ -91,16 +91,16 @@ case $1 in -e|--enter) storeenv $PRIV $PREFIX/share/archbox/bin/uth copyresolv - $PRIV $PREFIX/share/archbox/bin/archbox enter + $PRIV $PREFIX/share/archbox/bin/enter exit $? ;; -m|--mount) storeenv - $PRIV $PREFIX/share/archbox/bin/archboxinit start + $PRIV $PREFIX/share/archbox/bin/init start ;; -u|--umount) storeenv - $PRIV $PREFIX/share/archbox/bin/archboxinit stop + $PRIV $PREFIX/share/archbox/bin/init stop ;; --remount-run) storeenv @@ -126,7 +126,7 @@ case $1 in *) storeenv $PRIV $PREFIX/share/archbox/bin/uth copyresolv - $PRIV $PREFIX/share/archbox/bin/archbox $@ + $PRIV $PREFIX/share/archbox/bin/exec $@ exit $? ;; esac diff --git a/enter.bash b/enter.bash new file mode 100644 index 0000000..22abf6d --- /dev/null +++ b/enter.bash @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +source /etc/archbox.conf +source /tmp/archbox_env + +REQ_ENV="DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS " +REQ_ENV+="XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR " +[[ ! -z $DISPLAY ]] && REQ_ENV+="DISPLAY=$DISPLAY " +[[ ! -z $WAYLAND_DISPLAY ]] && REQ_ENV+="WAYLAND_DISPLAY=$WAYLAND_DISPLAY " + +ENV="$REQ_ENV $ENV_VAR" +COMMAND="$@" +chroot $CHROOT /sbin/env $ENV /bin/su $USER \ No newline at end of file diff --git a/exec.bash b/exec.bash index b7828ad..02a6941 100644 --- a/exec.bash +++ b/exec.bash @@ -10,5 +10,4 @@ REQ_ENV+="XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR " ENV="$REQ_ENV $ENV_VAR" COMMAND="$@" -[[ $1 = "enter" ]] && (chroot $CHROOT /sbin/env $ENV /bin/su $USER; exit 0) \ - || chroot $CHROOT /bin/su -c "env $ENV $COMMAND" $USER +chroot $CHROOT /bin/su -c "env $ENV $COMMAND" $USER \ No newline at end of file diff --git a/install.sh b/install.sh index 6111184..f4a0d17 100755 --- a/install.sh +++ b/install.sh @@ -6,7 +6,8 @@ mkdir -p $PREFIX/share/archbox/bin install -v -D -m 755 ./archbox.bash $PREFIX/bin/archbox install -v -D -m 755 ./archbox-desktop.bash $PREFIX/bin/archbox-desktop [[ ! -e /etc/archbox.conf ]] && install -v -D -m 755 ./archbox.conf /etc/archbox.conf -install -v -D -m 755 ./archboxcommand.bash $PREFIX/share/archbox/bin/archbox +install -v -D -m 755 ./exec.bash $PREFIX/share/archbox/bin/exec +install -v -D -m 755 ./enter.bash $PREFIX/share/archbox/bin/enter install -v -D -m 755 ./chroot_setup.bash $PREFIX/share/archbox/chroot_setup.bash install -v -D -m 755 ./init.bash $PREFIX/share/archbox/bin/init install -v -D -m 755 ./uth.bash $PREFIX/share/archbox/bin/uth