forked from NEMSLinux/legacy-nems-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservices.sh
More file actions
executable file
·69 lines (50 loc) · 1.71 KB
/
services.sh
File metadata and controls
executable file
·69 lines (50 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Enable or disable services on boot based on nems.conf
conf='/usr/local/share/nems/nems.conf'
platform=$(/usr/local/bin/nems-info platform)
ver=$(/usr/local/bin/nems-info nemsver)
# Set defaults if nothing is set
# Pi Zero / 1
if (( $platform < '2' )); then
if ! grep -q "service.rpi-monitor" "$conf"; then
echo "service.rpi-monitor=0" >> "$conf"
fi
if ! grep -q "service.nagios-api" "$conf"; then
echo "service.nagios-api=0" >> "$conf"
fi
if ! grep -q "service.monitorix" "$conf"; then
echo "service.monitorix=0" >> "$conf"
fi
fi
# All Platforms
socket=$(/usr/local/bin/nems-info socket)
# nagios-api
if grep -q "service.nagios-api=0" "$conf"; then
sleep 1
else
sleep 15 # Need to wait a bit so Nagios has time to load first
if (( $(awk 'BEGIN {print ("'$ver'" >= "'1.4'")}') )); then
/root/nems/nagios-api/nagios-api -p 8090 -c $socket -s /var/cache/nagios/status.dat -l /var/log/nagios/nagios.log >> /var/log/nagios-api.log 2>&1 &
else
/root/nems/nagios-api/nagios-api -p 8090 -c /var/lib/nagios3/rw/live.sock -s /var/cache/nagios3/status.dat -l /var/log/nagios3/nagios.log >> /var/log/nagios-api.log 2>&1 &
fi
fi
# monitorix
if grep -q "service.monitorix=0" "$conf"; then
/bin/systemctl stop monitorix
/bin/systemctl disable monitorix
else
/bin/systemctl enable monitorix
/bin/systemctl start monitorix
fi
# Raspberry Pi Only
if (( $platform < '10' )); then
# RPi-Monitor
if grep -q "service.rpi-monitor=0" "$conf"; then
sleep 30
/etc/init.d/rpimonitor stop
/bin/systemctl stop rpimonitor
else
/etc/init.d/rpimonitor start
fi
fi