-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart
More file actions
executable file
·88 lines (78 loc) · 1.91 KB
/
start
File metadata and controls
executable file
·88 lines (78 loc) · 1.91 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
# Usage: ./start [nongrok|nogrok]
quit() {
# echo "start EOF"
kill $ngrok_pid 2> /dev/null
kill $frpc_pid 2> /dev/null
exit 0
}
trap quit EXIT
usage() {
echo "Usage: $(basename $0) [-d] [-f <0|1>] [-n <0|1>]"
echo " -h ... Show this help"
echo " -d ... Dev Mode"
echo " -c ... Console (Run in second terminal to see output from Dev Mode)"
echo " -f ... Start frpc (Default 1 except when using -d)"
echo " -n ... Start ngrok (Default 0)"
exit 1
}
dev=false
start_frpc=true
start_ngrok=false
# A letter followed by a colon means the switch takes an argument
while getopts "hcdf:n:" opts; do
case "${opts}" in
h)
usage
exit 1
;;
c)
textual console -x event -x debug
exit 0
;;
d)
dev=true
start_frpc=true
start_ngrok=false
;;
f)
f=${OPTARG}
[[ $f -eq 0 || $f -eq 1 ]] || usage
[[ $f -eq 1 || -z $f ]] && start_frpc=true || start_frpc=false
;;
n)
n=${OPTARG}
[[ $n -eq 0 || $n -eq 1 ]] || usage
[[ $n -eq 1 || -z $n ]] && start_ngrok=true || start_ngrok=false
;;
*)
usage
exit 1
;;
esac
done
# remove switches from $@
shift $((OPTIND-1))
if $start_frpc; then
# start frpc (in the background)
echo "Starting frpc.sh..."
./frpc.sh > /dev/null &
frpc_pid=$!
fi
if $start_ngrok; then
# start ngrok (in the background)
echo "Starting ngrok.sh..."
./ngrok.sh noui > /dev/null &
ngrok_pid=$!
fi
# Try to activate venv
if [[ -f ./venv/bin/activate ]]; then
echo "Activating virtual env..."
source ./venv/bin/activate
fi
# run plotter-server
if $dev; then
textual run --dev main.py
else
python main.py
fi