diff --git a/README.md b/README.md index 800cd60..860a02e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config/config.conf_sample b/config/config.conf_sample index ff0946e..4d38db9 100644 --- a/config/config.conf_sample +++ b/config/config.conf_sample @@ -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 diff --git a/install.sh b/install.sh index 8bd4caf..6dfe887 100755 --- a/install.sh +++ b/install.sh @@ -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" diff --git a/wrapper.sh b/wrapper.sh index 4651e89..f97da9c 100644 --- a/wrapper.sh +++ b/wrapper.sh @@ -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[@]}" "${@}"