world-o-techno/startup.sh

64 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2015-08-02 22:34:51 +02:00
#!/bin/bash -x
2015-08-08 10:32:03 +02:00
SCRIPT=$(readlink -f "$0")
SCRIPTPATH=$(dirname "$SCRIPT")
SCRIPTNAME="$0"
ARGS="$@"
self_update() {
# Wait for Network
sleep 10
cd $SCRIPTPATH
git fetch
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
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
2019-09-05 20:12:56 +02:00
sleep 95
# set the default audio output to be the headphone jack
amixer cset numid=3 1
# set audio volume to full
amixer sset PCM 100%
# play our tune
cat /home/${USER}/world-o-techno/world-o-techno.rb|sonic_pi
}
self_update
main
2015-08-08 10:32:03 +02:00
2019-09-02 23:08:29 +02:00