aboutsummaryrefslogtreecommitdiff
path: root/systems/monitoring-1/monitoring/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'systems/monitoring-1/monitoring/run.sh')
-rw-r--r--systems/monitoring-1/monitoring/run.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/systems/monitoring-1/monitoring/run.sh b/systems/monitoring-1/monitoring/run.sh
new file mode 100644
index 0000000..9a57990
--- /dev/null
+++ b/systems/monitoring-1/monitoring/run.sh
@@ -0,0 +1,47 @@
1#!/bin/bash
2
3function graceful_exit(){
4 # Note, "service naemon stop" does not work in the phusion image
5 # We just kill the process rather than chase this down.
6 pkill naemon
7 exit $1
8}
9
10# Recup fichiers Ismael
11if [ -n "$NAMESPACE" ]; then
12 echo "Namespace: $NAMESPACE"
13else
14 echo "Le namespace n'a pas été défini dans \$NAMESPACE."
15 exit 1
16fi
17
18curl -o /etc/naemon/conf.d/objects.cfg "https://status.immae.eu/$NAMESPACE/objects.conf"
19curl -o /etc/naemon/module-conf.d/immae.cfg "https://status.immae.eu/common/immae.cfg"
20curl -o /etc/naemon/resource.cfg "https://status.immae.eu/common/resource.cfg"
21
22curl "https://status.immae.eu/$NAMESPACE/plugins.tar" | tar -C /etc/naemon -x
23
24sed -i -e "s|@@COMMON_PLUGINS@@|/usr/lib/naemon/plugins|" \
25 -e "s|@@IMMAE_PLUGINS@@|/etc/naemon/immae_plugins/|" \
26 -e "s|@@TOKEN@@|$NOTIFY_REMOTE_TOKEN|" \
27 /etc/naemon/resource.cfg
28
29# Ensure consistent ownership for the data volume, even if the
30# UID/GID's changes
31chown -R naemon:naemon /etc/naemon /data/var/log/naemon
32
33# Start the services
34service naemon start
35
36# Trap exit signals and do a proper shutdown
37trap "graceful_exit 0;" SIGINT SIGTERM
38
39sleep 5
40while true
41do
42 if ! [ -d "/proc/$(cat /var/run/naemon/naemon.pid)" ]; then
43 echo "Naemon no longer running"
44 graceful_exit 1
45 fi
46 sleep 1
47done