-
Notifications
You must be signed in to change notification settings - Fork 2
/
launcher.sh
executable file
·112 lines (100 loc) · 2.34 KB
/
launcher.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/zsh
err_exit(){
echo '[ERROR]'
printf "%s " "Press enter to continue"
read -r
exit "$1"
}
# Get the option
r_key=false
update_symbols_key=false
str_param=""
printf "%s " "Params: "
while [ "$#" -gt 0 ]
do
case "$1" in
-f|--freeze)
r_key=true
printf "%s " " freeze;"
;;
-u|--update-symbols)
update_symbols_key=true
printf "%s " " --update-symbols;"
;;
--first-symbol)
shift
first_symbol="$1"
str_param+="--first-symbol $first_symbol "
printf "%s " " first symbol='$first_symbol';"
;;
--second-symbol)
shift
second_symbol="$1"
str_param+="--second-symbol $second_symbol "
printf "%s " " second-symbol='$second_symbol';"
;;
--id)
shift
id="$1"
str_param+="--id $id "
printf "%s " " id=$id;"
;;
--test)
test="--test"
str_param+="$test "
printf "%s " "$test;"
;;
--force-url)
force_url="--force-url"
str_param+="$force_url "
printf "%s " " $force_url';"
;;
-h|--help)
help="--help"
str_param+="$help "
printf "%s " " $help';"
;;
-*)
echo "Invalid option '$1'. Use -h or --help to see the valid options" >&2
return 1
;;
*)
echo "Invalid option '$1'. Use -h or --help to see the valid options" >&2
return 1
;;
esac
shift
done
echo
echo "start_dir: $(pwd)"
start_dir=$(pwd)
echo "base_dir: $(dirname "$0")"
base_dir=$(dirname "$0")
if [ "$base_dir" != "." ]; then
echo "Changing directory to: $base_dir"
cd "$base_dir" || err_exit $?
echo "pwd: $(pwd)"
fi
echo "Venv activating:"
source ./venv/bin/activate || err_exit $?
echo "Venv activated successful"
if [ "$r_key" = true ]; then
echo "pip freeze:"
pip freeze
fi
# Updating symbols list
printf "\nUpdating symbols list \n"
if $update_symbols_key; then
printf "python ./getting_data/scrape_app.py > \n"
python ./getting_data/scrape_app.py
printf "< python ./getting_data/scrape_app.py\n\n"
fi
# Starting bot with
printf "\n%s\n" "Starting bot with args: $str_param "
printf "python ./bot_logic.py > \n"
while true ; do echo "$str_param" | xargs python ./bot_logic.py || sleep 5; done
printf "< python ./bot_logic.py\n\n"
echo "Changing directory to: $start_dir"
cd "$start_dir" || err_exit $?
echo "pwd: $(pwd)"
deactivate