Updated Scheduling exports with Mono & Crontab (markdown)

Yudi
2019-09-17 22:43:11 -03:00
parent 4cbf10c417
commit 77b98a964d

@@ -20,6 +20,7 @@ FILENAME=<name>
EXPORTDIRECTORY=<dir>
EXPORTFORMAT=<format>
# Available export formats: PlainText, HtmlDark, HtmlLight, Csv
# /\ CaSe-SeNsItIvE /\
cd $EXEPATH || exit
@@ -29,21 +30,25 @@ fi
PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
mono DiscordChatExporter.Cli.exe export -t ${TOKEN//\"} $ISBOTYES -c $CHANNEL -f $EXPORTFORMAT -o exporttmp
CURRENTTIME=`date +"%Y-%m-%d-%H-%M-%S"`
mono DiscordChatExporter.Cli.exe export -t $TOKEN $ISBOTYES -c $CHANNEL -f $EXPORTFORMAT -o export.tmp
CURRENTTIME=$(date +"%Y-%m-%d-%H-%M-%S")
if [[ "$EXPORTFORMAT" == "PlainText" ]]; then
mv "exporttmp" ${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.txt
mv "export.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.txt"
elif [[ "$EXPORTFORMAT" == "Html"* ]]; then
mv "exporttmp" ${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.html
mv "export.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.html"
elif [[ "$EXPORTFORMAT" == "Csv" ]]; then
mv "exporttmp" ${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.csv
mv "export.tmp" "${EXPORTDIRECTORY//\"}/$FILENAME-$CURRENTTIME.csv"
else
exit
echo "$EXPORTFORMAT - Unknown export format"
if ! rm -Rf "export.tmp" ; then
echo "Unable to delete $PWD/export.tmp"
fi
exit
exit 1
fi
exit 0
```
**3.** Replace:
@@ -58,10 +63,12 @@ exit
`<name>` with a filename without spaces
`<dir>` with the export directory (e.g. /home/user/Documents/CronExport)
`<dir>` with the export directory (e.g. /home/user/Documents/Discord\ Exports)
`<format>` with one of the available export formats
**Remember to escape spaces** (add `\` before spaces)!<br/><br/>
**4.** Give the shell script permissions with `sudo chmod 755 /path/to/DiscordChatExporter/cron.sh`
**5.** Add a new job to crontab using `sudo crontab e`