-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·133 lines (106 loc) · 2.81 KB
/
install
File metadata and controls
executable file
·133 lines (106 loc) · 2.81 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
USAGE="Usage: `basename $0` [-lep] [-b]"
ROOT_UID=0
E_NOTROOT=87
# must be run as super user
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script"
exit $E_NOTROOT
fi
# directories used by sugar
#TODO replace these with environment variables
ACTIVITY_DIR=/home/sugar/Activities
LIBRARY_DIR=/usr/lib
EXTENSION_DIR=/usr/share/sugar/extensions
# generate directories for activities
MATH_PRAC_DIR="${ACTIVITY_DIR}/MathogenPrac.activity"
MATH_TUTE_DIR="${ACTIVITY_DIR}/MathogenTute.activity"
MATH_EXAM_DIR="${ACTIVITY_DIR}/MathogenExam.activity"
# glycogen library and extension directories
LIB_DIR="${LIBRARY_DIR}/python2.7/site-packages/glycogen"
EXT_DIR="${EXTENSION_DIR}/cpsection/glycogen"
# directories to copy from
HERE=`pwd`
ACTIVITY_FROM="${HERE}/activities"
MATH_PRAC_FROM="${ACTIVITY_FROM}/mathogen_prac/MathogenPrac.activity"
MATH_TUTE_FROM="${ACTIVITY_FROM}/mathogen_tute/MathogenTute.activity"
MATH_EXAM_FROM="${ACTIVITY_FROM}/mathogen_exam/MathogenExam.activity"
LIB_FROM="${HERE}/site-packages/glycogen"
EXT_FROM="${HERE}/extensions/cpsection/glycogen"
DO_BACKUP=false
DO_LIB=false
DO_EXT=false
DO_MATH_PRAC=false
DO_MATH_TUTE=false
DO_MATH_EXAM=false
# parse command line options
#TODO there is something wrong with these - they sort of work,
# but often the backup is not done, and there are complaints sometimes
# about missing an argument
while getopts bleptx: OPT; do
case "$OPT" in
b)
DO_BACKUP=true
;;
l)
DO_LIB=true
;;
e)
DO_EXT=true
;;
p)
DO_MATH_PRAC=true
;;
t)
DO_MATH_TUTE=true
;;
x)
DO_MATH_EXAM=true
;;
\?)
# invalid parameter passed
echo $USAGE >&2
exit 1
;;
esac
done
# decide which components to update
# TODO set these from command line arguments
# handle backing up of old directories
BACKUP_LABEL=".old"
function backup {
# $1 directory to back up
rm -r $1$BACKUP_LABEL #remove old backup
cp -r $1 $1$BACKUP_LABEL
echo "[backup] $1 to"
echo "[backup] $1$BACKUP_LABEL"
}
function deploy {
# $1 source directory
# $2 target directory
if $DO_BACKUP ; then
backup $2
fi
rm -r $2 # remove old version
cp -r $1 $2 # deploy source version to target directory
echo "[deploy] from $1"
echo "[deploy] to $2"
}
if $DO_MATH_PRAC ; then
deploy $MATH_PRAC_FROM $MATH_PRAC_DIR
fi
if $DO_MATH_TUTE ; then
deploy $MATH_TUTE_FROM $MATH_TUTE_DIR
fi
if $DO_MATH_EXAM ; then
deploy $MATH_EXAM_FROM $MATH_EXAM_DIR
fi
if $DO_LIB ; then
deploy $LIB_FROM $LIB_DIR
fi
if $DO_EXT ; then
deploy $EXT_FROM $EXT_DIR
fi
echo "[finish] success"
exit 0