2019-05-01 12:29:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# file. multibot.sh
|
|
|
|
# description: run multiple telegram bots from one installation
|
|
|
|
#
|
2021-01-01 21:48:13 +00:00
|
|
|
#### $$VERSION$$ v1.21-pre-14-ga93dc56
|
2019-05-01 12:29:57 +00:00
|
|
|
|
|
|
|
if [ "${2}" = "" ] || [ "${2}" = "-h" ]; then
|
|
|
|
echo "Usage: $0 botname command"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
BOT="${1}"
|
2020-06-23 14:35:50 +00:00
|
|
|
[ "${#BOT}" -lt 5 ] && echo "Botname must have a minimum length of 5 characters" && exit 1
|
2019-05-01 12:29:57 +00:00
|
|
|
|
|
|
|
# where should the bots live?
|
2020-06-23 14:35:50 +00:00
|
|
|
# true in one dir, false in separate dirs
|
2019-05-01 12:29:57 +00:00
|
|
|
if true; then
|
|
|
|
# example for all in one bashbot dir
|
|
|
|
BINDIR="/usr/local/telegram-bot-bash"
|
|
|
|
ETC="${BINDIR}"
|
|
|
|
VAR="${BINDIR}"
|
|
|
|
|
|
|
|
else
|
2020-06-23 14:35:50 +00:00
|
|
|
# alternative linux like locations
|
2019-05-01 12:29:57 +00:00
|
|
|
BINDIR="/usr/local/bin"
|
2020-09-27 15:36:01 +00:00
|
|
|
ETC="/etc/bashbot"
|
|
|
|
VAR="/var/bashbot"
|
2019-05-01 12:29:57 +00:00
|
|
|
export BASHBOT_JSONSH="/usr/local/bin/JSON.sh"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set final ENV
|
|
|
|
export BASHBOT_ETC="${ETC}/${BOT}"
|
|
|
|
export BASHBOT_VAR="${VAR}/${BOT}"
|
|
|
|
|
|
|
|
# some checks
|
|
|
|
[ ! -d "${BINDIR}" ] && echo "Dir ${BINDIR} does not exist" && exit 1
|
|
|
|
[ ! -d "${BASHBOT_ETC}" ] && echo "Dir ${BASHBOT_ETC} does not exist" && exit 1
|
|
|
|
[ ! -d "${BASHBOT_VAR}" ] && echo "Dir ${BASHBOT_VAR} does not exist" && exit 1
|
2020-06-23 14:35:50 +00:00
|
|
|
[ ! -x "${BINDIR}/bashbot.sh" ] && echo "${BINDIR}/bashbot.sh not executable or does not exist" && exit 1
|
2019-05-01 12:29:57 +00:00
|
|
|
[ ! -r "${BASHBOT_ETC}/commands.sh" ] && echo "${BASHBOT_ETC}/commands.sh not readable or does not exist" && exit 1
|
|
|
|
[ ! -r "${BASHBOT_ETC}/mycommands.sh" ] && echo "${BASHBOT_ETC}/mycommands.sh not readable or does not exist" && exit 1
|
|
|
|
|
2019-05-01 12:36:34 +00:00
|
|
|
"${BINDIR}/bashbot.sh" "$2"
|