update base image; add compose file
This commit is contained in:
19
entry.sh
19
entry.sh
@@ -5,12 +5,21 @@ set -e
|
||||
|
||||
[[ "${DEBUG}" == "true" ]] && set -x
|
||||
|
||||
# Replace variables in config files
|
||||
for file in /templates/*; do
|
||||
if [[ -f "$file" ]]; then
|
||||
filename=$(basename "$file")
|
||||
envsubst < "$file" > "/etc/$filename"
|
||||
echo "Created /etc/${filename}"
|
||||
fi
|
||||
done
|
||||
|
||||
# Generate password if hash not set
|
||||
if [[ ! -z "${FTP_PASSWORD}" ]] && [[ -z "${FTP_PASSWORD_HASH}" ]]; then
|
||||
if [[ -n "${FTP_PASSWORD}" ]] && [[ -z "${FTP_PASSWORD_HASH}" ]]; then
|
||||
FTP_PASSWORD_HASH="$(echo "${FTP_PASSWORD}" | mkpasswd -s -m sha-512)"
|
||||
fi
|
||||
|
||||
if [[ ! -z "${FTP_USER}" ]] || [[ ! -z "${FTP_PASSWORD_HASH}" ]]; then
|
||||
if [[ -n "${FTP_USER}" ]] || [[ -n "${FTP_PASSWORD_HASH}" ]]; then
|
||||
/add-virtual-user.sh -d "${FTP_USER}" "${FTP_PASSWORD_HASH}"
|
||||
fi
|
||||
|
||||
@@ -22,20 +31,20 @@ while read -r user; do
|
||||
done < <(env | grep "FTP_USER_" | sed 's/^\(FTP_USER_[a-zA-Z0-9]*\)=.*/\1/')
|
||||
|
||||
# Support user directories
|
||||
if [[ ! -z "${FTP_USERS_ROOT}" ]]; then
|
||||
if [[ -n "${FTP_USERS_ROOT}" ]]; then
|
||||
# shellcheck disable=SC2016
|
||||
sed -i 's/local_root=.*/local_root=\/srv\/$USER/' /etc/vsftpd*.conf
|
||||
fi
|
||||
|
||||
# Support setting the passive address
|
||||
if [[ ! -z "$FTP_PASV_ADDRESS" ]]; then
|
||||
if [[ -n "$FTP_PASV_ADDRESS" ]]; then
|
||||
for f in /etc/vsftpd*.conf; do
|
||||
echo "pasv_address=${FTP_PASV_ADDRESS}" >> "$f"
|
||||
done
|
||||
fi
|
||||
|
||||
# Manage /srv permissions
|
||||
if [[ ! -z "${FTP_CHOWN_ROOT}" ]]; then
|
||||
if [[ -n "${FTP_CHOWN_ROOT}" ]]; then
|
||||
chown ftp:ftp /srv
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user