forked from AndyTaylorTweet/Pi-Star_Binaries_sbin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpistar-daily.cron
executable file
·147 lines (128 loc) · 7.9 KB
/
pistar-daily.cron
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
# Make sure we are root, if we cant stop the services, the results are a bit hit and miss.
if [ "$(id -u)" != "0" ]; then
echo -e "You need to be root to run this command...\n"
exit 1
fi
# Make the disk RW
mount -o remount,rw /
# Host Files Update
/usr/local/sbin/HostFilesUpdate.sh
# Update the Dashboard from GIT
git --work-tree=/var/www/dashboard --git-dir=/var/www/dashboard/.git pull origin master
# Stop all the services...
systemctl stop pistar-watchdog.service > /dev/null 2>&1
systemctl stop mmdvmhost.service > /dev/null 2>&1
systemctl stop dstarrepeater.service > /dev/null 2>&1
sleep 2
systemctl stop ircddbgateway.service > /dev/null 2>&1
systemctl stop dapnetgateway.service > /dev/null 2>&1
systemctl stop p25gateway.service > /dev/null 2>&1
systemctl stop p25parrot.service > /dev/null 2>&1
systemctl stop nxdngateway.service > /dev/null 2>&1
systemctl stop nxdnparrot.service > /dev/null 2>&1
systemctl stop ysfgateway.service > /dev/null 2>&1
systemctl stop ysfparrot.service > /dev/null 2>&1
systemctl stop ysf2dmr.service > /dev/null 2>&1
systemctl stop ysf2p25.service > /dev/null 2>&1
systemctl stop ysf2nxdn.service > /dev/null 2>&1
systemctl stop dmr2ysf.service > /dev/null 2>&1
systemctl stop dmr2nxdn.service > /dev/null 2>&1
systemctl stop dmrgateway.service > /dev/null 2>&1
systemctl stop timeserver.service > /dev/null 2>&1
# Update the Binaries
git --work-tree=/usr/local/bin --git-dir=/usr/local/bin/.git pull origin master
# Update the Binaries (sbin)
git --work-tree=/usr/local/sbin --git-dir=/usr/local/sbin/.git pull origin master
# Purge the logs older than 2 days
rm -f $(find /var/log/pi-star/*.log -type f -mtime +0 -print)
rm -f $(find /var/log/ -type f -mtime +0 -print | grep .gz)
# Shrink NxinX error log to stop it getting out of hand
echo "$(tail -500 /var/log/nginx/error.log)" > /var/log/nginx/error.log
# Pre-Fix some config in MMDVMHost for update purposes.
mmdvmHostVer=`MMDVMHost -v | awk '{print $3}' | cut -c 1-8`
needsUpdate=`grep -c Gwy /etc/mmdvmhost`
if [ ${mmdvmHostVer} \> 20171031 ] && [ ${needsUpdate} \> 0 ]; then
# Config needs to be updated, add in the changes here
sed -i "/GwyAddress=/c\\GatewayAddress=127.0.0.1" /etc/mmdvmhost
sed -i "/GwyPort=/c\\GatewayPort=4200" /etc/mmdvmhost
fi
# Fix up new P25Gateway Config Hostfile setup
if [[ $(/usr/local/bin/P25Gateway --version | awk '{print $3}' | cut -c -8) -gt "20180108" ]]; then
sed -i 's/Hosts=\/usr\/local\/etc\/P25Hosts.txt/HostsFile1=\/usr\/local\/etc\/P25Hosts.txt\nHostsFile2=\/usr\/local\/etc\/P25HostsLocal.txt/g' /etc/p25gateway
fi
if [ ! -f /root/P25Hosts.txt ]; then
touch /root/P25Hosts.txt
fi
# If we are ready to use the new DMRGateway
if [[ $(/usr/local/bin/DMRGateway --version | awk '{print $3}' | cut -c -8) -gt "20170924" ]] && [[ $(grep -c "\[DMR Network 3\]" /etc/dmrgateway) -eq "1" ]] && [[ ! -f /usr/local/etc/DMR_Audio/no_NO.indx ]]; then
curl --fail -o /usr/local/etc/DMR_Audio/de_DE.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/de_DE.ambe
curl --fail -o /usr/local/etc/DMR_Audio/de_DE.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/de_DE.indx
curl --fail -o /usr/local/etc/DMR_Audio/dk_DK.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/dk_DK.ambe
curl --fail -o /usr/local/etc/DMR_Audio/dk_DK.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/dk_DK.indx
curl --fail -o /usr/local/etc/DMR_Audio/en_GB.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/en_GB.ambe
curl --fail -o /usr/local/etc/DMR_Audio/en_GB.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/en_GB.indx
curl --fail -o /usr/local/etc/DMR_Audio/en_US.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/en_US.ambe
curl --fail -o /usr/local/etc/DMR_Audio/en_US.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/en_US.indx
curl --fail -o /usr/local/etc/DMR_Audio/es_ES.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/es_ES.ambe
curl --fail -o /usr/local/etc/DMR_Audio/es_ES.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/es_ES.indx
curl --fail -o /usr/local/etc/DMR_Audio/fr_FR.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/fr_FR.ambe
curl --fail -o /usr/local/etc/DMR_Audio/fr_FR.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/fr_FR.indx
curl --fail -o /usr/local/etc/DMR_Audio/it_IT.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/it_IT.ambe
curl --fail -o /usr/local/etc/DMR_Audio/it_IT.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/it_IT.indx
curl --fail -o /usr/local/etc/DMR_Audio/no_NO.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/no_NO.ambe
curl --fail -o /usr/local/etc/DMR_Audio/no_NO.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/no_NO.indx
curl --fail -o /usr/local/etc/DMR_Audio/pl_PL.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/pl_PL.ambe
curl --fail -o /usr/local/etc/DMR_Audio/pl_PL.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/pl_PL.indx
curl --fail -o /usr/local/etc/DMR_Audio/se_SE.ambe -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/se_SE.ambe
curl --fail -o /usr/local/etc/DMR_Audio/se_SE.indx -s https://raw.githubusercontent.com/g4klx/DMRGateway/master/Audio/se_SE.indx
fi
if [[ $(grep Version /etc/pistar-release | awk '{print $3}' | cut -c 1) -eq 4 ]]; then
if [[ $(cat /etc/ircddbgateway | grep -o "xlx" | wc -l) -eq 0 ]]; then
echo "xlxEnabled=0" >> /etc/ircddbgateway
echo "xlxOverrideLocal=0" >> /etc/ircddbgateway
echo "xlxHostsFileUrl=" >> /etc/ircddbgateway
fi
if [[ $(cat /etc/ircddbgateway | grep -o "aprsPassword" | wc -l) -eq 0 ]]; then
echo "aprsPassword=00000" >> /etc/ircddbgateway
fi
if [[ $(cat /etc/ircddbgateway | grep -o "mobileGPS" | wc -l) -eq 0 ]]; then
echo "mobileGPSEnabled=0" >> /etc/ircddbgateway
echo "mobileGPSAddress=127.0.0.1" >> /etc/ircddbgateway
echo "mobileGPSPort=7834" >> /etc/ircddbgateway
fi
if [[ $(cat /etc/dstarrepeater | grep -o "mmdvmRXInvert" | wc -l) -eq 0 ]]; then
echo "mmdvmRXInvert=0" >> /etc/dstarrepeater
echo "mmdvmTXInvert=0" >> /etc/dstarrepeater
echo "mmdvmPTTInvert=0" >> /etc/dstarrepeater
echo "mmdvmTXDelay=50" >> /etc/dstarrepeater
echo "mmdvmRXLevel=100" >> /etc/dstarrepeater
echo "mmdvmTXLevel=100" >> /etc/dstarrepeater
fi
fi
# Start all the services...
systemctl start ircddbgateway.service > /dev/null 2>&1
systemctl start dmrgateway.service > /dev/null 2>&1
systemctl start dapnetgateway.service > /dev/null 2>&1
systemctl start p25gateway.service > /dev/null 2>&1
systemctl start p25parrot.service > /dev/null 2>&1
systemctl start nxdngateway.service > /dev/null 2>&1
systemctl start nxdnparrot.service > /dev/null 2>&1
systemctl start ysfgateway.service > /dev/null 2>&1
systemctl start ysfparrot.service > /dev/null 2>&1
systemctl start ysf2dmr.service > /dev/null 2>&1
systemctl start ysf2p25.service > /dev/null 2>&1
systemctl start ysf2nxdn.service > /dev/null 2>&1
systemctl start dmr2ysf.service > /dev/null 2>&1
systemctl start dmr2nxdn.service > /dev/null 2>&1
systemctl start timeserver.service > /dev/null 2>&1
systemctl start mmdvmhost.service > /dev/null 2>&1
systemctl start dstarrepeater.service > /dev/null 2>&1
systemctl start pistar-watchdog.service > /dev/null 2>&1
# Fix nginx unit file
if ! [ $(cat /lib/systemd/system/nginx.service | grep -o "mkdir") ]; then
sed -i '\/PIDFile=\/run\/nginx.pid/a ExecStartPre=\/bin\/mkdir -p \/var\/log\/nginx' /lib/systemd/system/nginx.service
systemctl daemon-reload
systemctl restart nginx.service
fi
exit 0