Commit ddf293bb authored by neilpang's avatar neilpang
Browse files

reload only for renewal

parent 45d6e00f
...@@ -29,9 +29,24 @@ vsftpd_deploy() { ...@@ -29,9 +29,24 @@ vsftpd_deploy() {
return 1 return 1
fi fi
_info "Copying key and cert"
_real_key="$_ssl_path/vsftpd.key"
if ! cat "$_ckey" >"$_real_key"; then
_err "Error: write key file to: $_real_key"
return 1
fi
_real_fullchain="$_ssl_path/vsftpd.chain.pem"
if ! cat "$_cfullchain" >"$_real_fullchain"; then
_err "Error: write key file to: $_real_fullchain"
return 1
fi
DEFAULT_VSFTPD_RELOAD="service vsftpd restart"
_reload="${DEPLOY_VSFTPD_RELOAD:-$DEFAULT_VSFTPD_RELOAD}"
if [ -z "$IS_RENEW" ]; then
DEFAULT_VSFTPD_CONF="/etc/vsftpd.conf" DEFAULT_VSFTPD_CONF="/etc/vsftpd.conf"
_vsftpd_conf="${DEPLOY_VSFTPD_CONF:-$DEFAULT_VSFTPD_CONF}" _vsftpd_conf="${DEPLOY_VSFTPD_CONF:-$DEFAULT_VSFTPD_CONF}"
if [ ! -f "$_vsftpd_conf" ]; then if [ ! -f "$_vsftpd_conf" ]; then
if [ -z "$DEPLOY_VSFTPD_CONF" ]; then if [ -z "$DEPLOY_VSFTPD_CONF" ]; then
_err "vsftpd conf is not found, please define DEPLOY_VSFTPD_CONF" _err "vsftpd conf is not found, please define DEPLOY_VSFTPD_CONF"
...@@ -41,36 +56,35 @@ vsftpd_deploy() { ...@@ -41,36 +56,35 @@ vsftpd_deploy() {
return 1 return 1
fi fi
fi fi
if [ ! -w "$_vsftpd_conf" ]; then if [ ! -w "$_vsftpd_conf" ]; then
_err "The file $_vsftpd_conf is not writable, please change the permission." _err "The file $_vsftpd_conf is not writable, please change the permission."
return 1 return 1
fi fi
_backup_conf="$DOMAIN_BACKUP_PATH/vsftpd.conf.bak" _backup_conf="$DOMAIN_BACKUP_PATH/vsftpd.conf.bak"
_info "Backup $_vsftpd_conf to $_backup_conf" _info "Backup $_vsftpd_conf to $_backup_conf"
cp "$_vsftpd_conf" "$_backup_conf" cp "$_vsftpd_conf" "$_backup_conf"
_info "Copying key and cert" _info "Modify vsftpd conf: $_vsftpd_conf"
_real_key="$_ssl_path/vsftpd.key" if _setopt "$_vsftpd_conf" "rsa_cert_file" "=" "$_real_fullchain" \
if ! cat "$_ckey" >"$_real_key"; then && _setopt "$_vsftpd_conf" "rsa_private_key_file" "=" "$_real_key" \
_err "Error: write key file to: $_real_key" && _setopt "$_vsftpd_conf" "ssl_enable" "=" "YES"; then
return 1 _info "Set config success!"
else
_err "Config vsftpd server error, please report bug to us."
_info "Restoring vsftpd conf"
if cat "$_backup_conf" >"$_vsftpd_conf"; then
_info "Restore conf success"
eval "$_reload"
else
_err "Opps, error restore vsftpd conf, please report bug to us."
fi fi
_real_fullchain="$_ssl_path/vsftpd.chain.pem"
if ! cat "$_cfullchain" >"$_real_fullchain"; then
_err "Error: write key file to: $_real_fullchain"
return 1 return 1
fi fi
_info "Modify vsftpd conf: $_vsftpd_conf" fi
DEFAULT_VSFTPD_RELOAD="service vsftpd restart" _info "Run reload: $_reload"
_reload="${DEPLOY_VSFTPD_RELOAD:-$DEFAULT_VSFTPD_RELOAD}" if eval "$_reload"; then
if _setopt "$_vsftpd_conf" "rsa_cert_file" "=" "$_real_fullchain" \ _info "Reload success!"
&& _setopt "$_vsftpd_conf" "rsa_private_key_file" "=" "$_real_key" \
&& _setopt "$_vsftpd_conf" "ssl_enable" "=" "YES" \
&& eval "$_reload"; then
_info "Deploy success!"
if [ "$DEPLOY_VSFTPD_CONF" ]; then if [ "$DEPLOY_VSFTPD_CONF" ]; then
_savedomainconf DEPLOY_VSFTPD_CONF "$DEPLOY_VSFTPD_CONF" _savedomainconf DEPLOY_VSFTPD_CONF "$DEPLOY_VSFTPD_CONF"
else else
...@@ -83,8 +97,7 @@ vsftpd_deploy() { ...@@ -83,8 +97,7 @@ vsftpd_deploy() {
fi fi
return 0 return 0
else else
_err "Config vsftpd server error, please report bug to us." _err "Reload error, restoring"
_info "Restoring vsftpd conf"
if cat "$_backup_conf" >"$_vsftpd_conf"; then if cat "$_backup_conf" >"$_vsftpd_conf"; then
_info "Restore conf success" _info "Restore conf success"
eval "$_reload" eval "$_reload"
...@@ -93,5 +106,5 @@ vsftpd_deploy() { ...@@ -93,5 +106,5 @@ vsftpd_deploy() {
fi fi
return 1 return 1
fi fi
return 1 return 0
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment