0
0
Fork 0
mirror of https://github.com/atmoz/sftp.git synced 2024-11-17 12:51:33 -05:00

Switch file test to "file exists"

Conditions will now pass if files are actually symlinks (as in the case of Kubernetes volumeMounts).
This commit is contained in:
Nick Savage 2019-06-28 11:03:11 +01:00 committed by GitHub
parent bd437a09cb
commit 63cf6e872c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,16 +24,16 @@ else
fi fi
# Backward compatibility with legacy config path # Backward compatibility with legacy config path
if [ ! -f "$userConfPath" ] && [ -f "$userConfPathLegacy" ]; then if [ ! -e "$userConfPath" ] && [ -e "$userConfPathLegacy" ]; then
mkdir -p "$(dirname $userConfPath)" mkdir -p "$(dirname $userConfPath)"
ln -s "$userConfPathLegacy" "$userConfPath" ln -s "$userConfPathLegacy" "$userConfPath"
fi fi
# Create users only on first run # Create users only on first run
if [ ! -f "$userConfFinalPath" ]; then if [ ! -e "$userConfFinalPath" ]; then
mkdir -p "$(dirname $userConfFinalPath)" mkdir -p "$(dirname $userConfFinalPath)"
if [ -f "$userConfPath" ]; then if [ -e "$userConfPath" ]; then
# Append mounted config to final config # Append mounted config to final config
grep -v -E "$reArgSkip" < "$userConfPath" > "$userConfFinalPath" grep -v -E "$reArgSkip" < "$userConfPath" > "$userConfFinalPath"
fi fi
@ -54,7 +54,7 @@ if [ ! -f "$userConfFinalPath" ]; then
fi fi
# Check that we have users in config # Check that we have users in config
if [ -f "$userConfFinalPath" ] && [ "$(wc -l < "$userConfFinalPath")" -gt 0 ]; then if [ -e "$userConfFinalPath" ] && [ "$(wc -l < "$userConfFinalPath")" -gt 0 ]; then
# Import users from final conf file # Import users from final conf file
while IFS= read -r user || [[ -n "$user" ]]; do while IFS= read -r user || [[ -n "$user" ]]; do
create-sftp-user "$user" create-sftp-user "$user"
@ -65,10 +65,10 @@ if [ ! -f "$userConfFinalPath" ]; then
fi fi
# Generate unique ssh keys for this container, if needed # Generate unique ssh keys for this container, if needed
if [ ! -f /etc/ssh/ssh_host_ed25519_key ]; then if [ ! -e /etc/ssh/ssh_host_ed25519_key ]; then
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N '' ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
fi fi
if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then if [ ! -e /etc/ssh/ssh_host_rsa_key ]; then
ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N '' ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N ''
fi fi
fi fi