Add wrapper script
This commit is contained in:
parent
75115a3ad5
commit
76a0a5101d
6 changed files with 57 additions and 5 deletions
29
install.sh
Executable file
29
install.sh
Executable 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 [ ! -e "${HOME}/.config/ovh_dns_ensure.conf" ]; then
|
||||||
|
touch "${HOME}/.config/ovh_dns_ensure.conf"
|
||||||
|
fi
|
||||||
|
chmod go-rwx "${HOME}/.config/ovh_dns_ensure.conf"
|
||||||
|
|
||||||
|
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
sed "s#__src_folder__#${script_dir}#g" wrapper.sh > "${destination}/ovh_dns_ensure.sh"
|
||||||
|
chmod +x "${destination}/ovh_dns_ensure.sh"
|
|
@ -1,9 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
if [ ! -d "$(dirname "${0}")/.venv" ]; then
|
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
python -m venv "$(dirname "${0}")/.venv"
|
if [ ! -d "${script_dir}/.venv" ]; then
|
||||||
|
python -m venv "$script_dir/.venv"
|
||||||
fi
|
fi
|
||||||
# shellcheck disable=1091
|
# shellcheck disable=1091
|
||||||
source "$(dirname "${0}")/.venv/bin/activate"
|
source "$script_dir/.venv/bin/activate"
|
||||||
pip install -r "$(dirname "${0}")/requirements.txt" > /dev/null
|
pip install -r "$script_dir/requirements.txt" > /dev/null
|
||||||
pip install "$(dirname "${0}")/" > /dev/null
|
pip install "$script_dir/" > /dev/null
|
||||||
ovh_dns_ensure.py "${@}"
|
ovh_dns_ensure.py "${@}"
|
||||||
|
|
0
ovh_dns_ensure/__init__.py
Normal file → Executable file
0
ovh_dns_ensure/__init__.py
Normal file → Executable file
0
ovh_dns_ensure/ovh_dns_ensure.py
Normal file → Executable file
0
ovh_dns_ensure/ovh_dns_ensure.py
Normal file → Executable file
0
setup.py
Normal file → Executable file
0
setup.py
Normal file → Executable file
22
wrapper.sh
Executable file
22
wrapper.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [ -z "${HOME}" ]; then
|
||||||
|
if [ "$(whoami)" == "root" ]; then
|
||||||
|
HOME="/root"
|
||||||
|
else
|
||||||
|
HOME=$(grep "$(whoami)" /etc/passwd | awk 'BEGIN {FS=":"} {print($6)}')
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
CONFIG_FILE="${HOME}/.config/ovh_dns_ensure.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__/ovh_dns_ensure.sh" "${config[@]}" "${@}"
|
Loading…
Reference in a new issue