-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.sh
126 lines (90 loc) · 3.86 KB
/
script.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/bash
# Created by: Isaaker
# Font Code: https://github.com/Isaaker/isaaker-shell-scripts/new/main/dump1090_status
# License: https://github.com/Isaaker/isaaker-shell-scripts/blob/main/LICENSE.txt
# RUN AS SUDO
# Check services running
# Check Dump1090
if [ "$(systemctl is-active dump1090-fa.service)" != "active" ]; then
#Wall
wall "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 stopped running, restarting services. Checked by: Method 1 - Systemctl"
#Log
sudo echo "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 stopped running. Checked by: Method 1 - Systemctl" >> /var/log/dump1090_restart_log.txt
#Restarting Services
systemctl restart dump1090-fa.service
systemctl restart rbfeeder.service
systemctl restart fr24feed.service
systemctl restart piaware.service
systemctl restart adsbexchange-feed.service
exit 1
fi
# Check Radarbox Feeder
if [ "$(systemctl is-active rbfeeder.service)" != "active" ]; then
#Wall
wall "[$(date +"%d-%m-%Y %H:%M:%S")] Radarbox Feeder stopped running, restarting service. Checked by: Method 1 - Systemctl"
#Log
sudo echo "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 stopped running. Checked by: Method 1 - Systemctl" >> /var/log/dump1090_restart_log.txt
#Restarting Services
systemctl restart rbfeeder.service
fi
# Check FlightRadar24 Feeder
if [ "$(systemctl is-active fr24feed.service)" != "active" ]; then
#Wall
wall "[$(date +"%d-%m-%Y %H:%M:%S")] FlightRadar24 Feeder stopped running, restarting service. Checked by: Method 1 - Systemctl"
#Log
sudo echo "[$(date +"%d-%m-%Y %H:%M:%S")] FlightRadar24 stopped running. Checked by: Method 1 - Systemctl" >> /var/log/dump1090_restart_log.txt
#Restarting Services
systemctl restart fr24feed.service
fi
# Check Piaware Feeder
if [ "$(systemctl is-active piaware.service)" != "active" ]; then
#Wall
wall "[$(date +"%d-%m-%Y %H:%M:%S")] PiAware Feeder stopped running, restarting service. Checked by: Method 1 - Systemctl"
#Log
sudo echo "[$(date +"%d-%m-%Y %H:%M:%S")] PiAware stopped running. Checked by: Method 1 - Systemctl" >> /var/log/dump1090_restart_log.txt
#Restarting Services
systemctl restart piaware.service
fi
# Check ADS-B Exchange Feeder
if [ "$(systemctl is-active adsbexchange-feed.service)" != "active" ]; then
#Wall
wall "[$(date +"%d-%m-%Y %H:%M:%S")] ADS-B Exchange Feeder stopped running, restarting service. Checked by: Method 1 - Systemctl"
#Log
sudo echo "[$(date +"%d-%m-%Y %H:%M:%S")] ADS-B Exchange stopped running. Checked by: Method 1 - Systemctl" >> /var/log/dump1090_restart_log.txt
#Restarting Services
systemctl restart adsbexchange-feed.service
fi
# Check aircraft file exist
if [ ! -f /run/dump1090-fa/aircraft.json ]; then
#Wall
wall "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 stopped running, restarting services. Checked by: Method 2 - /run/dump1090-fa/aircraft.json file didn't exist"
#Log
sudo echo "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 stopped running. Checked by: Method 2 - /run/dump1090-fa/aircraft.json file didn't exist" >> /var/log/dump1090_restart_log.txt
#Restarting Services
systemctl restart dump1090-fa.service
systemctl restart rbfeeder.service
systemctl restart fr24feed.service
systemctl restart piaware.service
systemctl restart adsbexchange-feed.service
exit 1
fi
# Check .aircraft contains current tracked aircrafts
if jq '.aircraft | length > 0' /run/dump1090-fa/aircraft.json; then
#Wall
wall "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 still running"
#Log
sudo echo "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 still running" >> /var/log/dump1090_restart_log.txt
exit 0
else
#Wall
wall "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 stopped running, restarting services"
#Log
sudo echo "[$(date +"%d-%m-%Y %H:%M:%S")] Dump1090 stopped running" >> /var/log/dump1090_restart_log.txt
#Restarting Services
systemctl restart dump1090-fa.service
systemctl restart rbfeeder.service
systemctl restart fr24feed.service
systemctl restart piaware.service
systemctl restart adsbexchange-feed.service
exit 1
fi