-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlutece.sh
executable file
·64 lines (59 loc) · 1.4 KB
/
lutece.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
62
63
64
#!/bin/bash
## Globals variables
# differring messages
MESSAGES=()
# quiet !
QUIET="-q"
# check if all utils are installed
function checkEnv() {
for app in cp mv rm chmod find awk sed tr cut curl git; do
if [ -z "`which $app 2>/dev/null`" ]; then
printf "%-20s%s\n" "$app" "[!!]"
echo "You have to install $app for running this script correctly." >&2
customExit 2
else
printf "%-20s%s\n" "$app" "[ok]"
fi
done
}
# retrieve git tools in temp folder
function getScripts() {
url="https://github.com/lutece-platform/tools-git-scripts"
TMPDIR="/tmp/tmp.$$"
git clone "$url" "${TMPDIR}" ${QUIET}
# TODO: Comment it !
# during development
#git --git-dir="${TMPDIR}/.git" --work-tree="${TMPDIR}" checkout -b develop origin/develop
# rsync -a /home/cmarneux/svn/lutece/tools-git-scripts/ "${TMPDIR}"
return $?
}
# clear temp folders/files then exit
# Param1: exit code
function customExit() {
if [ ${#MESSAGES[@]} -gt 0 ]; then
for i in ${!MESSAGES[@]}; do
echo "${MESSAGES[i]}"
done
fi
if [ -s "${TMPDIR}/`basename "$0"`" ]; then
mode=`stat -c "%a" "$0"`
cp "${TMPDIR}/`basename "$0"`" "$0"
chmod $mode "$0"
fi
rm -Rf "${TMPDIR}"
exit $1
}
checkEnv
getScripts
if [ $? -eq 0 ]; then
if [ -s "${TMPDIR}/main.sh" ]; then
source "${TMPDIR}/main.sh"
customExit 0
else
echo "Error to find main script." >&2
customExit 3
fi
else
echo "Error occured during git clone." >&2
customExit 4
fi