forked from cyoung/stratux
-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
__opt__stratux__bin__stratux-pre-start.sh
executable file
·69 lines (59 loc) · 2.02 KB
/
__opt__stratux__bin__stratux-pre-start.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
#!/bin/bash
#echo powersave >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
#Logging Function
SCRIPT=`basename ${BASH_SOURCE[0]}`
STX_LOG="/var/log/stratux.log"
function wLog () {
echo "$(date +"%Y/%m/%d %H:%M:%S") - $SCRIPT - $1" >> ${STX_LOG}
}
wLog "Running Stratux Updater Script."
SCRIPT_MASK="update*stratux*v*.sh"
TEMP_LOCATION="/boot/firmware/StratuxUpdates/$SCRIPT_MASK"
UPDATE_LOCATION="/root/$SCRIPT_MASK"
if [ -e ${TEMP_LOCATION} ]; then
wLog "Found Update Script in $TEMP_LOCATION$SCRIPT_MASK"
TEMP_SCRIPT=`ls -1t ${TEMP_LOCATION} | head -1`
wLog "Moving Script $TEMP_SCRIPT"
cp -r ${TEMP_SCRIPT} /root/
wLog "Changing permissions to chmod a+x $UPDATE_LOCATION"
chmod a+x ${UPDATE_LOCATION}
wLog "Removing Update file from $TEMP_LOCATION"
rm -rf ${TEMP_SCRIPT}
fi
# Check if we need to run an update.
if [ -e ${UPDATE_LOCATION} ]; then
UPDATE_SCRIPT=`ls -1t ${UPDATE_LOCATION} | head -1`
if [ -n ${UPDATE_SCRIPT} ] ; then
# Execute the script, remove it, then reboot.
wLog "Running update script ${UPDATE_SCRIPT}..."
bash ${UPDATE_SCRIPT}
wLog "Removing Update SH"
rm -f ${UPDATE_SCRIPT}
wLog "Finished... Rebooting... Bye"
reboot
fi
fi
if [ -f /boot/firmware/.stratux-first-boot ]; then
rm /boot/firmware/.stratux-first-boot
if [ -f /boot/firmware/stratux.conf ]; then
# In case of US build, a stratux.conf file will always be imported, only containing UAT/OGN options.
# We don't want to force-reboot for that.. Only for network/overlay changes
do_reboot=false
# re-apply overlay
if [ "$(jq -r .PersistentLogging /boot/firmware/stratux.conf)" = "true" ]; then
/sbin/overlayctl disable
do_reboot=true
wLog "overlayctl disabled due to stratux.conf settings"
fi
# write network config
if grep -q WiFi /boot/firmware/stratux.conf ; then
/opt/stratux/bin/gen_gdl90 -write-network-config
do_reboot=true
wLog "re-wrote network configuration for first-boot config import. Rebooting... Bye"
fi
if $do_reboot; then
reboot
fi
fi
fi
wLog "Exited without updating anything..."