File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,20 @@ MAX_ATTEMPTS=3
1616
1717# check if website is up
1818check_website () {
19- curl -s -w " %{http_code} %{url_effective}\n" -I " $FQDN " > /dev/null && return 0 || return 1
19+ if curl -s -w " %{http_code} %{url_effective}\n" -I " $FQDN " > /dev/null; then
20+ return 0
21+ else
22+ return 1
23+ fi
2024}
2125
2226# send notification via ntfy
2327send_notification () {
24- curl -s -d " $1 " http://127.0.0.1:2586/" $NTFY_TOPIC " && return 0 || return 1
28+ if curl -s -d " $1 " http://127.0.0.1:2586/" $NTFY_TOPIC " ; then
29+ return 0
30+ else
31+ return 1
32+ fi
2533}
2634
2735# perform checks
Original file line number Diff line number Diff line change 2323
2424 fqdn = stripProtocol cfg . settings . base-url ;
2525
26- check-domain = pkgs . writeShellApplication {
26+ check-domain = pkgs . writeShellApplication rec {
2727 name = "check-domain" ;
2828 runtimeInputs = [ pkgs . curl ] ;
29- text = readFile ./check-domain.sh ;
29+ text = readFile ./${ name } .sh ;
30+ meta . mainProgram = name ;
3031 } ;
3132
3233 mkMonitorDomainService =
4445 Type = "oneshot" ;
4546 User = "nobody" ;
4647 Group = "nogroup" ;
47- ExecStart = "${ pkgs . bash } /bin/bash ${ check-domain } /bin/check-domain ${ escapedDomain } ${ escapedTopic } " ;
48+ ExecStart = "${ getExe check-domain } ${ escapedDomain } ${ escapedTopic } " ;
4849 Restart = "on-failure" ;
4950 RestartSec = "300s" ;
5051 } ;
5354 inherit ( lib )
5455 escapeShellArg
5556 foldl'
57+ getExe
5658 hasPrefix
5759 mkDefault
5860 mkEnableOption
You can’t perform that action at this time.
0 commit comments