Add wrappers
This commit is contained in:
parent
24d68684de
commit
76e25393d0
3 changed files with 61 additions and 0 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/mastodon_email_bridge.conf" ]; then
|
||||||
|
touch "${HOME}/.config/mastodon_email_bridge.conf"
|
||||||
|
fi
|
||||||
|
chmod go-rwx "${HOME}/.config/mastodon_email_bridge.conf"
|
||||||
|
|
||||||
|
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
sed "s#__src_folder__#${script_dir}#g" wrapper.sh > "${destination}/mastodon_email_bridge.sh"
|
||||||
|
chmod +x "${destination}/mastodon_email_bridge.sh"
|
10
mastodon_email_bridge.sh
Executable file
10
mastodon_email_bridge.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
|
||||||
|
mastodon_email_bridge.py "${@}"
|
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/mastodon_email_bridge.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__/mastodon_email_bridge.sh" "${config[@]}" "${@}"
|
Loading…
Reference in a new issue