Update user ID and group ID only when necessary

This commit is contained in:
Chocobo1 2024-05-18 11:48:10 +08:00
parent 0efd9c5813
commit bee722307c
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
2 changed files with 4 additions and 4 deletions

View File

@ -4,11 +4,11 @@ downloadsPath="/downloads"
profilePath="/config"
qbtConfigFile="$profilePath/qBittorrent/config/qBittorrent.conf"
if [ -n "$PUID" ]; then
if [ -n "$PUID" ] && [ "$PUID" != "$(id -u qbtUser)" ]; then
sed -i "s|^qbtUser:x:[0-9]*:|qbtUser:x:$PUID:|g" /etc/passwd
fi
if [ -n "$PGID" ]; then
if [ -n "$PGID" ] && [ "$PGID" != "$(id -g qbtUser)" ]; then
sed -i "s|^\(qbtUser:x:[0-9]*\):[0-9]*:|\1:$PGID:|g" /etc/passwd
sed -i "s|^qbtUser:x:[0-9]*:|qbtUser:x:$PGID:|g" /etc/group
fi

View File

@ -4,11 +4,11 @@ downloadsPath="/downloads"
profilePath="/config"
qbtConfigFile="$profilePath/qBittorrent/config/qBittorrent.conf"
if [ -n "$PUID" ]; then
if [ -n "$PUID" ] && [ "$PUID" != "$(id -u qbtUser)" ]; then
sed -i "s|^qbtUser:x:[0-9]*:|qbtUser:x:$PUID:|g" /etc/passwd
fi
if [ -n "$PGID" ]; then
if [ -n "$PGID" ] && [ "$PGID" != "$(id -g qbtUser)" ]; then
sed -i "s|^\(qbtUser:x:[0-9]*\):[0-9]*:|\1:$PGID:|g" /etc/passwd
sed -i "s|^qbtUser:x:[0-9]*:|qbtUser:x:$PGID:|g" /etc/group
fi