mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-27 14:22:34 +08:00
Add support for PUID/PGID environment variables
These arefor setting the user/group to drop privileges to. Closes #2441. Thanks to matthewparkes.
This commit is contained in:
@@ -3,8 +3,14 @@ set -e
|
||||
|
||||
# Set permissions
|
||||
user="$(id -u)"
|
||||
if [ "$PUID" = "" ]; then
|
||||
PUID="mosquitto"
|
||||
fi
|
||||
if [ "$PGID" = "" ]; then
|
||||
PGID="mosquitto"
|
||||
fi
|
||||
if [ "$user" = '0' ]; then
|
||||
[ -d "/mosquitto" ] && chown -R mosquitto:mosquitto /mosquitto || true
|
||||
[ -d "/mosquitto" ] && chown -R ${PUID}:${PGID} /mosquitto || true
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
||||
Reference in New Issue
Block a user