Add installer
This commit is contained in:
parent
fdd2859d1d
commit
36a5418f8a
3 changed files with 61 additions and 0 deletions
10
image_classifier.sh
Executable file
10
image_classifier.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
if [ ! -d "${script_dir}/.venv" ]; then
|
||||
python -m venv "$script_dir/.venv"
|
||||
fi
|
||||
# shellcheck disable=1091
|
||||
source "$script_dir/.venv/bin/activate"
|
||||
pip install -r "$script_dir/requirements.txt" > /dev/null
|
||||
pip install "$script_dir/" > /dev/null
|
||||
backup_imap.py "${@}"
|
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/image_classifier.conf" ]; then
|
||||
touch "${HOME}/.config/image_classifier.conf"
|
||||
fi
|
||||
chmod go-rwx "${HOME}/.config/image_classifier.conf"
|
||||
|
||||
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
sed "s#__src_folder__#${script_dir}#g" wrapper.sh > "${destination}/image_classifier.sh"
|
||||
chmod +x "${destination}/image_classifier.sh"
|
22
wrapper.sh
Normal file
22
wrapper.sh
Normal 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/image_classifier.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__/image_classifier.sh" "${config[@]}" "${@}"
|
Loading…
Reference in a new issue