mirror of https://gitlab.crans.org/nounous/nixos
add shell option and no dynamics user can controle update easy gatus annoucement
parent
585ab398f8
commit
41c9fbf57b
|
|
@ -35,8 +35,51 @@ let
|
|||
) allHosts;
|
||||
|
||||
|
||||
gatus-announce = pkgs.writeShellScriptBin "gatus-announce" ''
|
||||
set -euo pipefail
|
||||
|
||||
FILE="/var/lib/gatus/config/99-announcements.yaml"
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Usage:"
|
||||
echo " sudo gatus-announce <type> \"<message>\" (types: outage, warning, information, operational)"
|
||||
echo " sudo gatus-announce clear (archive l'annonce en cours)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "clear" ]; then
|
||||
if [ -f "$FILE" ]; then
|
||||
sed -i 's/archived: false/archived: true/g' "$FILE"
|
||||
echo "Annonce archivée."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TYPE="$1"
|
||||
MESSAGE="''${2:-}"
|
||||
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
if [ -z "$MESSAGE" ]; then
|
||||
echo "Erreur : le message est vide."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOF > "$FILE"
|
||||
announcements:
|
||||
- timestamp: "$TIMESTAMP"
|
||||
type: $TYPE
|
||||
message: "$MESSAGE"
|
||||
archived: false
|
||||
EOF
|
||||
|
||||
chmod 644 "$FILE"
|
||||
echo "Annonce publiée ($TYPE) : $MESSAGE"
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
{
|
||||
environment.systemPackages = [ gatus-announce ];
|
||||
|
||||
services.openssh.settings.AcceptEnv = [ "GIT_PROTOCOL" ];
|
||||
|
||||
services.forgejo = {
|
||||
|
|
@ -58,6 +101,7 @@ in
|
|||
services.gatus = {
|
||||
enable = true;
|
||||
openFirewall = false;
|
||||
skip-invalid-config-update = true;
|
||||
settings = {
|
||||
web.port = 8080;
|
||||
ui.title = "Page Status Crans";
|
||||
|
|
@ -73,6 +117,15 @@ in
|
|||
endpoints = endpointsFromInfos;
|
||||
|
||||
};
|
||||
};
|
||||
users.users.gatus = {
|
||||
isSystemUser = true;
|
||||
group = "gatus";
|
||||
};
|
||||
users.groups.gatus = {};
|
||||
|
||||
systemd.services.gatus.serviceConfig = {
|
||||
|
||||
};
|
||||
# Override the systemd service to watch a directory instead of the single /nix/store file
|
||||
systemd.services.gatus = {
|
||||
|
|
@ -92,6 +145,9 @@ in
|
|||
message: "Investigating elevated latency on EU servers."
|
||||
archived: false" >> /var/lib/gatus/config/99-announcements.yaml
|
||||
'';
|
||||
DynamicUser = lib.mkForce false;
|
||||
User = "gatus";
|
||||
Group = "gatus";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue