Skip to content

Commit 73ea34a

Browse files
committed
develop: ntfy-sh: fixing check-domains
1 parent 6f7b04b commit 73ea34a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

modules/nixos/ntfy-sh/check-domain.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ MAX_ATTEMPTS=3
1616

1717
# check if website is up
1818
check_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
2327
send_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

modules/nixos/ntfy-sh/default.nix

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ let
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 =
@@ -44,7 +45,7 @@ let
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
};
@@ -53,6 +54,7 @@ let
5354
inherit (lib)
5455
escapeShellArg
5556
foldl'
57+
getExe
5658
hasPrefix
5759
mkDefault
5860
mkEnableOption

0 commit comments

Comments
 (0)