Bring XDG_RUNTIME_DIR variable to chroot

This commit is contained in:
lemniskett 2020-10-29 12:10:52 +07:00
parent 3194859f55
commit 0e7434a12a
2 changed files with 8 additions and 7 deletions

View File

@ -14,8 +14,9 @@ asroot(){
[[ $EUID -ne 0 ]] && err "Run this as root!" [[ $EUID -ne 0 ]] && err "Run this as root!"
} }
storedbus(){ storeenv(){
echo $DBUS_SESSION_BUS_ADDRESS > /tmp/archbox_dbus_session_address echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" > /tmp/env_archbox
echo "XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" >> /tmp/env_archbox
} }
help_text(){ help_text(){
@ -78,7 +79,7 @@ case $1 in
chroot $CHROOT /bin/bash -c "sh /chroot_setup" chroot $CHROOT /bin/bash -c "sh /chroot_setup"
;; ;;
--enter) --enter)
storedbus storeenv
copyresolv copyresolv
$PRIV /usr/local/share/archbox/bin/archbox enter $PRIV /usr/local/share/archbox/bin/archbox enter
;; ;;
@ -92,7 +93,7 @@ case $1 in
err "Unknown option: $1" err "Unknown option: $1"
;; ;;
*) *)
storedbus storeenv
copyresolv copyresolv
COMMAND=$(echo $@ | tr ' ' '\ ') COMMAND=$(echo $@ | tr ' ' '\ ')
$PRIV /usr/local/share/archbox/bin/archbox $COMMAND $PRIV /usr/local/share/archbox/bin/archbox $COMMAND

View File

@ -2,7 +2,7 @@
source /etc/archbox.conf source /etc/archbox.conf
DBUS_ADDRESS="$(cat /tmp/archbox_dbus_session_address)" ENV="$(cat /tmp/env_archbox)"
COMMAND=$(echo $@ | tr ' ' '\ ') COMMAND=$(echo $@ | tr ' ' '\ ')
[[ $1 = "enter" ]] && chroot $CHROOT /sbin/env DBUS_SESSION_BUS_ADDRESS=$DBUS_ADDRESS /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 $COMMAND" $USER || chroot $CHROOT /bin/su -c "env $ENV $COMMAND" $USER