forked from erocci/erocci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·112 lines (105 loc) · 2.55 KB
/
start.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
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
#!/bin/bash
basedir=$(cd $(dirname $0) && pwd)
function usage() {
#echo "Usage: $0 [-d] [-t] [-s] [-x <jid>] [-c <config>] [-h]"
echo "Usage: $0 [-d] [-t] [-s] [-c <config>] [-h]"
echo -e "\t-d Print debug messages"
echo -e "\t-q Print only error messages"
echo -e "\t-t Start HTTP listener"
echo -e "\t-s Start HTTPS listener (default: HTTP)"
#echo -e "\t-x <jid> Start XMPP listener with given JID"
echo -e "\t-c <config> Set alternate config file (default: example.config)"
echo -e "\t-n <name> Set node name for distributed mode (default: node1)"
echo -e "\t-h Print this help"
}
function join {
local IFS="$1"; shift; echo -n "$*"
}
appdir=$basedir/apps/erocci
ssldir=$appdir/priv/ssl
cacertfile=$ssldir/cowboy-ca.crt
certfile=$ssldir/server.crt
keyfile=$ssldir/server.key
name=node1
debug=info
configdir=$basedir/config
config=$configdir/sys.config
idx=-1
http_listener="{http, occi_http, [{port, 8080}]}"
listeners[0]=${http_listener}
#while getopts ":hdqtsc:x:p:" opt; do
while getopts ":hdqtsc:x:" opt; do
case $opt in
d)
debug=debug
set -x
;;
q)
debug=error
;;
t)
idx=$(( $idx + 1 ))
listeners[$idx]=${http_listener}
;;
s)
idx=$(( $idx + 1 ))
listeners[$idx]="{https, occi_https, [{port, 8443}, {cacertfile, \"$cacertfile\"}, {certfile, \"$certfile\"}, {keyfile, \"$keyfile\"}]}"
;;
x)
echo "XMPP listener disabled"
usage
exit 1
#jid=$OPTARG
# case x$jid in
# x)
# true
# ;;
# *@local)
# idx=$(( $idx + 1 ))
# listeners[$idx]="{xmpplocal, occi_xmpp_client, [{jid, \"$jid\"}, {auth, {xmpp, []}}]}"
# ;;
# *)
# read -s -p "Password:" passwd
# idx=$(( $idx + 1 ))
# listeners[$idx]="{xmppc, occi_xmpp_client, [{jid, \"$jid\"}, {passwd, \"$passwd\"}, {auth, {xmpp, []}}]}"
# ;;
# esac
;;
c)
if [ -e $OPTARG ]; then
case $OPTARG in
/*)
config=$OPTARG
;;
*)
config=`pwd`/$OPTARG
;;
esac
elif [ -e ${configdir}/$OPTARG ]; then
config=${configdir}/$OPTARG
else
echo "Could not find config: "$OPTARG
exit 1
fi
;;
n)
name=$OPTARG
;;
h)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
listeners=$(echo -n "["; join , "${listeners[@]}"; echo -n "]")
cd ${basedir}
exec erl -pa $basedir/apps/erocci/ebin -pa $basedir/deps/*/ebin \
-boot start_sasl \
-config $config \
-erocci_core listeners "$listeners" \
-sname $name \
-s erocci