From 87f6f182698d913be174d286fc778f626ecaafea Mon Sep 17 00:00:00 2001 From: judahpaul16 Date: Sat, 25 May 2024 13:34:58 -0400 Subject: [PATCH] Refresh your session after installing docker - Ensures the user is in the docker group when executing the script for the first time - Fixes #40 --- README.md | 17 +++++++---------- contrib/setup.sh | 17 +++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index df2cad4..d6595b3 100644 --- a/README.md +++ b/README.md @@ -494,16 +494,6 @@ echo " _|_||_|_ \\" echo " ____ |___||___| \\" echo -e "${NC}" -# Add user to the Docker group -sudo groupadd docker 2>/dev/null -sudo usermod -aG docker $USER - -# Check if script is running with 'docker' group -if ! groups $USER | grep -q "\bdocker\b"; then - echo "Re-executing script to apply Docker group membership..." - exec sg docker "$0 $*" -fi - # Mask systemd-networkd-wait-online.service to prevent boot delays sudo systemctl mask systemd-networkd-wait-online.service @@ -553,6 +543,13 @@ function install() { echo "Package manager not supported." return 1 fi + + if [$package == "docker"]; then + echo "Docker installed. Adding user to docker group..." + sudo usermod -aG docker $(whoami) + echo "User added to \`docker\` group but session must be reloaded. Please log out, log back in, and rerun the script. Exiting..." + exit 0 + fi } install chrony diff --git a/contrib/setup.sh b/contrib/setup.sh index 2c4831d..7039b39 100644 --- a/contrib/setup.sh +++ b/contrib/setup.sh @@ -51,16 +51,6 @@ echo " _|_||_|_ \\" echo " ____ |___||___| \\" echo -e "${NC}" -# Add user to the Docker group -sudo groupadd docker 2>/dev/null -sudo usermod -aG docker $USER - -# Check if script is running with 'docker' group -if ! groups $USER | grep -q "\bdocker\b"; then - echo "Re-executing script to apply Docker group membership..." - exec sg docker "$0 $*" -fi - # Mask systemd-networkd-wait-online.service to prevent boot delays sudo systemctl mask systemd-networkd-wait-online.service @@ -110,6 +100,13 @@ function install() { echo "Package manager not supported." return 1 fi + + if [$package == "docker"]; then + echo "Docker installed. Adding user to docker group..." + sudo usermod -aG docker $(whoami) + echo "User added to \`docker\` group but session must be reloaded. Please log out, log back in, and rerun the script. Exiting..." + exit 0 + fi } install chrony