#!/bin/bash if [ $# -ne 1 ] ; then ACME_SH_ENV_FILE="$1" fi if [ -f "/etc/default/acme_sh_request_env" ] ; then # shellcheck disable=SC1091 . "/etc/default/acme_sh_request_env" else exit 1 fi if [ -n "$ACME_SH_ENV_FILE" ] && [ -f "$ACME_SH_ENV_FILE" ] ; then # shellcheck source=/dev/null . "$ACME_SH_ENV_FILE" else exit 1 fi RETVAL= if [ ! -f "$ACME_SH_CONFIG_HOME/ok_certificate_issued" ] && [ "$ACME_SH_USE_DNS_PROVIDER" == "False" ] ; then # First request. Try to shut down all the services running on port 80 if [ -x /bin/systemctl ] ; then /bin/systemctl stop nginx >/dev/null 2>&1 /bin/systemctl stop apache2 >/dev/null 2>&1 /bin/systemctl stop httpd >/dev/null 2>&1 else service nginx stop >/dev/null 2>&1 service apache2 stop >/dev/null 2>&1 service httpd stop >/dev/null 2>&1 fi $ACME_SH_BIN $ACME_SH_FIRST_CERT_REQUEST > "$ACME_SH_ISSUE_LOG_FILE" 2>&1 RETVAL=$? if [ -x /bin/systemctl ] ; then /bin/systemctl restart nginx >/dev/null 2>&1 /bin/systemctl restart apache2 >/dev/null 2>&1 /bin/systemctl restart httpd >/dev/null 2>&1 else service nginx start >/dev/null 2>&1 service apache2 start >/dev/null 2>&1 service httpd start >/dev/null 2>&1 fi else $ACME_SH_BIN $ACME_SH_ISSUE_CERT_REQUEST > "$ACME_SH_ISSUE_LOG_FILE" 2>&1 RETVAL=$? fi if [ $RETVAL -eq 0 ] ; then touch "$ACME_SH_CONFIG_HOME/ok_certificate_issued" fi if [ $RETVAL -eq 2 ] ; then # There is a valid certificate already exit 0 fi exit $RETVAL