home · contact · privacy
Add install and startup scripts. master
authorChristian Heller <c.heller@plomlompom.de>
Mon, 10 Feb 2025 15:51:20 +0000 (16:51 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 10 Feb 2025 15:51:20 +0000 (16:51 +0100)
sh/install.sh [new file with mode: 0755]
sh/run [new file with mode: 0644]

diff --git a/sh/install.sh b/sh/install.sh
new file mode 100755 (executable)
index 0000000..1127276
--- /dev/null
@@ -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 (file)
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" $@