forked from martindale/nntpchan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·77 lines (67 loc) · 1.55 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
#!/usr/bin/env bash
set -e
root=$(readlink -e $(dirname $0))
prefix="/opt/nntpchan"
help_text="usage: $0 [--prefix /opt/nntpchan] [-q|--quiet] [-r|--rebuild] [--disable-redis]"
# check for help flags first
for arg in $@ ; do
case $arg in
-h|--help)
echo $help_text
exit 0
;;
esac
done
_next=""
want_rebuild="0"
want_quiet="0"
build_args=""
# check for main flags
for arg in $@ ; do
case $arg in
-q|--quiet)
want_quiet="1"
;;
-r|--rebuild)
want_rebuild="1"
;;
--prefix)
_next="prefix"
;;
--prefix=*)
prefix=$(echo $arg | cut -d'=' -f2)
;;
--disable-redis)
build_args="$build_args --disable-redis"
;;
*)
if [ "X$_next" == "Xprefix" ] ; then
# set prefix
prefix="$arg"
_next=""
fi
;;
esac
done
_cmd() {
if [ "X$want_quiet" == "X1" ] ; then
$@ &> /dev/null
else
$@
fi
}
if [ "X$want_rebuild" == "X1" ] ; then
_cmd echo "rebuilding daemon";
_cmd $root/build.sh $build_args
fi
if [ ! -e $root/srndv2 ] ; then
_cmd echo "building daemon"
# TODO: use different GOPATH for root?
_cmd $root/build.sh $build_args
fi
_cmd mkdir -p $prefix
_cmd mkdir -p $prefix/webroot/thm
_cmd mkdir -p $prefix/webroot/img
_cmd cp -f $root/srndv2 $prefix/srndv2
_cmd cp -rf $root/{doc,contrib,certs} $prefix/
_cmd echo "installed to $prefix"