add cron dbp script

This commit is contained in:
Mario Fetka 2023-01-08 11:57:13 +01:00
parent f47f9fcdf9
commit 7ab42ae32e
3 changed files with 130 additions and 0 deletions

91
dbp/cron.sh Executable file
View File

@ -0,0 +1,91 @@
#!/bin/bash
while getopts ':f:h' opt; do
case "$opt" in
f)
INIFILE="$OPTARG"
;;
h)
echo "Usage: $(basename $0) [-f dbp.ini]"
exit 0
;;
:)
echo -e "option requires an argument.\nUsage: $(basename $0) [-f dbp.ini]"
exit 1
;;
?)
echo -e "Invalid command option.\nUsage: $(basename $0) [-f dpb.ini]"
exit 1
;;
esac
done
shift "$(($OPTIND -1))"
MYSTIC_DIR=`${MYSTIC_DIR}/inimod r ${INIFILE} -S GeneralDbP -k BaseDir --silent`
TMP_DIR=$(mktemp -d)
MIS_ENABLE=`${MYSTIC_DIR}/inimod r ${INIFILE} -S GeneralDbP -k MisLog --silent`
MUTIL_ENABLE=`${MYSTIC_DIR}/inimod r ${INIFILE} -S GeneralDbP -k MutilLog --silent`
ERROR_ENABLE=`${MYSTIC_DIR}/inimod r ${INIFILE} -S GeneralDbP -k ErrorLog --silent`
MRCCHAT_ENABLE=`${MYSTIC_DIR}/inimod r ${INIFILE} -S GeneralDbP -k MrcChatLog --silent`
NODE_ENABLE=`${MYSTIC_DIR}/inimod r ${INIFILE} -S GeneralDbP -k NodeLog --silent`
IP2L_ENABLE=`${MYSTIC_DIR}/inimod r ${INIFILE} -S GeneralDbP -k Ip2Location --silent`
IP2L_TOKEN=`${MYSTIC_DIR}/inimod r ${INIFILE} -S Ip2Location -k Token --silent`
IP2L_DB=`${MYSTIC_DIR}/inimod r ${INIFILE} -S Ip2Location -k Database --silent`
YESTERDAY=$(date '+%Y%m%d' -d "-1days")
NOW=$(date '+%Y%m%d')
TOMORROW=$(date '+%Y%m%d' -d "+1days")
if [ $MIS_ENABLE = "true" ]; then
touch ${MYSTIC_DIR}/logs/mis.${NOW}.log
touch ${MYSTIC_DIR}/logs/mis.${TOMORROW}.log
ln -sf mis.${NOW}.log ${MYSTIC_DIR}/logs/mis.log
[ -f /${MYSTIC_DIR}/logs/mis.${YESTERDAY}.log ] && gzip -9 ${MYSTIC_DIR}/logs/mis.${YESTERDAY}.log
fi
if [ $MUTIL_ENABLE = "true" ]; then
touch ${MYSTIC_DIR}/logs/mutil.${NOW}.log
touch ${MYSTIC_DIR}/logs/mutil.${TOMORROW}.log
ln -sf mutil.${NOW}.log ${MYSTIC_DIR}/logs/mutil.log
[ -f /${MYSTIC_DIR}/logs/mutil.${YESTERDAY}.log ] && gzip -9 ${MYSTIC_DIR}/logs/mutil.${YESTERDAY}.log
fi
if [ $ERROR_ENABLE = "true" ]; then
touch ${MYSTIC_DIR}/logs/errors.${NOW}.log
touch ${MYSTIC_DIR}/logs/errors.${TOMORROW}.log
ln -sf errors.${NOW}.log ${MYSTIC_DIR}/logs/errors.log
[ -f /${MYSTIC_DIR}/logs/errors.${YESTERDAY}.log ] && gzip -9 ${MYSTIC_DIR}/logs/errors.${YESTERDAY}.log
fi
if [ $MRCCHAT_ENABLE = "true" ]; then
touch ${MYSTIC_DIR}/logs/mrcchat.${NOW}.log
touch ${MYSTIC_DIR}/logs/mrcchat.${TOMORROW}.log
ln -sf ../../logs/mrcchat.${NOW}.log ${MYSTIC_DIR}/data/mrc/mrcchat.log
ln -sf mrcchat.${NOW}.log ${MYSTIC_DIR}/logs/mrcchat.log
[ -f /${MYSTIC_DIR}/logs/mrcchat.${YESTERDAY}.log ] && gzip -9 ${MYSTIC_DIR}/logs/mrcchat.${YESTERDAY}.log
fi
if [ $NODE_ENABLE = "true" ]; then
for i in {0..10}
do
touch ${MYSTIC_DIR}/logs/node${i}.${NOW}.log
touch ${MYSTIC_DIR}/logs/node${i}.${TOMORROW}.log
ln -sf node${i}.${NOW}.log ${MYSTIC_DIR}/logs/node${i}.log
[ -f ${MYSTIC_DIR}/logs/node${i}.${YESTERDAY}.log ] && gzip -9 ${MYSTIC_DIR}/logs/node${i}.${YESTERDAY}.log
done
fi
if [ $IP2L_ENABLE = "true" ]; then
${MYSTIC_DIR}/ip2location -package ${IP2L_TOKEN} -token ${IP2L_TOKEN} -output ${TMP_DIR}/IP2LOCATION.ZIP
unzip -o ${TMP_DIR}/IP2LOCATION.ZIP -x *.TXT -d ${MYSTIC_DIR}/data
unzip -o ${TMP_DIR}/IP2LOCATION.ZIP -x *.BIN -d ${MYSTIC_DIR}/docs
mv ${MYSTIC_DIR}/data/IP2LOCATION-*.BIN ${MYSTIC_DIR}/data/iplocation.bin
rm -rf ${TMP_DIR}
fi
exit 0

29
dbp/dbp.ini Normal file
View File

@ -0,0 +1,29 @@
[GeneralDbP]
Ip2Location=false
MisLog=false
ErrorLog=false
NodeLog=false
MutilLog=false
MrcChatLog=false
BanUnbanIP=false
BaseDir=@MYSTIC_DIR@
[Ip2Location]
; Pleas Create an Free Account at https://lite.ip2location.com/ and fill in the Token
; if you Buy the the Service you can CHange the Database to reflect your purchase.
Token=PleasePutTokenHere
Database=DB1LITE
[MisLog]
[ErrorLog]
[NodeLog]
[MutilLog]
[MrcChatLog]
[BanUnbanIP]

10
dbp/install.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
MYSTIC_DIR="$1"
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" cron.sh > ${MYSTIC_DIR}/cron
chmod +x ${MYSTIC_DIR}/cron
#sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" mis-stop.sh > ${MYSTIC_DIR}/mis-stop
#chmod +x ${MYSTIC_DIR}/mis-stop
sed -e "s!@MYSTIC_DIR@!${MYSTIC_DIR}!g" dbp.ini > ${MYSTIC_DIR}/dbp.ini