forked from AndyTaylorTweet/Pi-Star_Binaries_sbin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpistar-bootconfig.sh
executable file
·61 lines (50 loc) · 1.84 KB
/
pistar-bootconfig.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
#!/bin/bash
#########################################################
# #
# Config Restore on Bootup #
# #
# Written for Pi-Star (http://www.mw0mwz.co.uk/pi-star) #
# By Andy Taylor (MW0MWZ) #
# #
# Version 1.0 #
# #
#########################################################
# Check we are root
if [ "$(id -u)" != "0" ]
then
echo "This script must be run as root" 1>&2
exit 1
fi
if [ ! -f /boot/Pi-Star_Config_*.zip ]; then
exit 1
fi
# First lets make the working directory
if [ ! -d /tmp/config_restore ]; then
mkdir /tmp/config_restore
fi
# Unpack the configs
unzip -j /boot/Pi-Star_Config_*.zip -d /tmp/config_restore/ 2>&1
# Stop the services
systemctl stop cron.service 2>&1
systemctl stop dstarrepeater.service 2>&1
systemctl stop mmdvmhost.service 2>&1
systemctl stop ircddbgateway.service 2>&1
systemctl stop timeserver.service 2>&1
systemctl stop pistar-watchdog.service 2>&1
systemctl stop ysfgateway.service 2>&1
systemctl stop p25gateway.service 2>&1
# Make the disk writable
mount -o remount,rw / 2>&1
mount -o remount,rw /boot 2>&1
# Overwrite the configs
rm -f /etc/dstar-radio.* 2>&1
mv -f /tmp/config_restore/ircddblocal.php /var/www/dashboard/config/ 2>&1
mv -f /tmp/config_restore/config.php /var/www/dashboard/config/ 2>&1
mv -f /tmp/config_restore/wpa_supplicant.conf /etc/wpa_supplicant/ 2>&1
mv -f /tmp/config_restore/* /etc/ 2>&1
#Set the Timezone
timedatectl set-timezone `grep date /var/www/dashboard/config/config.php | grep -o "'.*'" | sed "s/'//g"`
# Clean up
rm -rf /boot/Pi-Star_Config_*.zip 2>&1
reboot
exit 0