self-update skript hinzugefügt. ToDo: Test, ob Internet verfügbar!
This commit is contained in:
parent
07aa5a76e0
commit
83fa9900f9
1 changed files with 56 additions and 8 deletions
50
startup.sh
50
startup.sh
|
@ -1,7 +1,49 @@
|
|||
#!/bin/bash -x
|
||||
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
SCRIPTNAME="$0"
|
||||
ARGS="$@"
|
||||
|
||||
UPSTREAM=${1:-'@{u}'}
|
||||
LOCAL=$(git rev-parse @) #Hash of the current local commit (@ is a git shorthand)
|
||||
REMOTE=$(git rev-parse "$UPSTREAM") #Hash of the current upstream commit
|
||||
BASE=$(git merge-base @ "$UPSTREAM") #Hash of the commit at which the current branch and its upstream diverge
|
||||
|
||||
|
||||
self_update() {
|
||||
# Wait for Network
|
||||
sleep 10
|
||||
|
||||
cd $SCRIPTPATH
|
||||
git fetch
|
||||
|
||||
if [ $LOCAL = $REMOTE ]; then
|
||||
echo "Repo is Up-to-date"
|
||||
|
||||
elif [ $LOCAL = $BASE ]; then
|
||||
echo "Repo is not Up-to-date. Pulling!"
|
||||
git pull --force
|
||||
|
||||
echo "Executeing the new version..."
|
||||
exec "$SCRIPTNAME" "$@"
|
||||
|
||||
# Now exit this old instance
|
||||
exit 0
|
||||
|
||||
else
|
||||
echo "Diverged"
|
||||
fi
|
||||
|
||||
echo "Already the latest version. Now running the script. "
|
||||
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
# wait for sonic-pi to start
|
||||
sleep 90
|
||||
sleep 70
|
||||
|
||||
# set the default audio output to be the headphone jack
|
||||
amixer cset numid=3 1
|
||||
|
@ -11,3 +53,9 @@ amixer sset PCM 100%
|
|||
|
||||
# play our tune
|
||||
cat /home/pi/world-o-techno/world-o-techno.rb|sonic_pi
|
||||
}
|
||||
|
||||
self_update
|
||||
main
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue