summaryrefslogtreecommitdiff
path: root/tools/getconfig.sh
blob: 2ce9be3e18eb0e50f5172785ae712c5d8cb39cca (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
#!/bin/sh

# usage: getconfig.sh <localconfig> <globalconfig> <plopcontrolfile>

set -o nounset
set -o errexit

BINDIR=$(dirname $0)

localconfig=$1
globalconfig=$2
plopcontrolfile=$3

plopcontrolport=
configversion="unknown"
if [ "${plopcontrolfile}" != "force-compile" -a -f ${plopcontrolfile} ]; then
    plopcontrolport=$(cat ${plopcontrolfile})
    configversion=$($BINDIR/plopcontrol.py ${plopcontrolfile} "configversion" || echo unreachable)
fi

echo "version before reload: $configversion"
getconfigresult=$(${BINDIR}/getconfig.py --localconfig ${localconfig} --dest ${globalconfig})
if [ "${plopcontrolfile}" = "force-compile" -o "$getconfigresult" = "newconfig" ]; then
    ${BINDIR}/compileconfig.py --localconfig ${localconfig} --config ${globalconfig}
    if [ "${plopcontrolport}" != "" ]; then
        reloadresult=$($BINDIR/plopcontrol.py ${plopcontrolfile} "reload" || echo unreachable)
        echo $reloadresult
        if [ "$reloadresult" != "reload completed" ]; then
            exit 1
        fi
        configversion=$($BINDIR/plopcontrol.py ${plopcontrolfile}  "configversion" || echo unreachable)
        echo "version after reload: $configversion"
    fi
else    
    echo "reload not needed"
fi