Automation of a local dev environment to learn, self-document, save time and avoid to reinvent the wheel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
debian-unattended/custom/add_to_docker_group.sh

15 lines
419 B

#!/bin/sh
if [ "$(id -u)" -ne 0 ]; then
echo "This script should be run as root. Aborting..." > /dev/stderr
exit 1
fi
echo "Adding user to the docker group..."
# This if statement evaulates if the script is launched using sudo AND not
# a `sudo su` logged user
if [ -n "$SUDO_USER" ] && [ "$SUDO_COMMAND" != "/usr/bin/su" ]; then
usermod -aG docker "$SUDO_USER"
else
usermod -aG docker "$(id -un)"
fi