summaryrefslogtreecommitdiff
path: root/catlfish-dev/start.sh
blob: bf7b1291e6010dd0dd92c5b4bfdededcc4fc43e3 (plain)
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
#! /bin/sh

# Required arguments.
logname=$1; [ -n "$1" ] && shift
role=$1; [ -n "$1" ] && shift
nodename=$1; [ -n "$1" ] && shift

# Optional arguments.
erlbase=$ERLANG_BASE_DIR

# Use some reasonable default values.
[ -z "$erlbase" ] && erlbase=/usr/local/catlfish

# FIXME: Get compileconfig.py from the
# $erlbase/lib/catlfish-$VERSION.ez (zip archive) instead of requiring
# source code to be unpacked in the container.
COMPILECONFIG=/usr/local/src/catlfish/tools/compileconfig.py

case $role in
    frontend|storage|signing)
        if [ -f /usr/local/etc/catlfish/${nodename}.config ]; then
	    ln -s /usr/local/etc/catlfish/${nodename}.config
        else
	    mkdir ${nodename}
            $COMPILECONFIG --config /usr/local/etc/catlfish/${logname}.cfg \
                           --localconfig /usr/local/etc/catlfish/${nodename}.cfg;
	    ln -s ${nodename}/${nodename}.config
        fi
        $erlbase/bin/run_erl \
            /var/run/catlfish/ \
            /var/run/catlfish/erlang_log/ \
            "exec $erlbase/bin/erl -config $nodename"
        ;;

    merge)
        # Module versions are included in the filename of the module
        # archive file and in the filename within the
        # archive. Example: lib/catlfish-0.8.0-dev.ez contains
        # catlfish-0.8.0-dev.
        ver=$(ls $erlbase/lib/catlfish-*.ez | sed 's/.*catlfish-\(.*\)\.ez/\1/1')
        ERL_LIBS=$erlbase/lib/catlfish-${ver}.ez/catlfish-${ver}
        ver=$(ls $erlbase/lib/plop-*.ez | sed 's/.*plop-\(.*\)\.ez/\1/1')
        ERL_LIBS=$ERL_LIBS:$erlbase/lib/plop-${ver}.ez/plop-${ver}
        ver=$(ls $erlbase/lib/lager-*.ez | sed 's/.*lager-\(.*\)\.ez/\1/1')
        ERL_LIBS=$ERL_LIBS:$erlbase/lib/lager-${ver}.ez/lager-${ver}
        export ERL_LIBS

	[ -z "${MERGE_DB_DIR}" ] && MERGE_DB_DIR=merge-db

        $erlbase/merge.sh ${logname} ${nodename} \
                          > merge_log/stdout \
                          2> merge_log/stderr
        ;;
    *)
        echo "catlfish: unknown role: $role"
        ;;
esac