-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
executable file
·55 lines (43 loc) · 1.25 KB
/
launch.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
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
DB_DIR="database_utils"
DB_PATH="${DB_DIR}/sanet.db"
DB_INIT_SCRIPT="${DB_DIR}/init.sql"
CONF_DIR="conf"
NODEID_CFG="${CONF_DIR}/nodeid.conf"
mynodeid=$( cat $NODEID_CFG )
echo $mynodeid
# database setup
rm -rf "$DB_PATH"
query="INSERT INTO node_status_map (nodeID, latitude, longitude, timestamp) VALUES ($mynodeid,0,0, strftime('%s', 'now'));"
sqlite3 "$DB_PATH" < "$DB_INIT_SCRIPT"
sqlite3 "$DB_PATH" "$query"
# tmux
trap end_servers SIGINT
function end_servers() {
echo "[*] Trapped CTRL-C"
tmux kill-session -t 0
tmuxproc="$(pgrep tmux)"
if [ -n "$tmuxproc" ] ; then
echo "Killing last tmux with PID : $tmuxproc"
kill "$tmuxproc"
fi
exit
}
function tmux_start() {
tmux new-session -d bash
tmux split-window -h bash
#sends keys to first and second terminals
tmux send -t 0:0.0 "python3 flightplanning/flight_server.py" C-m
sleep 15s
tmux send -t 0:0.1 "./robin -v 3" C-m
}
tmuxproc="$(pgrep tmux)"
echo "Tmux running with PID : $tmuxproc"
pkill -f tmux
if [ -n "$tmuxproc" ] ; then
echo "Killing last tmux with PID : $tmuxproc"
kill "$tmuxproc"
fi
tmux_start &
mate-terminal --tab --command "tmux attach-session;" # Only works on NO PC
cat