-
Notifications
You must be signed in to change notification settings - Fork 365
/
__root__stratux-pre-start.sh
executable file
·41 lines (36 loc) · 1.19 KB
/
__root__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
#!/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/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
wLog "Exited without updating anything..."