From 6b3f536681c86296526786fc80aa4737e1d42b20 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Wed, 28 Dec 2022 07:40:44 +0100 Subject: [PATCH] fixes - fixed app dir - fixed missing readme and version file - keep config on update/remove --- .gitlab-ci.yml | 5 +++-- DEBIAN/postinst | 8 +++++--- DEBIAN/postrm | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e60da24..0c34ce4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,9 +12,10 @@ build:debian: - mkdir build # copy install instructions - cp -r DEBIAN build/ - # copy app + # copy app into "/usr/share/fastapi-dls" as "/usr/share/fastapi-dls/app" & copy README.md and version.env - mkdir -p build/usr/share/ - - cp -r app build/usr/share/fastapi-dls + - cp -r app build/usr/share/fastapi-dls/ + - cp README.md version.env build/usr/share/fastapi-dls # create conf file - mkdir -p build/etc/fastapi-dls - touch build/etc/fastapi-dls/env diff --git a/DEBIAN/postinst b/DEBIAN/postinst index e4e8873..77bf587 100644 --- a/DEBIAN/postinst +++ b/DEBIAN/postinst @@ -1,5 +1,6 @@ #!/bin/bash +WORKING_DIR=/usr/share/fastapi-dls CONFIG_DIR=/etc/fastapi-dls echo "> Create config directory ..." @@ -15,12 +16,12 @@ After=network.target User=www-data Group=www-data AmbientCapabilities=CAP_NET_BIND_SERVICE -WorkingDirectory=/usr/share/fastapi-dls +WorkingDirectory=$WORKING_DIR EnvironmentFile=$CONFIG_DIR/env ExecStart=uvicorn main:app \\ --env-file /etc/fastapi-dls/env \\ --host \$DLS_URL --port \$DLS_PORT \\ - --app-dir /usr/share/fastapi-dls \\ + --app-dir $WORKING_DIR/app \\ --ssl-keyfile /etc/fastapi-dls/webserver.key \\ --ssl-certfile /etc/fastapi-dls/webserver.crt \\ --proxy-headers @@ -41,7 +42,7 @@ cat <$CONFIG_DIR/env DLS_URL=127.0.0.1 DLS_PORT=443 LEASE_EXPIRE_DAYS=90 -DATABASE=sqlite:////usr/share/fastapi-dls/db.sqlite +DATABASE=sqlite:///$CONFIG_DIR/db.sqlite INSTANCE_KEY_RSA=$CONFIG_DIR/instance.private.pem INSTANCE_KEY_PUB=$CONFIG_DIR/instance.public.pem @@ -77,6 +78,7 @@ if [[ -f $CONFIG_DIR/webserver.key ]]; then fi chown -R www-data:www-data $CONFIG_DIR/* +chown -R www-data:www-data $WORKING_DIR cat < Removing config directory." - rm -r /etc/fastapi-dls + echo "> Config directory not empty, please remove manually." + # rm -r /etc/fastapi-dls fi if [[ -f /etc/systemd/system/fastapi-dls.service ]]; then