-
Notifications
You must be signed in to change notification settings - Fork 0
/
start
executable file
·52 lines (47 loc) · 2.12 KB
/
start
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
#!/bin/bash
echo
# Check to see if in the right base directory
CURRENT_BASE_DIR=${PWD##*/}
if [ $CURRENT_BASE_DIR = "Super-Best-Frame" ]
then
# Virtual enviromnment for flask applications
echo "[Super-Best-Frame] - Checking if virtual enviroment is setup ..."
if [ -d ./env ] # Check to see if virtual enviroment exists in current working directory
then
echo "[Super-Best-Frame] - Virtual environment already exists."
echo "[Super-Best-Frame] - Activating virtual enviroment ..."
source env/bin/activate # Activate virtual enviroment
else
echo "[Super-Best-Frame] - Creating a virtual environment for web application ..."
python3 -m venv env # Creating the virtual environment
echo "[Super-Best-Frame] - Activating virtual enviroment ..."
source env/bin/activate # Activate virtual enviroment
echo "[Super-Best-Frame] - Installing all required python packages ..."
pip3 install -U -r requirements.txt # Install all required packages for virtual environment
fi
# Setting up OpenCV
# python3 -c "import cv2; print(cv2.__version__)"
OPENCV_VER=$(python3 -c "import cv2; print(cv2.__version__)" 2> /dev/null)
if [ $? -eq 0 ]; then
echo "[Super-Best-Frame] - Open CV is already installed on this system"
echo "[Super-Best-Frame] - Open CV version: ${OPENCV_VER}"
else
echo "[Super-Best-Frame] - Open CV is not installed on this sytem. Installing"
sudo apt -y update
sudo apt -y install python3-opencv
fi
echo "[Super-Best-Frame] - Setting envirmental variable 'DISPLAY' to 0 ..."
export DISPLAY=:0
# Running the flask application
echo "[Super-Best-Frame] - Starting web application ..."
echo
python3 main.py
echo
echo "[Super-Best-Frame] - Web application has stopped."
else
# Current directory is not correct
echo
echo "[Super-Best-Frame] - CRITICAL! - Application was not able to start up!"
echo "[Super-Best-Frame] - CRITICAL! - Shell script not executed within the correct directory."
echo
fi