forked from OpenACD/OpenACD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevboot
executable file
·127 lines (115 loc) · 3.11 KB
/
devboot
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#
# This is the successor to ./boot.rb. To remove the dependancy on ruby, we
# are converting to rebar. However, rebar does not allow for an easy way
# to change a system that's running. Generating a release does a fine
# job of creating a start up script, but it cannot be regenerated without
# trashing the existing release. The bins for the deps are not put into
# the primary ebin folder, so those get lost. Thus, this is a dev boot
# script that will allow one to start the system in a dev-friendly mode,
# and still be able to run rebar and reload the resulting code.
#
# The ironic twist is this will only work if you've done a rebar generate.
function help_dump {
echo "usage: devboot [-c cookiename] [-s shortname | -n longname] [-f configfile] [-nb | -b bootfile]"
echo ""
echo "-c defaults to \"OpenACDDev\""
echo "-s and -n override each nother. Defaults to \"-s openacddev\""
echo "-b defaults to rel/openacd/releases/1/openacd"
echo "-nb disables use of a boot file. -b and -nb override eachother."
echo "-f defaults to \"single\""
echo "-e defaults to \"erl\""
}
EBIN="ebin"
COOKIE="OpenACDDev"
NAMETYPE="-sname"
NODENAME="openacddev"
CONFIG="single"
BOOT="-boot rel/openacd/releases/1/openacd"
ERL_PATH="erl"
OPENACD_RUN_DIR="rel/openacd/run"
export OPENACD_RUN_DIR
deps=`ls deps`
morepa=""
for deps_file in $deps
do
morepa="$morepa -pa deps/$deps_file/ebin"
done
# and included apps too
deps=`ls include_apps`
for deps_file in $deps
do
morepa="$morepa -pa include_apps/$deps_file/ebin"
done
args=("$@")
argstring=""
i=0
while [ $i -lt ${#args[@]} ]
do
case ${args[${i}]} in
"-s")
NAMETYPE="-sname"
let i=$i+1
NODENAME="${args[${i}]}";;
"-n")
NAMETYPE="-name"
let i=$i+1
NODENAME="${args[${i}]}";;
"-b")
let i=$i+1
BOOT="-boot ${args[${i}]}";;
"-nb")
BOOT="";;
"-c")
let i=$i+1
COOKIE="${args[${i}]}";;
"-f")
let i=$i+1
CONFIG="${args[${i}]}";;
"-e")
let i=$i+1
ERL_PATH="${args[${i}]}";;
*)
help_dump
exit 0
esac
argstring="$argstring ${args[${i}]}"
let i=$i+1
done
if [ ! -f $CONFIG ] && [ ! -f "${CONFIG}.config" ]; then
SUFFIX=`echo "${CONFIG}" | awk -F . '{print $NF}'`
CONFIGNODENAME=`erl -eval "io:format(\"~s\",[node()]),halt(1)" $NAMETYPE $NODENAME -noshell`
if [ $SUFFIX = 'config' ]; then
FILE=$CONFIG
else
FILE="${CONFIG}.config"
fi
cat > $FILE <<single.config
%% This file was generated by devboot.
%% If you are comfortable editing erlang application configuration scripts
%% there is no harm in editing the file.
[{'OpenACD', [
{nodes, ['$CONFIGNODENAME']},
{console_loglevel, info},
{logfiles, [{"full.log", debug}, {"console.log", info}]},
{plugin_dir, "plugins.d"}
]},
{sasl, [
{errlog_type, error} % disable SASL progress reports
]}].
single.config
fi
if [ ! -f "key" ]; then
echo "RSA key does not exist, generating..."
ssh-keygen -t rsa -f key -N ""
RES=$?
if [ $RES != 0 ]; then
echo "Key generation failed with error $RES!"
exit $RES
fi
fi
export OPENACD_RUN_DIR=`pwd`
CMD="$ERL_PATH +K true -pa $EBIN $morepa -setcookie $COOKIE $NAMETYPE $NODENAME -config $CONFIG $BOOT"
#echo $CMD
exec $CMD
exit 0