Skip to content

Commit

Permalink
[Let's Encrypt] Add extended logging of cron task execution #297 (#298)
Browse files Browse the repository at this point in the history
* [Let's Encrypt] Add extended logging of cron task execution #297

* [Let's Encrypt] Add extended logging of cron task execution #297

* [Let's Encrypt] Add extended logging of cron task execution #297

* [Let's Encrypt] Add extended logging of cron task execution #297

* [Let's Encrypt] Add extended logging of cron task execution

Co-authored-by: Slava Katiukha <v.katiukha@gmail.com>

* [Let's Encrypt] Add extended logging of cron task execution

* [Let's Encrypt] Add extended logging of cron task execution

---------

Co-authored-by: Slava Katiukha <v.katiukha@gmail.com>
  • Loading branch information
lazarenkoalexey and SlavaKatiukha authored Jun 14, 2024
1 parent 0260452 commit d9a26ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions scripts/auto-update-ssl-cert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function validateLatestVersion(){
function updateScripts(){
for sh_script_name in auto-update-ssl-cert install-le validation generate-ssl-cert; do
for i in {1..5}; do
$WGET --timeout=5 --waitretry=0 --tries=1 --no-check-certificate $RAW_REPO_SCRIPS_URL/${sh_script_name}.sh -O /tmp/${sh_script_name}.sh
$WGET -nv --timeout=5 --waitretry=0 --tries=1 --no-check-certificate $RAW_REPO_SCRIPS_URL/${sh_script_name}.sh -O /tmp/${sh_script_name}.sh
if (( $? == 0 )); then
break
else
Expand Down Expand Up @@ -68,16 +68,17 @@ seconds_before_expire=$(( $DAYS_BEFORE_EXPIRE * 24 * 60 * 60 ));
$( [[ -e /usr/bin/python ]] || ln -s /usr/bin/python3 /usr/bin/python )
[[ -f "/var/lib/jelastic/SSL/jelastic.crt" && "$withExtIp" != "false" ]] && exp_date=$(jem ssl checkdomain | python -c "import sys, json; print (json.load(sys.stdin)['expiredate'])");

[ -z "$exp_date" ] && { echo "$(date) - no certificates for update" >> /var/log/letsencrypt.log; exit 0; };
[ -z "$exp_date" ] && { echo "$(date) - no certificates for update"; exit 0; };

_exp_date_unixtime=$(date --date="$exp_date" "+%s");
_cur_date_unixtime=$(date "+%s");
_delta_time=$(( $_exp_date_unixtime - $_cur_date_unixtime ));

[[ $_delta_time -le $seconds_before_expire ]] && {
echo "$(date) - update required" >> /var/log/letsencrypt.log;
echo "$(date) - update required";
validateLatestVersion
resp=$($WGET --no-check-certificate -qO- "${auto_update_url}");
echo ${resp};
[[ $? -ne 0 ]] && [[ -z $resp ]] && resp="Temporary network Issue";
{ echo "${resp#*response*}" | sed 's/"//g' | grep -q 'result:0' ;} || $WGET -qO- "${jerror_url}/jerror?appid=$appid&actionname=updatefromcontainer&callparameters=$auto_update_url&email=$email&errorcode=4121&errormessage=$resp&priority=high"
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-le.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ echo "Installing required packages"
microdnf -y install epel-release; microdnf install -y git bc nss socat tinyproxy --enablerepo='epel';
else

yum-config-manager --save --setopt=\*.retries=5 --setopt=\*.skip_if_unavailable=true --setopt=\*.timeout=5
yum-config-manager --save --setopt=\*.retries=5 --setopt=\*.skip_if_unavailable=true --setopt=\*.timeout=5 >/dev/null
yum -y install epel-release git bc nss;
yum -y install tinyproxy socat --enablerepo='epel';
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/ssl-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ function SSLManager(config) {
"chmod +x %(scriptPath)",
"crontab -l | grep -v '/root/.acme.sh' | crontab -",
"crontab -l | grep -v '%(scriptPath)' | crontab -",
"echo \"%(cronTime) su - root -c \\\"%(scriptPath) '%(autoUpdateUrl)' >> %(log)\\\"\" >> /var/spool/cron/root"
"echo \"%(cronTime) su - root -c \\\"%(scriptPath) '%(autoUpdateUrl)' >> %(log) 2>&1\\\"\" >> /var/spool/cron/root"
], {
url : scriptUrl,
cronTime : crontime ? crontime : config.cronTime,
Expand Down

0 comments on commit d9a26ed

Please sign in to comment.