-
-
Notifications
You must be signed in to change notification settings - Fork 387
/
gen_dev
executable file
·30 lines (26 loc) · 785 Bytes
/
gen_dev
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
#! /bin/sh
#
# gen_dev dev4 vars.src vars
#
# Generate an overlay config for devNNN or dev_swcNNN from vars.src and write to vars
#
NAME=$(echo $1 | sed -e "s/_swc//")
TEMPLATE=$2
VARFILE=$3
NODE="[email protected]"
NUMBER=${NAME##dev}
BASE=$((10000 + 50 * $NUMBER))
MQTTPORT=$(($BASE + 3))
MQTTWSPORT=$(($BASE + 4))
MQTTSPORT=$(($BASE + 5))
CLUSTERPORT=$(($BASE + 10))
METRICSPORT=$(($BASE + 20))
HTTPSPORT=$(($BASE + 21))
echo "Generating $NAME - node='$NODE' mqttport=$MQTTPORT mqttwsport=$MQTTWSPORT"
sed -e "s/@NODE@/$NODE/" \
-e "s/@MQTTPORT@/$MQTTPORT/" \
-e "s/@MQTTWSPORT@/$MQTTWSPORT/" \
-e "s/@MQTTSPORT@/$MQTTSPORT/" \
-e "s/@CLUSTERPORT@/$CLUSTERPORT/" \
-e "s/@HTTPSPORT@/$HTTPSPORT/" \
-e "s/@METRICSPORT@/$METRICSPORT/" < $TEMPLATE > $VARFILE