mirror of
https://github.com/atmoz/sftp.git
synced 2024-11-17 12:51:33 -05:00
Do not create users on container restart
This commit is contained in:
parent
55d879419f
commit
c388a4ec68
1 changed files with 31 additions and 21 deletions
40
entrypoint
40
entrypoint
|
@ -35,6 +35,11 @@ function createUser() {
|
|||
gid="${param[3]}"
|
||||
fi
|
||||
|
||||
if $(cat /etc/passwd | cut -d: -f3 | grep -q "$uid"); then
|
||||
echo "User with UID \"$uid\" already exists, skipping."
|
||||
return 0
|
||||
fi
|
||||
|
||||
useraddOptions="--no-user-group"
|
||||
|
||||
if [ -n "$uid" ]; then
|
||||
|
@ -75,32 +80,37 @@ if [ "$1" == "--readme" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
# Append mounted config to final config
|
||||
if [ -f "$userConfPath" ]; then
|
||||
# Create final config
|
||||
if [ ! -f "$userConfFinalPath" ]; then
|
||||
|
||||
# Append mounted config to final config
|
||||
if [ -f "$userConfPath" ]; then
|
||||
cat "$userConfPath" >> "$userConfFinalPath"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Append users from arguments to final config
|
||||
for user in "$@"; do
|
||||
# Append users from arguments to final config
|
||||
for user in "$@"; do
|
||||
echo "$user" >> "$userConfFinalPath"
|
||||
done
|
||||
done
|
||||
|
||||
# Append users from STDIN to final config
|
||||
if [ ! -t 0 ]; then
|
||||
# Append users from STDIN to final config
|
||||
if [ ! -t 0 ]; then
|
||||
while IFS= read -r user || [[ -n "$user" ]]; do
|
||||
echo "$user" >> "$userConfFinalPath"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f "$userConfFinalPath" ]; then
|
||||
if [ ! -f "$userConfFinalPath" ]; then
|
||||
echo "ERROR: Missing users!"
|
||||
printHelp
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Import users from final conf file
|
||||
while IFS= read -r user || [[ -n "$user" ]]; do
|
||||
createUser "$user"
|
||||
done < "$userConfFinalPath"
|
||||
|
||||
fi
|
||||
|
||||
# Import users from final conf file
|
||||
while IFS= read -r user || [[ -n "$user" ]]; do
|
||||
createUser "$user"
|
||||
done < "$userConfFinalPath"
|
||||
|
||||
exec /usr/sbin/sshd -D
|
||||
|
|
Loading…
Reference in a new issue