Add install wrapper and config
This commit is contained in:
parent
3b3944c893
commit
5197392e18
4 changed files with 23 additions and 3 deletions
|
@ -21,6 +21,8 @@ To install system-wide:
|
||||||
sudo ./install.sh --destination /usr/local/bin
|
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
|
## Usage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
debug_level='DEBUG'
|
debug_level='DEBUG'
|
||||||
log_file='/config/nc_password_client.log'
|
host="nc.example.org"
|
||||||
# list_of_parameters=['foo', 'bar']
|
user="jhon_doe"
|
||||||
|
api_token="12345-67890-ABCDE-FGHIJK"
|
||||||
|
timeout=20
|
||||||
|
|
|
@ -19,6 +19,11 @@ do
|
||||||
esac
|
esac
|
||||||
done
|
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 )
|
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
sed "s#__src_folder__#${script_dir}#g" wrapper.sh > "${destination}/nc_password_client.sh"
|
sed "s#__src_folder__#${script_dir}#g" wrapper.sh > "${destination}/nc_password_client.sh"
|
||||||
chmod +x "${destination}/nc_password_client.sh"
|
chmod +x "${destination}/nc_password_client.sh"
|
||||||
|
|
13
wrapper.sh
13
wrapper.sh
|
@ -1,3 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
CONFIG_FILE="${HOME}/.config/nc_password_client.conf"
|
||||||
cd "__src_folder__" || exit 1
|
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[@]}" "${@}"
|
||||||
|
|
Loading…
Reference in a new issue