forked from mholgatem/GPIOnext
-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.sh
40 lines (35 loc) · 994 Bytes
/
update.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
#!/bin/bash
VERSION="1.0"
#get script path
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH
#if not root user, restart script as root
if [ "$(whoami)" != "root" ]; then
echo "Switching to root user..."
sudo bash $SCRIPT $*
exit 1
fi
shopt -s nocasematch
if ! [[ "$1" == "-noupdate" ]]; then
echo "Performing self-update..."
git config --global user.email "[email protected]"
git config --global user.name "[email protected]"
git checkout master
git stash
git pull
git stash pop
git config --global --unset user.email
git config --global --unset user.name
exec /bin/bash update.sh -noupdate
fi
shopt -u nocasematch
# create bash custom commands
cp $SCRIPTPATH"/usr-bin-gpionext" /usr/bin/gpionext
config="CONFIG_PATH=${SCRIPTPATH}/config_manager.py"
sed -i '1s#^#'$config'\n#g' /usr/bin/gpionext
chmod 777 /usr/bin/gpionext
sudo systemctl stop gpionext
sudo systemctl daemon-reload
sudo systemctl start gpionext
echo 'update complete'