Add install wrapper and config

This commit is contained in:
Antonio J. Delgado 2024-11-16 23:06:35 +02:00
parent 3b3944c893
commit 5197392e18
4 changed files with 23 additions and 3 deletions

View file

@ -21,6 +21,8 @@ To install system-wide:
sudo ./install.sh --destination /usr/local/bin
```
Change your configuration file in "${HOME}/.config/nc_password_client.conf" (see the example in the config folder).
## Usage
```bash

View file

@ -1,3 +1,5 @@
debug_level='DEBUG'
log_file='/config/nc_password_client.log'
# list_of_parameters=['foo', 'bar']
host="nc.example.org"
user="jhon_doe"
api_token="12345-67890-ABCDE-FGHIJK"
timeout=20

View file

@ -19,6 +19,11 @@ do
esac
done
if [ ! -x "${HOME}/.config/nc_password_client.conf" ]; then
touch "${HOME}/.config/nc_password_client.conf"
fi
chmod go-rwx "${HOME}/.config/nc_password_client.conf"
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
sed "s#__src_folder__#${script_dir}#g" wrapper.sh > "${destination}/nc_password_client.sh"
chmod +x "${destination}/nc_password_client.sh"

View file

@ -1,3 +1,14 @@
#!/bin/bash
CONFIG_FILE="${HOME}/.config/nc_password_client.conf"
cd "__src_folder__" || exit 1
"__src_folder__/nc_password_client.sh" "${@}"
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__/nc_password_client.sh" "${config[@]}" "${@}"