-
Notifications
You must be signed in to change notification settings - Fork 0
/
port_init.sh
executable file
·43 lines (36 loc) · 1.03 KB
/
port_init.sh
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
#!/bin/bash
# Setup topology defined in config file
# usage: $0 <config> [<docker-image>]
# <config> - file with topology description
# <docker-image> - (OPTIONAL) docker image to use for containers. If not specified, default image will be used.
set -Eeo pipefail
if [[ $# -ne 2 ]]; then
echo "Missing parameters!"
echo "usage: $0 <port-min> <port-max>"
echo " <port-min> - lower bound"
echo " <port-max> - upper bound"
exit 2
fi
MIN=$1
MAX=$2
CFG_DIR="/etc/pfc"
# check basic structure
if [ ! -d "${CFG_DIR}" ] ; then
echo "# Creating '${CFG_DIR}'"
mkdir -p ${CFG_DIR}
chmod 755 ${CFG_DIR}
fi
if [ -f "${CFG_DIR}/gue_port.cfg" ] ; then
if [[ $(wc -l ${CFG_DIR}/gue_port.cfg | awk '{print $1}') -ne 0 ]] ; then
echo "# Port list already initialized"
exit 1
else
echo "# Port list exists, but empty"
fi
else
touch ${CFG_DIR}/gue_port.cfg
fi
for (( i=${MIN}; i<=${MAX}; i++ ))
do
echo "$i" >> ${CFG_DIR}/gue_port.cfg
done