From ee59f0258b5fca37ab10361a139b022730cf8e43 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Mon, 28 Nov 2022 19:27:37 +0100 Subject: [PATCH] Improve healthcheck --- caddy/config/Caddyfile | 5 ----- healthcheck/.gitignore | 2 -- healthcheck/{ => data}/http | 4 ++-- healthcheck/data/mail | 9 +++++++++ healthcheck/{ => data}/mailcheck.template.mail | 0 healthcheck/{ => data}/matrix | 0 healthcheck/{ => data}/template.msmtprc | 0 healthcheck/docker-compose.yml | 2 +- healthcheck/healthcheck@.service | 4 ++++ healthcheck/healthcheck@.timer | 4 ++++ healthcheck/mail | 9 --------- 11 files changed, 20 insertions(+), 19 deletions(-) delete mode 100644 healthcheck/.gitignore rename healthcheck/{ => data}/http (90%) create mode 100755 healthcheck/data/mail rename healthcheck/{ => data}/mailcheck.template.mail (100%) rename healthcheck/{ => data}/matrix (100%) rename healthcheck/{ => data}/template.msmtprc (100%) create mode 100644 healthcheck/healthcheck@.service create mode 100644 healthcheck/healthcheck@.timer delete mode 100755 healthcheck/mail diff --git a/caddy/config/Caddyfile b/caddy/config/Caddyfile index 7ee03fe..1388427 100644 --- a/caddy/config/Caddyfile +++ b/caddy/config/Caddyfile @@ -2,11 +2,6 @@ email tobias@msrg.cc } -db.serguzim.me:80, -dns.serguzim.me:80 { - reverse_proxy host.docker.internal:4444 -} - import /etc/caddy/snippets import /etc/caddy/conf.d/*.conf import /etc/caddy/conf-hidden.d/*.conf diff --git a/healthcheck/.gitignore b/healthcheck/.gitignore deleted file mode 100644 index 07ee4a4..0000000 --- a/healthcheck/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/mailcheck.mail -/msmtprc diff --git a/healthcheck/http b/healthcheck/data/http similarity index 90% rename from healthcheck/http rename to healthcheck/data/http index 1385b93..4bda77b 100755 --- a/healthcheck/http +++ b/healthcheck/data/http @@ -41,7 +41,7 @@ check_url "www.reitanlage-oranienburg.de" if [ "$error" = "" ] then - curl_hc "$hc_url" >/dev/null 2>&1 + curl_hc "$hc_url" else - curl_hc --data-raw "$error" "$hc_url/fail" >/dev/null 2>&1 + curl_hc --data-raw "$error" "$hc_url/fail" fi diff --git a/healthcheck/data/mail b/healthcheck/data/mail new file mode 100755 index 0000000..cd38926 --- /dev/null +++ b/healthcheck/data/mail @@ -0,0 +1,9 @@ +#!/usr/bin/sh + +set -e +cd /opt/ || exit + +envsubst < template.msmtprc > /tmp/msmtprc +envsubst < mailcheck.template.mail > /tmp/mailcheck.mail + +msmtp -C /tmp/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /tmp/mailcheck.mail diff --git a/healthcheck/mailcheck.template.mail b/healthcheck/data/mailcheck.template.mail similarity index 100% rename from healthcheck/mailcheck.template.mail rename to healthcheck/data/mailcheck.template.mail diff --git a/healthcheck/matrix b/healthcheck/data/matrix similarity index 100% rename from healthcheck/matrix rename to healthcheck/data/matrix diff --git a/healthcheck/template.msmtprc b/healthcheck/data/template.msmtprc similarity index 100% rename from healthcheck/template.msmtprc rename to healthcheck/data/template.msmtprc diff --git a/healthcheck/docker-compose.yml b/healthcheck/docker-compose.yml index e410601..5ef0298 100644 --- a/healthcheck/docker-compose.yml +++ b/healthcheck/docker-compose.yml @@ -10,7 +10,7 @@ x-common-elements: - .env - .secret.env volumes: - - ./:/opt + - ./data/:/opt services: http: diff --git a/healthcheck/healthcheck@.service b/healthcheck/healthcheck@.service new file mode 100644 index 0000000..2c332b9 --- /dev/null +++ b/healthcheck/healthcheck@.service @@ -0,0 +1,4 @@ +[Service] +Type=oneshot +ExecStart=/usr/bin/docker compose run --rm %i +WorkingDirectory=/opt/services/healthcheck/ diff --git a/healthcheck/healthcheck@.timer b/healthcheck/healthcheck@.timer new file mode 100644 index 0000000..1ecfb64 --- /dev/null +++ b/healthcheck/healthcheck@.timer @@ -0,0 +1,4 @@ +[Timer] +OnCalendar=*:0/5 +[Install] +WantedBy=timers.target diff --git a/healthcheck/mail b/healthcheck/mail deleted file mode 100755 index 576b505..0000000 --- a/healthcheck/mail +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/sh - -set -e -cd /opt/ || exit - -envsubst < template.msmtprc > msmtprc -envsubst < mailcheck.template.mail > mailcheck.mail - -msmtp -C /opt/msmtprc -a default "$MAIL_HC_UID@hc-ping.com" < /opt/mailcheck.mail