Browse Source

session reload fork and kill on exit

main
pvincent 9 months ago
parent
commit
e595160303
  1. 16
      lib/install.sh

16
lib/install.sh

@ -12,11 +12,6 @@ NEW_GROUP=lxd
readonly NEW_GROUP EXPANDED_CONF readonly NEW_GROUP EXPANDED_CONF
on_exit() { on_exit() {
if [[ "$SESSION_RELOAD_REQUIRED" == true ]]; then
echo "======================================================"
echo "Session Reload is required (due to new group <$NEW_GROUP>)"
echo "======================================================"
fi
if [ -n "${1:-}" ]; then if [ -n "${1:-}" ]; then
echo "Aborted by $1" echo "Aborted by $1"
elif [ "${status:-}" -ne 0 ]; then elif [ "${status:-}" -ne 0 ]; then
@ -32,8 +27,12 @@ function prepare_lxd {
echo "define lxd and assign to user <$USER>" echo "define lxd and assign to user <$USER>"
sudo groupadd --force "$NEW_GROUP" sudo groupadd --force "$NEW_GROUP"
sudo usermod --append --groups "$NEW_GROUP" "$(whoami)" sudo usermod --append --groups "$NEW_GROUP" "$(whoami)"
exec sg "$NEW_GROUP" -c "$0 SESSION_RELOAD_REQUIRED $TARGET $@"
sg "$NEW_GROUP" -c "$0 SESSION_RELOAD_REQUIRED $TARGET $@"
sg "$NEW_GROUP" -c bash
kill -9 "$PPID"
# no further processing because exec has been called! # no further processing because exec has been called!
else else
echo "user <$USER> already belongs to group <lxd>!" echo "user <$USER> already belongs to group <lxd>!"
fi fi
@ -432,10 +431,9 @@ else
extra_dev_desktop extra_dev_desktop
if [[ "$SESSION_RELOAD_REQUIRED" == true ]]; then if [[ "$SESSION_RELOAD_REQUIRED" == true ]]; then
echowarn "current session has been reloaded, due to new group <$NEW_GROUP>."
echowarn "be aware to exit twice or fully disconnect/reconnect to take advantage of new group <$NEW_GROUP>!"
echoinfo "successful session installation" echoinfo "successful session installation"
sg $NEW_GROUP -c bash
echowarn "be aware: the current session has been reloaded, due to new group <$NEW_GROUP>."
echowarn "-> exit means kill!"
else else
echoinfo "successful installation" echoinfo "successful installation"
fi fi

Loading…
Cancel
Save