Julian-Hans commited on
Commit
8e25340
1 Parent(s): 88282b4

added setup script

Browse files
Files changed (1) hide show
  1. setup.sh +64 -0
setup.sh ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ VENV_DIR="venv"
4
+
5
+ #ensure package list
6
+ sudo add-apt-repository -y universe
7
+ #ensure python and requirements is installed
8
+ sudo apt install -qq -y python3-venv
9
+ sudo apt install -qq -y python3-pip
10
+ sudo apt install -y build-essential
11
+ sudo apt install -y gcc g++
12
+ sudo apt install -y screen
13
+
14
+
15
+ # Check if the virtual environment exists
16
+ if [ ! -d "$VENV_DIR" ]; then
17
+ echo "Virtual environment not found. Creating a new one..."
18
+ # Create a virtual environment
19
+ python3 -m venv "$VENV_DIR"
20
+ echo "Virtual environment created."
21
+
22
+ else
23
+ echo "Virtual environment found."
24
+ fi
25
+
26
+ # Activate the virtual environment
27
+ source "$VENV_DIR/bin/activate"
28
+ echo "Virtual environment $VENV_DIR activated."
29
+
30
+ pip install --upgrade pip
31
+
32
+ if [ -d "Case-Study-1" ]; then
33
+ echo "Repository folder 'Case-Study-1' already exists. Checking for updates."
34
+ cd Case-Study-1
35
+ if git pull | grep -q 'Already up to date.'; then
36
+ echo "Repository is up to date. Proceeding with setup."
37
+
38
+ else
39
+ echo "Repository updated successfully. Proceeding to next step."
40
+ git clone https://github.com/oxmraz-mldo24/Case-Study-1.git
41
+ fi
42
+ else
43
+ echo "Cloning repository..."
44
+ if git clone https://github.com/oxmraz-mldo24/Case-Study-1.git; then
45
+ echo "Repository cloned successfully. Proceeding to next step."
46
+ cd Case-Study-1
47
+ else
48
+ echo "Failed to clone repository. Exiting."
49
+ exit 1
50
+ fi
51
+ fi
52
+ echo "Checking if http://127.0.0.1:7860 is running..."
53
+ if curl -s --head http://127.0.0.1:7860 | grep "200 OK" > /dev/null; then
54
+ echo "URL is running.No further action required. Exiting."
55
+ exit 0 # Exit script since the service is already running
56
+ else
57
+ echo "URL is not running.Proceeding with setup."
58
+ # Install dependencies and run the application
59
+ pip install -r requirements.txt
60
+
61
+ screen -S "app" -d -m bash -c 'python3 app.py'
62
+ fi
63
+ deactivate
64
+ exit 0