2020-11-08 13:40:45 +01:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2020-11-09 16:17:37 +01:00
|
|
|
|
|
|
|
USERNAME=telegram-bot-api
|
|
|
|
GROUPNAME=telegram-bot-api
|
|
|
|
|
2020-11-25 15:39:54 +01:00
|
|
|
chown ${USERNAME}:${GROUPNAME} "${TELEGRAM_WORK_DIR}" "${TELEGRAM_TEMP_DIR}"
|
|
|
|
|
2020-11-25 15:51:11 +01:00
|
|
|
chmod 700 "${TELEGRAM_TEMP_DIR}"
|
2020-11-08 13:40:45 +01:00
|
|
|
|
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
exec "${*}"
|
|
|
|
fi
|
|
|
|
|
2020-11-25 08:32:01 +01:00
|
|
|
DEFAULT_ARGS="--http-port 8081 --dir=${TELEGRAM_WORK_DIR} --temp-dir=${TELEGRAM_TEMP_DIR}"
|
2020-11-08 13:40:45 +01:00
|
|
|
CUSTOM_ARGS=""
|
|
|
|
|
2020-11-09 16:17:37 +01:00
|
|
|
if [ -n "$TELEGRAM_STAT" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --http-stat-port=8082"
|
|
|
|
fi
|
2020-12-15 17:43:20 +01:00
|
|
|
if [ -n "$TELEGRAM_STAT_HIDE_SENSIBLE_DATA" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --stats-hide-sensible-data"
|
|
|
|
fi
|
2020-11-08 13:40:45 +01:00
|
|
|
if [ -n "$TELEGRAM_FILTER" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --filter=$TELEGRAM_FILTER"
|
|
|
|
fi
|
|
|
|
if [ -n "$TELEGRAM_MAX_WEBHOOK_CONNECTIONS" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --max-webhook-connections=$TELEGRAM_MAX_WEBHOOK_CONNECTIONS"
|
|
|
|
fi
|
|
|
|
if [ -n "$TELEGRAM_VERBOSITY" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --verbosity=$TELEGRAM_VERBOSITY"
|
|
|
|
fi
|
|
|
|
if [ -n "$TELEGRAM_MAX_CONNECTIONS" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --max-connections=$TELEGRAM_MAX_CONNECTIONS"
|
|
|
|
fi
|
|
|
|
if [ -n "$TELEGRAM_PROXY" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --proxy=$TELEGRAM_PROXY"
|
|
|
|
fi
|
|
|
|
if [ -n "$TELEGRAM_LOCAL" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --local"
|
|
|
|
fi
|
2020-11-12 23:45:30 +01:00
|
|
|
if [ -n "$TELEGRAM_NO_FILE_LIMIT" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --no-file-limit"
|
|
|
|
fi
|
2020-12-12 00:45:36 +01:00
|
|
|
if [ -n "$TELEGRAM_ALLOW_USERS" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --allow-users"
|
|
|
|
fi
|
|
|
|
if [ -n "$TELEGRAM_ALLOW_USERS_REGISTRATION" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --allow-users-registration"
|
|
|
|
fi
|
2020-11-11 01:09:00 +01:00
|
|
|
if [ -n "$TELEGRAM_INSECURE" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --insecure"
|
|
|
|
fi
|
|
|
|
if [ -n "$TELEGRAM_RELATIVE" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} --relative"
|
|
|
|
fi
|
2020-11-11 19:45:15 +01:00
|
|
|
if [ -n "$TELEGRAM_MAX_BATCH" ]; then
|
|
|
|
CUSTOM_ARGS="${CUSTOM_ARGS} ---max-batch-operations=$TELEGRAM_MAX_BATCH"
|
|
|
|
fi
|
2020-11-25 08:32:01 +01:00
|
|
|
if [ -n "$TELEGRAM_LOGS" ]; then
|
|
|
|
CUSTOM_ARGS="$CUSTOM_ARGS --log=${TELEGRAM_LOGS}"
|
|
|
|
else
|
|
|
|
CUSTOM_ARGS="$CUSTOM_ARGS --log=/proc/1/fd/1"
|
|
|
|
fi
|
2020-11-08 13:40:45 +01:00
|
|
|
|
|
|
|
COMMAND="telegram-bot-api ${DEFAULT_ARGS}${CUSTOM_ARGS}"
|
|
|
|
|
|
|
|
echo "$COMMAND"
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
exec $COMMAND
|