Skip to content

Commit

Permalink
Refresh your session after installing docker
Browse files Browse the repository at this point in the history
- Ensures the user is in the docker group when executing the script for the first time
- Fixes #40
  • Loading branch information
judahpaul16 committed May 25, 2024
1 parent 9a82e89 commit 87f6f18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions contrib/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 87f6f18

Please sign in to comment.