logmonitor/etc/cont-init.d/10_syslog_ng

65 lines
1.8 KiB
Text
Raw Permalink Normal View History

2021-01-28 07:10:11 -05:00
#!/usr/bin/with-contenv /bin/sh
CONFD=/etc/syslog-ng/conf.d
TEMPLATES=/etc/syslog-ng/templates
# Setup the SQL destination if SQL_* environment variables are set
2021-01-28 07:10:11 -05:00
if $(env | grep -q SQL); then
if [ -z ${SQL_PORT+set} ]; then
SQL_PORT=3306
fi
cp -f ${TEMPLATES}/d_sql.template ${CONFD}/d_sql.conf
sed -i "s/SQL_HOST/${SQL_HOST}/" ${CONFD}/d_sql.conf
sed -i "s/SQL_PORT/${SQL_PORT}/" ${CONFD}/d_sql.conf
sed -i "s/SQL_USER/${SQL_USER}/" ${CONFD}/d_sql.conf
sed -i "s/SQL_PASSWORD/${SQL_PASSWORD}/" ${CONFD}/d_sql.conf
sed -i "s/SQL_DATABASE/${SQL_DATABASE}/" ${CONFD}/d_sql.conf
# otherwise make sure the SQL destination is disabled
elif [ -f ${CONFD}/d_sql.conf ]; then
rm -f ${CONFD}/d_sql.conf
fi
# Setup local template
DO_ENABLE_LOCAL=false
2021-01-28 07:10:11 -05:00
if [ ! -z ${ENABLE_LOCAL+set} ]; then
case $ENABLE_LOCAL in
true|True|TRUE|yes|Yes|YES|1|on|On|ON)
DO_ENABLE_LOCAL=true
;;
esac
fi
if ${DO_ENABLE_LOCAL}; then
echo "Logging to Local ENABLED."
2021-01-28 07:10:11 -05:00
cp --remove-destination ${TEMPLATES}/d_local.template ${CONFD}/d_local.conf
2021-01-28 07:10:11 -05:00
else # otherwise make sure it's disabled
echo "Logging to Local DISABLED."
2021-01-28 07:10:11 -05:00
rm -f ${CONFD}/d_local.conf
fi
# Setup discord template
DO_ENABLE_DISCORD=false
if [ ! -z ${ENABLE_DISCORD+set} ]; then
case $ENABLE_DISCORD in
true|True|TRUE|yes|Yes|YES|1|on|On|ON)
DO_ENABLE_DISCORD=true
;;
esac
fi
if ${DO_ENABLE_DISCORD}; then
echo "Logging to Discord ENABLED."
cp --remove-destination ${TEMPLATES}/d_discord.template ${CONFD}/d_discord.conf
if [ -z ${ALLOWED_SUBNET+set} ]; then
ALLOWED_SUBNET="10.0.0.0/24"
fi
echo "Allowed network subnet is ${ALLOWED_SUBNET}"
sed -i "s:ALLOWED_SUBNET:${ALLOWED_SUBNET}:" ${CONFD}/d_discord.conf
else # otherwise make sure it's disabled
echo "Logging to Discord DISABLED."
rm -f ${CONFD}/d_discord.conf
fi