-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·38 lines (32 loc) · 897 Bytes
/
install.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
#!/bin/bash
NAME=excavate
SRC="./${NAME}.py"
# Find a directory where executables (namely, Python) are stored
# for the GitLab CI runner user, if one exists. Otherwise, install
# to /usr/local/bin.
GITLAB_USER=$(grep -i '^gitlab[^:]*runner:' /etc/passwd | cut -f1 -d:)
if [ "$GITLAB_USER" != "" ]; then
DST_DIR=$(dirname $(su $GITLAB_USER -c "which python"))
else
DST_DIR=/usr/local/bin
fi
DST="$DST_DIR/$NAME"
CP=/bin/cp
CHMOD=/bin/chmod
MD5SUM=md5sum
function exec_cmd() {
local cmd="$@"
$cmd
local result=$?
if [ $result -ne 0 ]; then
exit $result
fi
}
echo "Installing $SRC to $DST"
echo "------------------------------------------------------------------"
exec_cmd $MD5SUM $SRC
exec_cmd $CP $SRC $DST
exec_cmd $CHMOD +x $DST
exec_cmd $MD5SUM $DST
echo "------------------------------------------------------------------"
echo "Installation complete"