From e7e99825eda1bcf34962defd0fa52f72141eb526 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Sat, 16 Nov 2024 23:08:53 +0200 Subject: [PATCH] Add install and wrapper --- skeleton/README.md | 14 +++++++++++--- skeleton/install.sh | 29 +++++++++++++++++++++++++++++ skeleton/wrapper.sh | 14 ++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100755 skeleton/install.sh create mode 100644 skeleton/wrapper.sh diff --git a/skeleton/README.md b/skeleton/README.md index 863f5c8..cdf344c 100644 --- a/skeleton/README.md +++ b/skeleton/README.md @@ -6,10 +6,18 @@ ### Linux - ```bash -pip install . +To install for example in your ~/.local/bin folder: +```bash +./install.sh --destination ~/.local/bin ``` +To install system-wide: +```bash +sudo ./install.sh --destination /usr/local/bin +``` + +Change your configuration file in "${HOME}/.config/__project_codename__.conf" (see the example in the config folder). + ### Windows (from PowerShell) Ensure you have "C:\Users\${env:USERNAME}\AppData\Roaming\Python\Python${python_version}\Scripts\" in your Path environment variable. @@ -21,5 +29,5 @@ Ensure you have "C:\Users\${env:USERNAME}\AppData\Roaming\Python\Python${python_ ## Usage ```bash -__project_codename__.py [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters +__project_codename__.sh [--debug-level|-d CRITICAL|ERROR|WARNING|INFO|DEBUG|NOTSET] # Other parameters ``` diff --git a/skeleton/install.sh b/skeleton/install.sh new file mode 100755 index 0000000..ad29201 --- /dev/null +++ b/skeleton/install.sh @@ -0,0 +1,29 @@ +#!/bin/bash +destination="/usr/local/bin" +while [ $# -gt 0 ] +do + case "$1" in + "--help"|"-h"|"-?") + usage + exit 0 + ;; + "--destination"|"-d") + shift + destination="${1}" + shift + ;; + *) + echo "Ignoring unknwon parameter '${1}'" + shift + ;; + esac +done + +if [ ! -x "${HOME}/.config/__project_codename__.conf" ]; then + touch "${HOME}/.config/__project_codename__.conf" +fi +chmod go-rwx "${HOME}/.config/__project_codename__.conf" + +script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +sed "s#__src_folder__#${script_dir}#g" wrapper.sh > "${destination}/__project_codename__.sh" +chmod +x "${destination}/__project_codename__.sh" diff --git a/skeleton/wrapper.sh b/skeleton/wrapper.sh new file mode 100644 index 0000000..e661d30 --- /dev/null +++ b/skeleton/wrapper.sh @@ -0,0 +1,14 @@ +#!/bin/bash +CONFIG_FILE="${HOME}/.config/__project_codename__.conf" +cd "__src_folder__" || exit 1 +if [ -r "${CONFIG_FILE}" ]; then + perms=$(stat -c %A "${CONFIG_FILE}") + if [ "${perms:4:6}" != '------' ]; then + echo "Permissions too open for config file '${CONFIG_FILE}' ($perms). Remove all permissions to group and others." + exit 1 + fi + config=(--config "${CONFIG_FILE}") +else + config=() +fi +"__src_folder__/__project_codename__.sh" "${config[@]}" "${@}"