Provide a way to bring custom enviroment variables to chroot.

This commit is contained in:
lemniskett 2020-10-29 13:07:50 +07:00
parent 99d453fb49
commit 11eac49532
2 changed files with 11 additions and 5 deletions

View File

@ -2,3 +2,7 @@ USER=lemniskett
PRIV="sudo" PRIV="sudo"
INSTALL_PATH="/var/archlinux" INSTALL_PATH="/var/archlinux"
CHROOT="$INSTALL_PATH/root.x86_64" CHROOT="$INSTALL_PATH/root.x86_64"
# Put your desired enviroment variable here, for example
# ENV_VAR="HOME=/var/home/lemniskett"
ENV_VAR=""

View File

@ -2,8 +2,10 @@
source /etc/archbox.conf source /etc/archbox.conf
DBUS_ADDRESS_ENV="$(cat /tmp/archbox_dbus_session_address)" REQ_ENV="DBUS_SESSION_BUS_ADDRESS=$(cat /tmp/archbox_dbus_session_address) XDG_RUNTIME_DIR=$(cat /tmp/archbox_xdg_runtime_dir)"
XDG_RUNTIME_ENV="$(cat /tmp/archbox_xdg_runtime_dir)"
ENV="$REQ_ENV $ENV_VAR"
COMMAND=$(echo $@ | tr ' ' '\ ') COMMAND=$(echo $@ | tr ' ' '\ ')
[[ $1 = "enter" ]] && chroot $CHROOT /sbin/env DBUS_SESSION_BUS_ADDRESS=$DBUS_ADDRESS_ENV XDG_RUNTIME_DIR=$XDG_RUNTIME_ENV /bin/su $USER \ [[ $1 = "enter" ]] && chroot $CHROOT /sbin/env $ENV /bin/su $USER \
|| chroot $CHROOT /bin/su -c "env DBUS_SESSION_BUS_ADDRESS=$DBUS_ADDRESS XDG_RUNTIME_DIR=$XDG_RUNTIME_ENV $COMMAND" $USER || chroot $CHROOT /bin/su -c "env $ENV $COMMAND" $USER