36 lines
1.3 KiB
Text
36 lines
1.3 KiB
Text
|
|
#!/bin/bash
|
||
|
|
# GENERE par Set-OPS (role serveur_nextcloud). Ne pas editer a la main.
|
||
|
|
#
|
||
|
|
# SONDE « collaboration » — installe, hors maintenance, sans migration en attente
|
||
|
|
#
|
||
|
|
# Contrat : docs/supervision-conception.md (API des greffons Nagios) — une ligne, 0/1/2.
|
||
|
|
# Mise en defaut PAR PARAMETRE : `serveur_nextcloud_sonde_url` (port ferme).
|
||
|
|
set -uo pipefail
|
||
|
|
|
||
|
|
URL={{ serveur_nextcloud_sonde_url }}
|
||
|
|
|
||
|
|
s=$(curl -sk --max-time 10 "${URL}/status.php" 2>/dev/null)
|
||
|
|
[[ -n "${s}" ]] || { echo "Nextcloud ne repond pas sur ${URL}."; exit 2; }
|
||
|
|
|
||
|
|
verdict=$(printf '%s' "${s}" | python3 -c '
|
||
|
|
import json, sys
|
||
|
|
try:
|
||
|
|
d = json.load(sys.stdin)
|
||
|
|
except Exception:
|
||
|
|
print("2|status.php illisible"); raise SystemExit
|
||
|
|
if not d.get("installed"):
|
||
|
|
print("2|instance NON INSTALLEE")
|
||
|
|
elif d.get("maintenance"):
|
||
|
|
print("2|en MODE MAINTENANCE — personne ne peut travailler")
|
||
|
|
elif d.get("needsDbUpgrade"):
|
||
|
|
print("2|migration de base EN ATTENTE — le service tourne sur un schema perime")
|
||
|
|
else:
|
||
|
|
print("0|version " + str(d.get("versionstring") or d.get("version") or "?"))
|
||
|
|
' 2>/dev/null)
|
||
|
|
|
||
|
|
code=${verdict%%|*}; texte=${verdict#*|}
|
||
|
|
[[ -n "${code}" ]] || { echo "Verdict Nextcloud illisible."; exit 2; }
|
||
|
|
[[ "${code}" == "0" ]] && { echo "Nextcloud : ${texte}, installe et disponible."; exit 0; }
|
||
|
|
echo "Nextcloud EN DEFAUT — ${texte}."
|
||
|
|
exit 2
|