From 9935d59ab6053425ffe651061d6f85caf347f636 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 15:25:13 +0200 Subject: [PATCH 01/35] add scripts to start server --- html/install.sh | 23 +++++++++++++++++++++++ html/run.sh | 12 ++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 html/install.sh create mode 100644 html/run.sh diff --git a/html/install.sh b/html/install.sh new file mode 100644 index 00000000..7cbeb29f --- /dev/null +++ b/html/install.sh @@ -0,0 +1,23 @@ +#!/bin/bash +PAINT_ROOT=/home/paint/PAINT +ENV_PATH=/home/paint/venv + +# Install git. +sudo apt-get update +sudo apt-get -y install git + +# Clone repository. +git clone https://github.com/ARTIST-Association/PAINT.git $PAINT_ROOT + +# Navigate to repository and create virtual environment if it doesn't exist yet. +cd $PAINT_ROOT +if [ ! -d "$ENV_PATH" ]; then + python3 -m venv $ENV_PATH +fi + +# Activate virtual environment and upgrade pip. +source $ENV_PATH/bin/activate +pip install --upgrade pip + +# Install dependencies. +pip install . diff --git a/html/run.sh b/html/run.sh new file mode 100644 index 00000000..bc8c34a4 --- /dev/null +++ b/html/run.sh @@ -0,0 +1,12 @@ +#!/bin/bash +PAINT_ROOT=/home/paint/PAINT +ENV_PATH=/home/paint/venv + +# Activate virtual environment. +source $ENV_PATH/bin/activate + +# Navigate to html directory. +cd $PAINT_ROOT/html + +# Start flask application. +flask run & From aa0da2e6b6b27d3ee81580ad58dceb36f698dee9 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 15:29:20 +0200 Subject: [PATCH 02/35] check if repository exists before cloning --- html/install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/html/install.sh b/html/install.sh index 7cbeb29f..78d3c49d 100644 --- a/html/install.sh +++ b/html/install.sh @@ -6,8 +6,12 @@ ENV_PATH=/home/paint/venv sudo apt-get update sudo apt-get -y install git -# Clone repository. -git clone https://github.com/ARTIST-Association/PAINT.git $PAINT_ROOT +# Check if repository exists, if not clone, if it exists pull. +if [ ! -d "$PAINT_ROOT" ]; then + git clone https://github.com/ARTIST-Association/PAINT.git $PAINT_ROOT +else + git pull +fi # Navigate to repository and create virtual environment if it doesn't exist yet. cd $PAINT_ROOT From 7ed649289d03c26e055eca2d4f5a215f0d808e5f Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 15:29:44 +0200 Subject: [PATCH 03/35] check if repository exists before cloning --- html/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/html/install.sh b/html/install.sh index 78d3c49d..5c0947b1 100644 --- a/html/install.sh +++ b/html/install.sh @@ -10,6 +10,7 @@ sudo apt-get -y install git if [ ! -d "$PAINT_ROOT" ]; then git clone https://github.com/ARTIST-Association/PAINT.git $PAINT_ROOT else + cd $PAINT_ROOT git pull fi From 2f62eacbd66cc65ace3cdfe2a915b62801e4c897 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 15:32:36 +0200 Subject: [PATCH 04/35] update cd commands --- html/install.sh | 4 ++-- html/run.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/html/install.sh b/html/install.sh index 5c0947b1..9d4a13c5 100644 --- a/html/install.sh +++ b/html/install.sh @@ -10,12 +10,12 @@ sudo apt-get -y install git if [ ! -d "$PAINT_ROOT" ]; then git clone https://github.com/ARTIST-Association/PAINT.git $PAINT_ROOT else - cd $PAINT_ROOT + cd "${PAINT_ROOT}" || exit 1 git pull fi # Navigate to repository and create virtual environment if it doesn't exist yet. -cd $PAINT_ROOT +cd "${PAINT_ROOT}" || exit 1 if [ ! -d "$ENV_PATH" ]; then python3 -m venv $ENV_PATH fi diff --git a/html/run.sh b/html/run.sh index bc8c34a4..bc334920 100644 --- a/html/run.sh +++ b/html/run.sh @@ -6,7 +6,7 @@ ENV_PATH=/home/paint/venv source $ENV_PATH/bin/activate # Navigate to html directory. -cd $PAINT_ROOT/html +cd ${PAINT_ROOT}/html || exit 1 # Start flask application. flask run & From 0d9e10c5e6f00e45b11ee9ac8f183d7a279b893b Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 15:34:10 +0200 Subject: [PATCH 05/35] Make executable --- html/install.sh | 0 html/run.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 html/install.sh mode change 100644 => 100755 html/run.sh diff --git a/html/install.sh b/html/install.sh old mode 100644 new mode 100755 diff --git a/html/run.sh b/html/run.sh old mode 100644 new mode 100755 From 965d0c5ee3050a1af05a2edc04ecb84dd79afd83 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 15:37:50 +0200 Subject: [PATCH 06/35] install venv --- html/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/install.sh b/html/install.sh index 9d4a13c5..2fe5043d 100755 --- a/html/install.sh +++ b/html/install.sh @@ -4,7 +4,7 @@ ENV_PATH=/home/paint/venv # Install git. sudo apt-get update -sudo apt-get -y install git +sudo apt-get -y install git python3-venv # Check if repository exists, if not clone, if it exists pull. if [ ! -d "$PAINT_ROOT" ]; then From 8caf2e70f667b4b4c105195acc831fe4ededa88c Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 15:40:52 +0200 Subject: [PATCH 07/35] include upgrade for pip command --- html/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/install.sh b/html/install.sh index 2fe5043d..d6228239 100755 --- a/html/install.sh +++ b/html/install.sh @@ -25,4 +25,4 @@ source $ENV_PATH/bin/activate pip install --upgrade pip # Install dependencies. -pip install . +pip install --upgrade . From 48485eb63d6f38510fa7e05fab0d0fb87ea6e01c Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 15:50:46 +0200 Subject: [PATCH 08/35] add waitress dependency --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a4a4a236..6bf25e20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,8 @@ dependencies = [ "openpyxl", "Flask", "pystac", - "opencv-python" + "opencv-python", + "waitress" ] [project.optional-dependencies] From 91968ec41075a6cf199c981c8861fa1d2f443a2f Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 16:01:10 +0200 Subject: [PATCH 09/35] switch start to waitress --- html/wsgi.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/html/wsgi.py b/html/wsgi.py index d35d4f68..95a630de 100644 --- a/html/wsgi.py +++ b/html/wsgi.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from flask import Flask, render_template +from waitress import serve app = Flask(__name__) @@ -97,4 +98,4 @@ def resources() -> str: if __name__ == "__main__": - app.run() + serve(app, host="127.0.0.1", port=8000) From 03dc0175bf27ab1dd9ef8ad89dc5b6459e7b381c Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 16:01:26 +0200 Subject: [PATCH 10/35] fix start of flast application --- html/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/run.sh b/html/run.sh index bc334920..5ba2d1de 100755 --- a/html/run.sh +++ b/html/run.sh @@ -9,4 +9,4 @@ source $ENV_PATH/bin/activate cd ${PAINT_ROOT}/html || exit 1 # Start flask application. -flask run & +python wsgi.py & From a2ff4f1d6eb9e57f5a2bc68871cace093b557a71 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 17:21:50 +0200 Subject: [PATCH 11/35] include apache and enable modules --- html/install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/html/install.sh b/html/install.sh index d6228239..f04a0d46 100755 --- a/html/install.sh +++ b/html/install.sh @@ -4,7 +4,11 @@ ENV_PATH=/home/paint/venv # Install git. sudo apt-get update -sudo apt-get -y install git python3-venv +sudo apt-get -y install apache2 git python3-venv + +# Enable apache proxy. +sudo a2enmod proxy +sudo a2enmod proxy_http # Check if repository exists, if not clone, if it exists pull. if [ ! -d "$PAINT_ROOT" ]; then From 7c425ef1b610e8ef9e7fab1359407be318bc84b0 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 30 Sep 2024 17:22:11 +0200 Subject: [PATCH 12/35] include server restart --- html/run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/html/run.sh b/html/run.sh index 5ba2d1de..d9ef504a 100755 --- a/html/run.sh +++ b/html/run.sh @@ -10,3 +10,6 @@ cd ${PAINT_ROOT}/html || exit 1 # Start flask application. python wsgi.py & + +# Restart apache. +sudo systemctl restart apache2 From 645ac4b263fab5d4bd8a393963267c749a0b7cad Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Wed, 2 Oct 2024 16:49:41 +0200 Subject: [PATCH 13/35] quick commit to save progress --- html/install.sh | 2 ++ html/paint_domain-le-ssl.conf | 21 +++++++++++++++++++++ html/paint_domain.conf | 21 +++++++++++++++++++++ html/run.sh | 4 ++++ 4 files changed, 48 insertions(+) create mode 100644 html/paint_domain-le-ssl.conf create mode 100644 html/paint_domain.conf diff --git a/html/install.sh b/html/install.sh index f04a0d46..58e16023 100755 --- a/html/install.sh +++ b/html/install.sh @@ -9,6 +9,8 @@ sudo apt-get -y install apache2 git python3-venv # Enable apache proxy. sudo a2enmod proxy sudo a2enmod proxy_http +sudo a2enmod alias +sudo a2enmod cache # Check if repository exists, if not clone, if it exists pull. if [ ! -d "$PAINT_ROOT" ]; then diff --git a/html/paint_domain-le-ssl.conf b/html/paint_domain-le-ssl.conf new file mode 100644 index 00000000..c9c1b22e --- /dev/null +++ b/html/paint_domain-le-ssl.conf @@ -0,0 +1,21 @@ + + + ServerAdmin markus.goetz@kit.edu + ServerName paint-database.org + ProxyPass /WRI1030197 ! + Alias /WRI1030197 "/mnt/lsdf/WRI1030197/" + + Options Indexes FollowSymLinks + Require all granted + AddDefaultCharset UTF-8 + IndexOptions FancyIndexing IconsAreLinks + + ProxyPass / http://127.0.0.1:8000/ + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + ServerAlias paint-database.org + Include /etc/letsencrypt/options-ssl-apache.conf + SSLCertificateFile /etc/letsencrypt/live/paint-database.org/fullchain.pem + SSLCertificateKeyFile /etc/letsencrypt/live/paint-database.org/privkey.pem + + diff --git a/html/paint_domain.conf b/html/paint_domain.conf new file mode 100644 index 00000000..8e4ef053 --- /dev/null +++ b/html/paint_domain.conf @@ -0,0 +1,21 @@ + + ServerAdmin markus.goetz@kit.edu + ServerName paint-database.org + ServerAlias paint-database.org + ProxyPass /WRI1030197 ! + Alias /WRI1030197 "/mnt/lsdf/WRI1030197/" + + Options Indexes FollowSymLinks + Require all granted + AddDefaultCharset UTF-8 + IndexOptions FancyIndexing IconsAreLinks + + ProxyPass / http://127.0.0.1:8000/ + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + RewriteEngine on + RewriteCond %{SERVER_NAME} =paint.datamanager.kit.edu [OR] + RewriteCond %{SERVER_NAME} =www.paint-database.org [OR] + RewriteCond %{SERVER_NAME} =paint-database.org + RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] + diff --git a/html/run.sh b/html/run.sh index d9ef504a..3b1c3122 100755 --- a/html/run.sh +++ b/html/run.sh @@ -1,6 +1,8 @@ #!/bin/bash PAINT_ROOT=/home/paint/PAINT ENV_PATH=/home/paint/venv +AVAILABLE_PATH=/etc/apache2/sites-available +ENABLED_PATH=/etc/apache2/sites-enabled # Activate virtual environment. source $ENV_PATH/bin/activate @@ -8,6 +10,8 @@ source $ENV_PATH/bin/activate # Navigate to html directory. cd ${PAINT_ROOT}/html || exit 1 +# Copy configuration files to correct folder +cp # Start flask application. python wsgi.py & From be3abc22d0fb0ee8258991fb141b89a50570f19f Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Wed, 2 Oct 2024 17:52:57 +0200 Subject: [PATCH 14/35] fix run script --- html/run.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/html/run.sh b/html/run.sh index 3b1c3122..f3f060f2 100755 --- a/html/run.sh +++ b/html/run.sh @@ -10,8 +10,14 @@ source $ENV_PATH/bin/activate # Navigate to html directory. cd ${PAINT_ROOT}/html || exit 1 -# Copy configuration files to correct folder -cp +# Copy configuration files to correct folder. +cp paint_domain.conf $AVAILABLE_PATH/paint_domain.conf +cp paint_domain-le-ssl.conf $AVAILABLE_PATH/paint_domain-le-ssl.conf + +# Create symlinks in enabled folder. +ln -sf $AVAILABLE_PATH/paint_domain.conf $ENABLED_PATH/paint_domain.conf +ln -sf $AVAILABLE_PATH/paint_domain-le-ssl.conf $ENABLED_PATH/paint_domain-le-ssl.conf + # Start flask application. python wsgi.py & From 75420d2155b6e8e160b5369078824667c778ff23 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Wed, 2 Oct 2024 17:54:37 +0200 Subject: [PATCH 15/35] include sudo rights --- html/run.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/html/run.sh b/html/run.sh index f3f060f2..a0d9889e 100755 --- a/html/run.sh +++ b/html/run.sh @@ -11,12 +11,12 @@ source $ENV_PATH/bin/activate cd ${PAINT_ROOT}/html || exit 1 # Copy configuration files to correct folder. -cp paint_domain.conf $AVAILABLE_PATH/paint_domain.conf -cp paint_domain-le-ssl.conf $AVAILABLE_PATH/paint_domain-le-ssl.conf +sudo cp paint_domain.conf $AVAILABLE_PATH/paint_domain.conf +sudo cp paint_domain-le-ssl.conf $AVAILABLE_PATH/paint_domain-le-ssl.conf # Create symlinks in enabled folder. -ln -sf $AVAILABLE_PATH/paint_domain.conf $ENABLED_PATH/paint_domain.conf -ln -sf $AVAILABLE_PATH/paint_domain-le-ssl.conf $ENABLED_PATH/paint_domain-le-ssl.conf +sudo ln -sf $AVAILABLE_PATH/paint_domain.conf $ENABLED_PATH/paint_domain.conf +sudo ln -sf $AVAILABLE_PATH/paint_domain-le-ssl.conf $ENABLED_PATH/paint_domain-le-ssl.conf # Start flask application. python wsgi.py & From 222767ad5a6572d8214688e6bced2060300466b1 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 7 Oct 2024 15:06:26 +0200 Subject: [PATCH 16/35] include icon alias --- html/paint_domain-le-ssl.conf | 6 ++++++ html/paint_domain.conf | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/html/paint_domain-le-ssl.conf b/html/paint_domain-le-ssl.conf index c9c1b22e..f86afec0 100644 --- a/html/paint_domain-le-ssl.conf +++ b/html/paint_domain-le-ssl.conf @@ -2,6 +2,12 @@ ServerAdmin markus.goetz@kit.edu ServerName paint-database.org + Alias /icons/ "/usr/share/apache2/icons/" + + Options Indexes MultiViews + AllowOverride None + Require all granted + ProxyPass /WRI1030197 ! Alias /WRI1030197 "/mnt/lsdf/WRI1030197/" diff --git a/html/paint_domain.conf b/html/paint_domain.conf index 8e4ef053..05e9c1d0 100644 --- a/html/paint_domain.conf +++ b/html/paint_domain.conf @@ -2,6 +2,12 @@ ServerAdmin markus.goetz@kit.edu ServerName paint-database.org ServerAlias paint-database.org + Alias /icons/ "/usr/share/apache2/icons/" + + Options Indexes MultiViews + AllowOverride None + Require all granted + ProxyPass /WRI1030197 ! Alias /WRI1030197 "/mnt/lsdf/WRI1030197/" From 7e07e289571d3c14ccfcc8493860e26514b96ac1 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 7 Oct 2024 15:07:30 +0200 Subject: [PATCH 17/35] include kill command for script --- html/run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/html/run.sh b/html/run.sh index a0d9889e..7e19ac5b 100755 --- a/html/run.sh +++ b/html/run.sh @@ -18,6 +18,9 @@ sudo cp paint_domain-le-ssl.conf $AVAILABLE_PATH/paint_domain-le-ssl.conf sudo ln -sf $AVAILABLE_PATH/paint_domain.conf $ENABLED_PATH/paint_domain.conf sudo ln -sf $AVAILABLE_PATH/paint_domain-le-ssl.conf $ENABLED_PATH/paint_domain-le-ssl.conf +# Kill flask application. +kill $(ps aux | grep '[p]ython wsgi.py' | awk '{print $2}') + # Start flask application. python wsgi.py & From 4891b356be66f123a0382361cae200cba95255ae Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 7 Oct 2024 15:11:25 +0200 Subject: [PATCH 18/35] fix icon alias --- html/paint_domain-le-ssl.conf | 1 + html/paint_domain.conf | 1 + 2 files changed, 2 insertions(+) diff --git a/html/paint_domain-le-ssl.conf b/html/paint_domain-le-ssl.conf index f86afec0..d0c8a443 100644 --- a/html/paint_domain-le-ssl.conf +++ b/html/paint_domain-le-ssl.conf @@ -7,6 +7,7 @@ Options Indexes MultiViews AllowOverride None Require all granted + Allow from all ProxyPass /WRI1030197 ! Alias /WRI1030197 "/mnt/lsdf/WRI1030197/" diff --git a/html/paint_domain.conf b/html/paint_domain.conf index 05e9c1d0..e4c6654b 100644 --- a/html/paint_domain.conf +++ b/html/paint_domain.conf @@ -7,6 +7,7 @@ Options Indexes MultiViews AllowOverride None Require all granted + Allow from all ProxyPass /WRI1030197 ! Alias /WRI1030197 "/mnt/lsdf/WRI1030197/" From b225e4cf4db995a4f23fb117b2b7a7e9b5adeb81 Mon Sep 17 00:00:00 2001 From: Kaleb Phipps Date: Mon, 7 Oct 2024 15:30:46 +0200 Subject: [PATCH 19/35] includ spinner when loading data --- html/templates/base.html | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/html/templates/base.html b/html/templates/base.html index 9b3bfb84..99c2df80 100644 --- a/html/templates/base.html +++ b/html/templates/base.html @@ -14,6 +14,12 @@ +
+
+ Loading... +
+
+