aboutsummaryrefslogtreecommitdiffstats
path: root/bin/dev_tools/master_app.sh
blob: 3de9c600cbf6c7f40171c310f9a7de5a12cd7be8 (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
#!/bin/bash

#
# Set the master app by:
#  (a) renaming the other master(s) datasource files
#  (b) enabling the master datasource file
#

master_app=$1
if [ -z "$master_app" ] ; then
    master_app="yp"
fi
if [ ! -d "./bin/$master_app" ] ; then
    echo "ERROR: master app directory missing"
    exit 1
fi

FS=$'\n'       # make newlines the only separator
for p in $(find bin -name srtool_env.sh -exec grep -l "SRT_MAIN_APP" {} \;) ; do
    if [ "${p}" != "${p/bin\/yp/}" ] ; then
        # Always leave the 'yp' directory alone
        continue
    fi
    echo "Check:$p"
    ds_dir=$(dirname $p)
    if [ "${p}" != "${p/bin\/$master_app/}" ] ; then
        echo "SET_MASTER:$p"
        mv -f $ds_dir/datasource.json_sample $ds_dir/datasource.json 2> /dev/null
    else
        echo "DISABLE_MASTER:$p"
        mv -f $ds_dir/datasource.json $ds_dir/datasource.json_sample 2> /dev/null
    fi
done

if [ "yp" = "$master_app" ] ; then
    echo "SET_MASTER:./bin/$master_app"
fi