diff --git a/README.md b/README.md index e186f84..c952df8 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ services: - "80:80/tcp" environment: TZ: 'America/Chicago' + WEB_UID: '1001' + WEB_GID: '1000' + PIHOLE_UID: '1001' + PIHOLE_GID: '1000' # WEBPASSWORD: 'set a secure password here or it will be random' # Volumes store your data between container upgrades volumes: @@ -128,6 +132,10 @@ There are other environment variables if you want to customize various things in | `CORS_HOSTS` | unset | `` | List of domains/subdomains on which CORS is allowed. Wildcards are not supported. Eg: `CORS_HOSTS: domain.com,home.domain.com,www.domain.com`. | `CUSTOM_CACHE_SIZE` | `10000` | Number | Set the cache size for dnsmasq. Useful for increasing the default cache size or to set it to 0. Note that when `DNSSEC` is "true", then this setting is ignored. | `FTLCONF_[SETTING]` | unset | As per documentation | Customize pihole-FTL.conf with settings described in the [FTLDNS Configuration page](https://docs.pi-hole.net/ftldns/configfile/). For example, to customize REPLY_ADDR6, ensure you have the `FTLCONF_REPLY_ADDR6` environment variable set. +| PIHOLE_UID | debian system value | Number | Overrides image's default pihole user id to match a host user id | +| PIHOLE_GID | debian system value | Number | Overrides image's default pihole group id to match a host group id | +| WEB_UID | debian system value | Number | Overrides image's default www-data user id to match a host user id | +| WEB_GID | debian system value | Number | Overrides image's default www-data group id to match a host group id | ### Experimental Variables | Variable | Default | Value | Description | diff --git a/s6/debian-root/etc/cont-init.d/05-changer-uid-gid.sh b/s6/debian-root/etc/cont-init.d/05-changer-uid-gid.sh new file mode 100644 index 0000000..eafab4f --- /dev/null +++ b/s6/debian-root/etc/cont-init.d/05-changer-uid-gid.sh @@ -0,0 +1,37 @@ +#!/usr/bin/with-contenv bash +set -e + +modifyUser() +{ + declare username=${1:-} newId=${2:-} + [[ -z ${username} || -z ${newId} ]] && return + + local currentId=$(id -u ${username}) + [[ ${currentId} -eq ${newId} ]] && return + + echo "user ${username} ${currentId} => ${newId}" + usermod -o -u ${newId} ${username} + + find / -user ${currentId} -print0 2> /dev/null | \ + xargs -0 -n1 chown -h ${username} 2> /dev/null +} + +modifyGroup() +{ + declare groupname=${1:-} newId=${2:-} + [[ -z ${groupname} || -z ${newId} ]] && return + + local currentId=$(id -g ${groupname}) + [[ ${currentId} -eq ${newId} ]] && return + + echo "group ${groupname} ${currentId} => ${newId}" + groupmod -o -g ${newId} ${groupname} + + find / -group ${currentId} -print0 2> /dev/null | \ + xargs -0 -n1 chgrp -h ${groupname} 2> /dev/null +} + +modifyUser www-data ${WEB_UID} +modifyGroup www-data ${WEB_GID} +modifyUser pihole ${PIHOLE_UID} +modifyGroup pihole ${PIHOLE_GID}