forked from Graham277/NewDozer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·55 lines (44 loc) · 1.27 KB
/
start.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.27 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
#!/usr/bin/env sh
# start.sh
# quickly source .venv and start up
# this script should be entirely sh-compliant
# if no arguments, use .venv
# if there is one argument, use it as a target
# if the one argument is --help/-h/-?, show help
# if there are two or more, throw error
VENV_TARGET=".venv"
# print help
help() {
echo "Usage:";
echo " setup.sh [--help|-h|-?|<venv-location>]";
echo " <venv-location>: The location of a virtualenv folder (optional, must not be specified with anything else). Defaults to '.venv'.";
echo " --help/-h/-?: Print this help (optional, must not be specified with anything else)";
echo "venv-location must not be named '--help', '-h' or '-?'";
exit "$1";
}
# parse argument (just one)
if [ $# -gt 1 ]; then
echo "Too many arguments";
help 1;
fi
if [ $# -eq 1 ]; then
# check for target/help
if [ "$1" = "--help" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ]; then
help 0;
else
VENV_TARGET="$1";
fi
fi
# check for venv and main.py
if ! [ -e "$VENV_TARGET" ] || ! [ -d "$VENV_TARGET" ]; then
echo "Cannot find directory $VENV_TARGET";
help 1;
fi
if ! [ -e "main.py" ] || ! [ -f "main.py" ]; then
echo "Cannot find main.py";
help 1;
fi
# source but sh
. "$VENV_TARGET"/bin/activate;
# run
"$VENV_TARGET"/bin/python3 main.py;