diff --git a/src/Dockerfile b/src/Dockerfile index 1d7aec88b..f6079a621 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -27,6 +27,7 @@ RUN apk add --no-cache \ coreutils \ procps \ ncurses \ + shadow \ binutils \ tzdata diff --git a/src/bash_functions.sh b/src/bash_functions.sh index 89a47a9c9..2556144d2 100644 --- a/src/bash_functions.sh +++ b/src/bash_functions.sh @@ -198,6 +198,30 @@ setup_web_password() { fi } +modifyUser() +{ + declare username=${1:-} newId=${2:-} + [[ -z ${username} || -z ${newId} ]] && return + + local currentId=$(id -u ${username}) + [[ ${currentId} -eq ${newId} ]] && return + + echo " [i] Changing ID for user: ${username} (${currentId} => ${newId})" + usermod -o -u ${newId} ${username} +} + +modifyGroup() +{ + declare groupname=${1:-} newId=${2:-} + [[ -z ${groupname} || -z ${newId} ]] && return + + local currentId=$(id -g ${groupname}) + [[ ${currentId} -eq ${newId} ]] && return + + echo " [i] Changing ID for group: ${groupname} (${currentId} => ${newId})" + groupmod -o -g ${newId} ${groupname} +} + # setup_blocklists() { # # Exit/return early without setting up adlists with defaults for any of the following conditions: # # 1. skip_setup_blocklists env is set diff --git a/src/start.sh b/src/start.sh index f538c297e..536b7d324 100644 --- a/src/start.sh +++ b/src/start.sh @@ -9,6 +9,8 @@ fi # shellcheck source=/dev/null . /usr/bin/bash_functions.sh +modifyUser pihole ${PIHOLE_UID} +modifyGroup pihole ${PIHOLE_GID} # shellcheck source=/dev/null # SKIP_INSTALL=true . /etc/.pihole/automated\ install/basic-install.sh