From 65da84b491303709953b6feb1657c3f76b44ec15 Mon Sep 17 00:00:00 2001 From: Edi Septriyanto Date: Sun, 2 Jan 2022 23:37:52 +0700 Subject: [PATCH] Add SSL support when build from source --- scripts/install_vsftpd.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/scripts/install_vsftpd.sh b/scripts/install_vsftpd.sh index c67c42a..9dd247e 100755 --- a/scripts/install_vsftpd.sh +++ b/scripts/install_vsftpd.sh @@ -14,7 +14,7 @@ if [[ "$(type -t run)" != "function" ]]; then fi # Make sure only root can run this installer script. -requires_root +requires_root "$@" # Make sure only supported distribution can run this installer script. preflight_system_check @@ -118,7 +118,7 @@ function init_vsftpd_install() { elif [[ -f "${LIB_GNU_DIR}/libcap.so" ]]; then run ln -s "${LIB_GNU_DIR}/libcap.so" "${LIB_DIR}/libcap.so" else - error "Cannot find libcap.so file." + echo "Cannot find libcap.so file." fi local CURRENT_DIR && \ @@ -135,11 +135,21 @@ function init_vsftpd_install() { run cd "${BUILD_DIR}" && \ run wget -q "${VSFTPD_ZIP_URL}" && \ run tar -zxf "${VSFTPD_FILENAME}" && \ - run cd vsftpd-*/ && \ + run cd vsftpd-*/ || return 1 + + # If SSL Enabled, modify the builddefs.h file. + if [[ "${VSFTPD_SSL_ENABLE}" == true ]]; then + run sed -i 's/\#undef\ VSF_BUILD_SSL/\#define\ VSF_BUILD_SSL/g' ./builddefs.h + fi + run make && \ run make install && \ run ldconfig /usr/local/lib && \ run cd "${CURRENT_DIR}" || return 1 + + # Move executable to /usr/sbin. + [ -x /usr/local/sbin/vsftpd ] && \ + run mv /usr/local/sbin/vsftpd /usr/sbin/ ;; *) # Skip installation. @@ -182,9 +192,13 @@ pasv_max_port=50000 user_sub_token=$USER local_root=/home/$USER -rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key -ssl_enable=Yes +EOL + + # Enable SSL. + if [[ "${VSFTPD_SSL_ENABLE}" == true ]]; then + cat >> /etc/vsftpd.conf <