Add install and wrapper

This commit is contained in:
Antonio J. Delgado 2024-11-16 23:08:53 +02:00
parent d50a29b21c
commit e7e99825ed
3 changed files with 54 additions and 3 deletions

View file

@ -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
```

29
skeleton/install.sh Executable file
View file

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

14
skeleton/wrapper.sh Normal file
View file

@ -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[@]}" "${@}"