Browse Source

Add FTP_OPTIONS

pull/625/head
Tim Kimber 5 years ago
parent
commit
4d23e085e1
No known key found for this signature in database GPG Key ID: 3E1804964E76BD18
2 changed files with 32 additions and 7 deletions
  1. +30
    -6
      getssl
  2. +2
    -1
      test/33-ftp.bats

+ 30
- 6
getssl View File

@ -274,6 +274,7 @@ DEACTIVATE_AUTH="false"
DEFAULT_REVOKE_CA="https://acme-v02.api.letsencrypt.org"
DOMAIN_KEY_LENGTH=4096
DUAL_RSA_ECDSA="false"
FTP_OPTIONS=""
GETSSL_IGNORE_CP_PRESERVE="false"
HTTP_TOKEN_CHECK_WAIT=0
IGNORE_DIRECTORY_DOMAIN="false"
@ -842,6 +843,9 @@ copy_file_to_location() { # copies a file, using scp, sftp or ftp if required.
if [[ "$cert" != "challenge token" ]] ; then
error_exit "ftp is not a secure method for copying certificates or keys"
fi
if [[ -z "$FTP_COMMAND" ]]; then
error_exit "No ftp command found"
fi
debug "using ftp to copy the file from $from"
ftpuser=$(echo "$to"| awk -F: '{print $2}')
ftppass=$(echo "$to"| awk -F: '{print $3}')
@ -853,13 +857,18 @@ copy_file_to_location() { # copies a file, using scp, sftp or ftp if required.
fromfile=$(basename "$from")
debug "ftp user=$ftpuser - pass=$ftppass - host=$ftphost dir=$ftpdirn file=$ftpfile"
debug "from dir=$fromdir file=$fromfile"
ftp -n <<- _EOF
open $ftphost
user $ftpuser $ftppass
if [ -n "$FTP_OPTIONS" ]; then
# Use eval to expand any variables in FTP_OPTIONS
FTP_OPTIONS=$(eval echo "$FTP_OPTIONS")
debug "FTP_OPTIONS=$FTP_OPTIONS"
fi
$FTP_COMMAND <<- _EOF
connect $ftphost
user $ftpuser $ftppass
cd $ftpdirn
lcd $fromdir
put ./$fromfile
chmod 644 $fromfile
$FTP_OPTIONS
_EOF
elif [[ "${to:0:5}" == "sftp:" ]] ; then
debug "using sftp to copy the file from $from"
@ -1119,6 +1128,18 @@ find_dns_utils() {
fi
}
find_ftp_command() {
FTP_COMMAND=""
if [[ -n "$(command -v ftp 2>/dev/null)" ]]; then
debug "Has ftp"
FTP_COMMAND="ftp -n"
elif [[ -n "$(command -v lftp 2>/dev/null)" ]]; then
debug "Has lftp"
FTP_COMMAND="lftp"
fi
}
fulfill_challenges() {
dn=0
for d in "${alldomains[@]}"; do
@ -1268,8 +1289,8 @@ for d in "${alldomains[@]}"; do
ftppass=$(echo "${t_loc}"| awk -F: '{print $3}')
ftphost=$(echo "${t_loc}"| awk -F: '{print $4}')
ftplocn=$(echo "${t_loc}"| awk -F: '{print $5}')
debug "ftp user=$ftpuser - pass=$ftppass - host=$ftphost location=$ftplocn"
ftp -n <<- EOF
debug "$FTP_COMMAND user=$ftpuser - pass=$ftppass - host=$ftphost location=$ftplocn"
$FTP_COMMAND <<- EOF
open $ftphost
user $ftpuser $ftppass
cd $ftplocn
@ -2654,6 +2675,9 @@ set_server_type
# check what dns utils are installed
find_dns_utils
# Find what ftp client is installed
find_ftp_command
# auto upgrade clients to v2
auto_upgrade_v2


+ 2
- 1
test/33-ftp.bats View File

@ -29,9 +29,10 @@ setup() {
cat <<- EOF > ${INSTALL_DIR}/.getssl/${GETSSL_CMD_HOST}/getssl_test_specific.cfg
ACL="ftp:ftpuser:ftpuser:${GETSSL_CMD_HOST}:/var/www/html/.well-known/acme-challenge"
FTP_OPTIONS="chmod 644 \\\$fromfile"
EOF
create_certificate -d
create_certificate
assert_success
check_output_for_errors
}

Loading…
Cancel
Save