From 0bf94804e718fb4d41995dbfe9c6dc3315d366f2 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 10 Feb 2025 16:51:20 +0100
Subject: [PATCH] Add install and startup scripts.

---
 sh/install.sh | 16 ++++++++++++++++
 sh/run        | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100755 sh/install.sh
 create mode 100644 sh/run

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" $@
-- 
2.30.2