-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·86 lines (71 loc) · 1.88 KB
/
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
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
#!/bin/bash
set -euo pipefail
INSTALL_DIR="$(dirname "$BASH_SOURCE")"
cd "$INSTALL_DIR"
LOGDIR=""
if [ -f ./mobindi.conf ]; then
. ./mobindi.conf
fi
UPDATECONF=0
FORCE_BUILD=0
while [ "$#" != 0 ]; do
case "$1" in
--log-dir)
shift
LOGDIR="$1"
shift
UPDATECONF=1
;;
--no-log-dir)
shift
LOGDIR=""
UPDATECONF=1
;;
--force-build)
shift
FORCE_BUILD=1
;;
*)
echo "Usage: $0 [--log-dir logdirectory] [--no-log-dir] [--force-build]"
exit 1
;;
esac
done
printf "Settings:\n * Log directory: %s\n" "$LOGDIR"
if [ "$UPDATECONF" != 0 ]; then
printf "LOGDIR='%q'" "$LOGDIR" > ./.mobindi.conf.tmp
mv ./.mobindi.conf.tmp ./mobindi.conf
fi
if [ "${LOGDIR-}" != "" ]; then
which multilog > /dev/null || (echo "Installation of daemontools required" >&2 ; sudo apt install daemontools)
[ -d "$LOGDIR" ] || sudo mkdir -p -- "$LOGDIR"
[ -w "$LOGDIR" ] || sudo chown "$UID" -R -- "$LOGDIR"
fi
# Rebuild if required
CURRENTREV="`git rev-parse HEAD`"
if [ "$CURRENTREV" == "" ]; then
echo "Git repo is broken. Aborting" 2>&1
exit 1
fi
if [ "$FORCE_BUILD" != 0 ]; then
LATESTBUILD=""
else
ISCLEAN="`git status --porcelain`"
if [ "$ISCLEAN" != "" ]; then
echo "WARNING: You're git repo is not clean - Automated build cannot be deduced from local modification" 2>&1
fi
if [ -f ".latestbuild" ]; then
LATESTBUILD="`cat .latestbuild`"
else
LATESTBUILD=""
fi
fi
if [ "$CURRENTREV" != "$LATESTBUILD" ]; then
echo "Build required... Please wait" 2>&1
rm -f .latestbuild
./build.sh
echo "$CURRENTREV" >> .latestbuild
fi
# Setup nginx
./nginx/install.sh
echo "System ready" >&2