-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_setup.sh
executable file
·28 lines (25 loc) · 1.07 KB
/
docker_setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
# If the OS is MacOS, then nothing needs to be done.
if [ "$(uname)" == "Darwin" ]; then
exit 0
fi
# If the user is root, then nothing needs to be done.
if [ "$(id -u)" = "0" ]; then
exit 0
fi
# If the user is not in the docker group, then add them to the group.
if ! groups $USER | grep -q '\bdocker\b'; then
printf "\033[92m========== This account is NOT in the docker group ==========\033[0m\n"
# Ask the user if they want to add the user to the docker group.
read -p "Do you want to add yourself to the docker group? [y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Add the user to the docker group.
sudo getent group docker || sudo groupadd docker
sudo usermod -aG docker $USER
# Tell the user to log out and log back in for changes to take effect.
printf "\033[92m========== You must log out and back in for changes to take effect. ==========\033[0m\n"
printf "\033[92m========== You may need to reboot entirely if you still get permission denied. ==========\033[0m\n"
exit 1
fi
fi