-
Notifications
You must be signed in to change notification settings - Fork 21
/
system-update.sh
executable file
·61 lines (54 loc) · 2.03 KB
/
system-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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/bash
# system-update.sh
#
# This is a place where we can put system update scripting.
# E.g. modify system files.
# It gets run from git-pull-reboot.sh, AFTER git pull and BEFORE reboot.
#
# One input argument: stationID as a string
# If an update is only to be run once,
# it should check that it has not been run yet!
# Make sure you check exit codes for whether the update actually worked.
# if [ $? -eq 0]; then echo "successful"; else echo "failed"; fi
LOGTAG=dosenet
case $1 in
"9999")
#--------------------------------------------------------------------------
# BEGIN station update:
#--------------------------------------------------------------------------
echo "This is station #9999"
# commands for this station go here
;;
*)
echo "This is station #$1"
# commands for all stations to run
;;
esac
#--------------------------------------------------------------------------
# BEGIN system update: git config user.email, user.name to enable git stash
#--------------------------------------------------------------------------
DOSENETPATH=/home/pi/dosenet-raspberrypi
cd $DOSENETPATH
GIT_EMAIL="[email protected]"
GIT_NAME="Anonymous Pi"
CUR_GIT_EMAIL=$(git config --get user.email)
CUR_GIT_NAME=$(git config --get user.name)
if [ ! "$CUR_GIT_EMAIL" = "$GIT_EMAIL" ]; then
git config user.email "$GIT_EMAIL"
if [ $? -eq 0 ]; then
logger --stderr --id --tag $LOGTAG "Successfully updated git user.email"
else
logger --stderr --id --tag $LOGTAG "Failed to update git user.email!"
fi
fi
if [ ! "$CUR_GIT_NAME" = "$GIT_NAME" ]; then
git config user.name "$GIT_NAME"
if [ $? -eq 0 ]; then
logger --stderr --id --tag $LOGTAG "Successfully updated git user.name"
else
logger --stderr --id --tag $LOGTAG "Failed to update git user.name!"
fi
fi
#--------------------------------------------------------------------------
# END system update: git config user.email, user.name to enable git stash
#--------------------------------------------------------------------------