2016-02-11 20:27:41 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
2018-07-07 10:45:11 +02:00
|
|
|
if [ -z "$ERESSEA" ]; then
|
2016-02-11 20:27:41 +01:00
|
|
|
echo "You have to define the \$ERESSEA environment variable to run $0"
|
2019-07-31 08:43:23 +02:00
|
|
|
exit 2
|
2016-02-11 20:27:41 +01:00
|
|
|
fi
|
2018-07-07 10:45:11 +02:00
|
|
|
|
|
|
|
function abort() {
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
echo "$@"
|
|
|
|
fi
|
2019-07-31 08:43:23 +02:00
|
|
|
exit 1
|
2018-07-07 10:45:11 +02:00
|
|
|
}
|
2016-02-11 20:27:41 +01:00
|
|
|
|
|
|
|
GAME=$1
|
|
|
|
EMAIL=$2
|
|
|
|
FACTION=$3
|
|
|
|
PASSWD=$4
|
2016-10-05 09:30:17 +02:00
|
|
|
#echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log
|
2016-02-11 20:27:41 +01:00
|
|
|
|
|
|
|
function reply() {
|
2018-07-07 10:45:11 +02:00
|
|
|
echo "$@" | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL"
|
|
|
|
abort "$@"
|
2016-02-11 20:27:41 +01:00
|
|
|
}
|
|
|
|
|
2018-07-07 10:45:11 +02:00
|
|
|
LOCKFILE="$ERESSEA/.report.lock"
|
|
|
|
[ -e "$LOCKFILE" ] && reply "lockfile exists. wait for mail delivery to finish."
|
2016-02-11 20:27:41 +01:00
|
|
|
|
2018-07-07 10:45:11 +02:00
|
|
|
echo "$(date):report:$GAME:$EMAIL:$FACTION:$PASSWD" >> "$ERESSEA/request.log"
|
2016-02-11 20:27:41 +01:00
|
|
|
|
2018-07-07 10:45:11 +02:00
|
|
|
cd "$ERESSEA" || exit
|
2019-01-20 02:48:14 +01:00
|
|
|
BIN="$ERESSEA/server/bin"
|
2018-09-27 16:57:39 +02:00
|
|
|
PWFILE="game-$GAME/eressea.db"
|
|
|
|
if [ ! -e "$PWFILE" ]; then
|
|
|
|
PWFILE="game-$GAME/passwd"
|
|
|
|
fi
|
2019-01-20 03:08:37 +01:00
|
|
|
"$BIN/checkpasswd.py" "$PWFILE" "$FACTION" "$PASSWD" || reply "Das Passwort fuer die Partei $FACTION ist ungueltig"
|
2016-02-11 20:27:41 +01:00
|
|
|
|
2018-07-07 10:45:11 +02:00
|
|
|
cd "$ERESSEA/game-$GAME/reports" || exit
|
|
|
|
if [ ! -e "${FACTION}.sh" ]; then
|
2016-02-11 20:27:41 +01:00
|
|
|
echo "Der Report für Partei $FACTION kann wegen technischer Probleme leider nicht nachgefordert werden: No such file ${FACTION}.sh" \
|
2018-07-07 10:45:11 +02:00
|
|
|
| mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL"
|
2016-02-11 20:27:41 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2018-07-07 10:45:11 +02:00
|
|
|
bash "${FACTION}.sh" "$EMAIL" || reply "Unbekannte Partei $FACTION"
|
2016-02-11 20:27:41 +01:00
|
|
|
|
2019-01-20 03:08:37 +01:00
|
|
|
OWNER=$("$BIN/getfaction.py" "$PWFILE" "$FACTION")
|
2019-07-31 08:43:23 +02:00
|
|
|
if [ -n "$OWNER" ]; then
|
2018-10-09 19:40:26 +02:00
|
|
|
echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \
|
|
|
|
| mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER"
|
2016-02-11 20:27:41 +01:00
|
|
|
fi
|