Skip to content

Commit

Permalink
Only create samba user if not already existing
Browse files Browse the repository at this point in the history
Check via pdbedit whether the samba user already exists and only call smbpasswd if it does not. This avoids reset of the password on every container restart.
  • Loading branch information
bdabelow committed Dec 29, 2024
1 parent 0f2b8b4 commit 7461d75
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rootfs/etc/cont-init.d/01-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if [[ "$(yq --output-format=json e '(.. | select(tag == "!!str")) |= envsubst' "
echo "Creating user $(_jq '.user')/$(_jq '.group') ($(_jq '.uid'):$(_jq '.gid'))"
id -g "$(_jq '.gid')" &>/dev/null || id -gn "$(_jq '.group')" &>/dev/null || addgroup -g "$(_jq '.gid')" -S "$(_jq '.group')"
id -u "$(_jq '.uid')" &>/dev/null || id -un "$(_jq '.user')" &>/dev/null || adduser -u "$(_jq '.uid')" -G "$(_jq '.group')" "$(_jq '.user')" -SHD
echo -e "$password\n$password" | smbpasswd -a -s "$(_jq '.user')"
pdbedit -L -u "$(_jq '.user')" &>/dev/null || echo -e "$password\n$password" | smbpasswd -a -s "$(_jq '.user')"
unset password
done
fi
Expand Down

0 comments on commit 7461d75

Please sign in to comment.