-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-prince.sh
More file actions
executable file
·37 lines (30 loc) · 972 Bytes
/
start-prince.sh
File metadata and controls
executable file
·37 lines (30 loc) · 972 Bytes
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
#!/usr/bin/env sh
prince_conf="prince_conf_c_h.json"
prince_log="/tmp/prince.log"
hello_mult=$1
tc_mult=$2
if [ $# -eq 3 ]; then
prince_conf=$3
elif [ $# -eq 4 ]; then
prince_conf=$3
prince_log=$4
fi
# set validity multipliers before starting prince
echo "/HelloTimerMult=${hello_mult}" | nc localhost 1234
echo "/TcTimerMult=${tc_mult}" | nc localhost 1234
sudo rm /tmp/prince.conf
cat $(pwd)/${prince_conf} | sed 's@^.*log_file.*$@"log_file":"'"${prince_log}"'"@' > /tmp/prince.conf
cp /tmp/prince.conf $(pwd)/${prince_conf}
# determine whether we are on a NUC or on a TPLINK
opkg_path=`which opkg`
if [ -z "$opkg_path" ]; then
prince_pid=$(ps aux | grep /usr/bin/prince | grep -v grep | tr -s ' ' | cut -d ' ' -f 2)
# Kill prince if it's already running
if [ ! -z "${prince_pid}" ]; then
kill ${prince_pid}
fi
echo "/usr/bin/prince $(pwd)/${prince_conf}" | at now
else
echo "WARNING: Prince start mechanism for OpenWRT not implemented yet"
exit 1
fi