-
Notifications
You must be signed in to change notification settings - Fork 1
/
tagtracker
46 lines (40 loc) · 1.17 KB
/
tagtracker
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
#!/bin/bash
#
# Startup script for TagTracker on Linux
#
# This will navigate to TagTracker folder, run TagTracker,
# then (on user confirmation), run it again. (This because
# program may well have shut down to reset for next day.)
old_dir="$(pwd)"
this_prog=$0
prog_name="${0##*/}"
if [[ "$TAGTRACKER_HOME" == "" ]]; then
echo "TAGTRACKER_HOME not set"
exit 1
fi
this_pid=$$
tt_pids=$(pgrep -u "$USER" -f 'python3[0-9\.]*\s+tagtracker.py')
if [[ "$tt_pids" != "" ]] ; then
echo TagTracker is already running, stopping other copies.
other_pids_to_kill=$(pgrep -u "$USER" -f "(\b$prog_name\b|python3[0-9\.]*\s+tt_internet_monitor)"|grep -v $this_pid)
kill -TERM $tt_pids $other_pids_to_kill 2>/dev/null
sleep 1
kill -KILL $tt_pids $other_pids_to_kill 2>/dev/null
sleep 1
fi
echo "Starting TagTracker in $TAGTRACKER_HOME..."
echo
cd "$TAGTRACKER_HOME/bin" || exit 1
python3 tagtracker.py
echo
echo "TagTracker done."
echo
read -rp "Restart TagTracker? (Y/N): " confirm
echo
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then
exec "$this_prog"
fi
# Do not restart
cd "$old_dir" || exit 1
echo "To restart TagTracker, enter \"$prog_name\""
echo