From 13194499f5d40613118af83f8d318b878f07db69 Mon Sep 17 00:00:00 2001 From: pvincent Date: Tue, 27 Feb 2024 18:00:15 +0400 Subject: [PATCH] exec sg --- lib/install.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/install.sh b/lib/install.sh index f903976..1f6348e 100755 --- a/lib/install.sh +++ b/lib/install.sh @@ -32,7 +32,7 @@ function prepare_lxd { echo "define lxd and assign to user <$USER>" sudo groupadd --force "$NEW_GROUP" sudo usermod --append --groups "$NEW_GROUP" "$(whoami)" - exec sg "$NEW_GROUP" exec "$0 $TARGET SESSION_RELOAD_REQUIRED $@" + exec sg "$NEW_GROUP" -c "$0 SESSION_RELOAD_REQUIRED $TARGET $@" # no further processing because exec has been called! else echo "user <$USER> already belongs to group !" @@ -49,7 +49,7 @@ function prepare_lxd { if [[ $(printenv container) == 'lxc' ]]; then echo "nested configuration applying..." - cat < ... " - lxc profile set default environment.container_hostname "$env_container_hostname" + sg $NEW_GROUP -c "lxc profile set default environment.container_hostname \"$env_container_hostname\"" PREFIX="" echoinfo OK else echo "environment container_hostname <$env_container_hostname> already defined!" @@ -373,19 +378,19 @@ function preload_bookworm_image { local PREFIX="preload:bookworm" if [[ $(lxc image list debian/12/cloud -f csv | wc -l) -lt 1 ]]; then - echo -n "downloading images from publc remote, please hold on..." - lxc image copy images:debian/12/cloud local: --copy-aliases --quiet + echo -n "downloading images from public remote, please hold on..." + sg $NEW_GROUP -c 'lxc image copy images:debian/12/cloud local: --copy-aliases --quiet' PREFIX="" echoinfo OK else - echo -n "refreshing images from publc remote..." - lxc image refresh debian/12/cloud --quiet + echo -n "refreshing images from public remote..." + sg $NEW_GROUP -c 'lxc image refresh debian/12/cloud --quiet' PREFIX="" echoinfo DONE fi } ### MAIN -if [[ "${2:-}" == "SESSION_RELOAD_REQUIRED" ]]; then +if [[ "${1:-}" == "SESSION_RELOAD_REQUIRED" ]]; then SESSION_RELOAD_REQUIRED=true shift else @@ -426,9 +431,12 @@ else opt_link extra_dev_desktop - if [[ "$SESSION_RELOAD_REQUIRED" == false ]]; then - echoinfo "successful installation" + 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 " + sg $NEW_GROUP -c bash else - echowarn "please reload your session, .bashrc needs to be reloaded!" + echoinfo "successful installation" fi fi