-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdevboot
More file actions
executable file
·137 lines (122 loc) · 3.25 KB
/
devboot
File metadata and controls
executable file
·137 lines (122 loc) · 3.25 KB
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
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
#
# 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. If the default boot file is not present, it will try to
# make it.
DEFAULT_COOKIE="OpenACDDev"
APPNAME="oacd_hop"
function help_dump {
echo "usage: devboot [-c cookiename] [-s shortname | -n longname] [-f configfile] [-e erl_shell] [-nb | -b bootfile]"
echo ""
echo "-c defaults to \"${DEFAULT_COOKIE}\""
echo "-s and -n override each nother. Defaults to \"-s ${APPNAME}_dev\""
echo "-b defaults to rel/${APPNAME}/releases/1/${APPNAME}"
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=$DEFAULT_COOKIE
NAMETYPE="-sname"
NODENAME="${APPNAME}_dev"
CONFIG="single"
BOOT="-boot rel/${APPNAME}/releases/1/${APPNAME}"
ERL_PATH="erl"
RUN_DIR="rel/${APPNAME}/run"
export RUN_DIR
deps=`ls deps`
morepa=""
for deps_file in $deps
do
morepa="$morepa -pa deps/$deps_file/ebin"
done
# special to oacd_hop, the dist folder
deps=`ls contrib/rabbitmq-erlang-client/dist`
for deps_file in $deps
do
morepa="$morepa -pa contrib/rabbitmq-erlang-client/dist/$deps_file/ebin"
done
if [ ! -f "rel/${APPNAME}/releases/1/${APPNAME}.boot" ]
then
echo "Generating default boot file..."
./rebar generate
fi
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
HOSTNAME=`hostname`
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}]}
]},
{${APPNAME}, [
]},
{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 RUN_DIR=`pwd`
CMD="$ERL_PATH +K true -pa $EBIN $morepa -setcookie $COOKIE $NAMETYPE $NODENAME -config $CONFIG $BOOT"
#echo $CMD
exec $CMD
exit 0