From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 10 Feb 2025 15:51:20 +0000 (+0100)
Subject: Add install and startup scripts.
X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/booking/static/foo.html?a=commitdiff_plain;h=0bf94804e718fb4d41995dbfe9c6dc3315d366f2;p=plomlib

Add install and startup scripts.
---

diff --git a/sh/install.sh b/sh/install.sh
new file mode 100755
index 0000000..1127276
--- /dev/null
+++ b/sh/install.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/sh
+set -e
+
+APP_NAME=$1
+
+PATH_APP_SHARE=~/.local/share/"${APP_NAME}"
+mkdir -p "${PATH_APP_SHARE}"
+cp -rL ./src/* "${PATH_APP_SHARE}/"
+
+PATH_LOCAL_BIN=~/.local/bin
+mkdir -p "${PATH_LOCAL_BIN}"
+PATH_TARGET_BIN="${PATH_LOCAL_BIN}/${APP_NAME}"
+cat plomlib/sh/run | sed "s/PLEASE_DO_REPLACE_ME/${APP_NAME}/g" > "${PATH_TARGET_BIN}"
+chmod u+x "${PATH_TARGET_BIN}"
+
+echo "Installed executable to ${PATH_TARGET_BIN}, app files to ${PATH_APP_SHARE}."
diff --git a/sh/run b/sh/run
new file mode 100644
index 0000000..a39612f
--- /dev/null
+++ b/sh/run
@@ -0,0 +1,19 @@
+#!/usr/bin/sh
+set -e
+
+APP_NAME=PLEASE_DO_REPLACE_ME
+
+PATH_APP_SHARE=~/.local/share/"${APP_NAME}"
+PATH_VENV="${PATH_APP_SHARE}/venv"
+
+python3 -m venv "${PATH_VENV}"
+. "${PATH_VENV}/bin/activate"
+
+if [ "$1" = "install_deps" ]; then
+    echo "Checking dependencies."
+    pip3 install -r "${PATH_APP_SHARE}/requirements.txt"
+    exit 0
+fi
+
+export PYTHONPATH="${PATH_APP_SHARE}:${PYTHONPATH}"
+python3 "${PATH_APP_SHARE}/run.py" $@