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]}"
|
gid="${param[3]}"
|
||||||
fi
|
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"
|
useraddOptions="--no-user-group"
|
||||||
|
|
||||||
if [ -n "$uid" ]; then
|
if [ -n "$uid" ]; then
|
||||||
|
@ -75,32 +80,37 @@ if [ "$1" == "--readme" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Append mounted config to final config
|
# Create final config
|
||||||
if [ -f "$userConfPath" ]; then
|
if [ ! -f "$userConfFinalPath" ]; then
|
||||||
|
|
||||||
|
# Append mounted config to final config
|
||||||
|
if [ -f "$userConfPath" ]; then
|
||||||
cat "$userConfPath" >> "$userConfFinalPath"
|
cat "$userConfPath" >> "$userConfFinalPath"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Append users from arguments to final config
|
# Append users from arguments to final config
|
||||||
for user in "$@"; do
|
for user in "$@"; do
|
||||||
echo "$user" >> "$userConfFinalPath"
|
echo "$user" >> "$userConfFinalPath"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Append users from STDIN to final config
|
# Append users from STDIN to final config
|
||||||
if [ ! -t 0 ]; then
|
if [ ! -t 0 ]; then
|
||||||
while IFS= read -r user || [[ -n "$user" ]]; do
|
while IFS= read -r user || [[ -n "$user" ]]; do
|
||||||
echo "$user" >> "$userConfFinalPath"
|
echo "$user" >> "$userConfFinalPath"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$userConfFinalPath" ]; then
|
if [ ! -f "$userConfFinalPath" ]; then
|
||||||
echo "ERROR: Missing users!"
|
echo "ERROR: Missing users!"
|
||||||
printHelp
|
printHelp
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Import users from final conf file
|
||||||
|
while IFS= read -r user || [[ -n "$user" ]]; do
|
||||||
|
createUser "$user"
|
||||||
|
done < "$userConfFinalPath"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Import users from final conf file
|
|
||||||
while IFS= read -r user || [[ -n "$user" ]]; do
|
|
||||||
createUser "$user"
|
|
||||||
done < "$userConfFinalPath"
|
|
||||||
|
|
||||||
exec /usr/sbin/sshd -D
|
exec /usr/sbin/sshd -D
|
||||||
|
|
Loading…
Reference in a new issue