Compare commits
3 Commits
6a5863ee52
...
be40aca44b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be40aca44b | ||
|
|
8228bd1f72 | ||
|
|
63af2c4f4e |
@@ -46,11 +46,12 @@
|
||||
|
||||
./system-modules/simple-postgres.nix
|
||||
] ++ (if hyper.isServer then [
|
||||
./system-modules/stay-up.nix
|
||||
|
||||
./system-modules/nx2site.nix
|
||||
./system-modules/hugo.nix
|
||||
./system-modules/postgres.nix
|
||||
./system-modules/nx2site/proxy.nix
|
||||
|
||||
# ./system-modules/nx2site/smtp.nix
|
||||
# ./system-modules/nx2site/imap.nix
|
||||
# ./system-modules/nx2site/vmail.nix
|
||||
|
||||
@@ -57,6 +57,7 @@ in {
|
||||
"mail_smtpauth" = true;
|
||||
"mail_smtpauthtype" = "LOGIN";
|
||||
"mail_smtpname" = "nextcloud@${hyper.domain}";
|
||||
"simpleSignUpLink.shown" = false;
|
||||
};
|
||||
secrets."mail_smtppassword" = config.sops.secrets."nx2site/smtp2go/nextcloud_api_key".path;
|
||||
# secrets.settings."mail_smtppassword" = config.sops.secrets."nx2site/maddy/nextcloud_password".path;
|
||||
|
||||
36
system-modules/stay-up.nix
Normal file
36
system-modules/stay-up.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{ config, pkgs, ... }@all: with all; let
|
||||
target = "1.1.1.1";
|
||||
timeoutMinutes = 5;
|
||||
logFile = "/var/log/stay-up.log";
|
||||
in {
|
||||
systemd.services.wifi-watchdog = {
|
||||
description = "Wi-Fi Watchdog Service";
|
||||
after = [ "network.target" "NetworkManager.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = with pkgs; [ iputils networkmanager coreutils ];
|
||||
script = /* bash */ ''
|
||||
FAIL_COUNT=0
|
||||
touch "${logFile}"
|
||||
while true; do
|
||||
if ping -c 1 -W 5 "${target}" > /dev/null 2>&1; then
|
||||
FAIL_COUNT=0
|
||||
else
|
||||
FAIL_COUNT=$((FAIL_COUNT + 1))
|
||||
if [ "$FAIL_COUNT" -ge "${toString timeoutMinutes}" ]; then
|
||||
echo "$(date -Iseconds): Network unreachable for ${toString timeoutMinutes} minutes. Restarting Wi-Fi." >> "${logFile}"
|
||||
nmcli radio wifi off
|
||||
sleep 5
|
||||
nmcli radio wifi on
|
||||
FAIL_COUNT=0
|
||||
fi
|
||||
fi
|
||||
sleep 60
|
||||
done
|
||||
'';
|
||||
serviceConfig = {
|
||||
Restart = "always";
|
||||
RestartSec = "10";
|
||||
User = "root"; # Root is required to execute nmcli radio commands and write to /var/log/
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user