forked from magcode/mpower-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-bootstate.sh
42 lines (35 loc) · 1.15 KB
/
install-bootstate.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
#!/bin/sh
#
echo "Installing bootstate ..."
scriptdir=/var/etc/persistent/bootstate
mkdir -p $scriptdir
config="$scriptdir/bootstate.cfg"
applyscript="$scriptdir/apply-bootstate.sh"
poststartscript="sleep 60; $applyscript"
poststart=/etc/persistent/rc.poststart
wget --no-check-certificate -q https://raw.githubusercontent.com/magcode/mpower-tools/master/bootstate/apply-bootstate.sh -O $applyscript
chmod 775 $applyscript
if [ ! -f $config ]; then
echo "$config not found, creating it ..."
export PORTS=`cat /etc/board.inc | grep feature_power | sed -e 's/.*\([0-9]\+\);/\1/'`
touch $config
for i in $(seq $PORTS)
do
echo "vpower.$i.relay=on" >> $config
done
fi
if [ ! -f $poststart ]; then
echo "$poststart not found, creating it ..."
touch $poststart
echo "#!/bin/sh" >> $poststart
chmod 755 $poststart
fi
if grep -q "$poststartscript" "$poststart"; then
echo "Found $poststart entry. File will not be changed"
else
echo "Adding start command to $poststart"
echo -e "$poststartscript" >> $poststart
fi
echo "Done!"
cfgmtd -w -p /etc/
echo "Adapt your settings in '$config' and call '$applyscript' afterwards."