Initial commit
This commit is contained in:
25
docker-assets/backup-eressea.patch
Normal file
25
docker-assets/backup-eressea.patch
Normal file
@ -0,0 +1,25 @@
|
||||
--- backup-eressea.org 2020-12-03 19:01:33.947594665 +0000
|
||||
+++ backup-eressea 2020-12-03 19:39:46.489607175 +0000
|
||||
@@ -3,12 +3,21 @@
|
||||
ERESSEA=$HOME/eressea
|
||||
echo "The ERESSEA environment variable is not set. Assuming $ERESSEA."
|
||||
fi
|
||||
+
|
||||
GAME=$1
|
||||
|
||||
+# script can have 3 parameters
|
||||
+# $1 = game number
|
||||
+# $2 = turn
|
||||
+# $3 = upload url
|
||||
+# the upload url and hence the upload it only done, if all three parameter are given
|
||||
+[ -n $3 ] && UPLOAD_WEBDAV_URL=$3
|
||||
+
|
||||
upload() {
|
||||
+ [ -z $UPLOAD_WEBDAV_URL ] && return
|
||||
SRC="$1"
|
||||
DST=$(basename "$SRC")
|
||||
- echo put "$SRC" "$DST" | cadaver "https://dav.box.com/dav/Eressea/game-$GAME/"
|
||||
+ echo put "$SRC" "$DST" | cadaver "$UPLOAD_WEBDAV_URL"
|
||||
}
|
||||
|
||||
if [ ! -d $ERESSEA/game-$GAME ]; then
|
19
docker-assets/check-orders.sh.patch
Normal file
19
docker-assets/check-orders.sh.patch
Normal file
@ -0,0 +1,19 @@
|
||||
--- check-orders.sh.bak 2020-12-05 17:24:17.709599000 +0000
|
||||
+++ check-orders.sh 2020-12-05 17:25:04.054911000 +0000
|
||||
@@ -4,6 +4,7 @@
|
||||
#set -x
|
||||
|
||||
GAME="$1"
|
||||
+RULES="$2"
|
||||
WARNINGS=0
|
||||
|
||||
if [ -z "$ERESSEA" ] ; then
|
||||
@@ -40,7 +41,7 @@
|
||||
check() {
|
||||
LANGUAGE="$1"
|
||||
FILENAME="$2"
|
||||
- "echeck" -w0 -x -R "e$GAME" -L "$LANGUAGE" "$FILENAME"
|
||||
+ "echeck" -w0 -x -R "$RULES" -L "$LANGUAGE" "$FILENAME"
|
||||
}
|
||||
|
||||
orders() {
|
16
docker-assets/create-orders.patch
Normal file
16
docker-assets/create-orders.patch
Normal file
@ -0,0 +1,16 @@
|
||||
--- create-orders.org 2020-12-03 20:21:23.379383000 +0000
|
||||
+++ create-orders 2020-12-03 20:22:20.290087000 +0000
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
cd "$ERESSEA/game-$GAME" || exit
|
||||
|
||||
-lockfile -r3 -l120 orders.queue.lock
|
||||
if [ -d "orders.dir.$TURN" ]; then
|
||||
echo "orders.dir.$TURN already exists"
|
||||
exit
|
||||
fi
|
||||
rm -f "orders.$TURN"
|
||||
+lockfile -r3 -l120 orders.queue.lock
|
||||
|
||||
cd orders.dir || exit
|
||||
|
15
docker-assets/lua-scripts/modifymap.lua
Normal file
15
docker-assets/lua-scripts/modifymap.lua
Normal file
@ -0,0 +1,15 @@
|
||||
local path = 'scripts'
|
||||
if config.install then
|
||||
path = config.install .. '/' .. path
|
||||
end
|
||||
package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua'
|
||||
require 'eressea.path'
|
||||
require 'eressea'
|
||||
require 'eressea.xmlconf'
|
||||
|
||||
eressea.read_game(get_turn() .. ".dat")
|
||||
gmtool.editor()
|
||||
eressea.write_game(get_turn() .. ".dat")
|
||||
write_database()
|
||||
write_passwords()
|
||||
|
30
docker-assets/lua-scripts/newgame.lua
Normal file
30
docker-assets/lua-scripts/newgame.lua
Normal file
@ -0,0 +1,30 @@
|
||||
require("config")
|
||||
require("eressea")
|
||||
require("tools/build-e3")
|
||||
|
||||
-- script build-e3 calls functions in module eressea; but without module name
|
||||
-- don't how to solve this; but is fully operational
|
||||
free_game = eressea.free_game
|
||||
|
||||
-- first we have to create an empty game data file
|
||||
-- reason: only when a game is loaded, the random seed is initialized correctly
|
||||
eressea.free_game()
|
||||
eressea.write_game(get_turn() .. ".dat")
|
||||
|
||||
-- load game data in order to seed initialized
|
||||
eressea.free_game()
|
||||
eressea.read_game(get_turn() .. ".dat")
|
||||
local w = os.getenv("ERESSEA_MAP_WIDTH")
|
||||
if not w then
|
||||
w = 80
|
||||
end
|
||||
local h = os.getenv("ERESSEA_MAP_HEIGHT")
|
||||
if not h then
|
||||
h = 40
|
||||
end
|
||||
local pl = plane.create(0, -w/2, -h/2, w+1, h+1)
|
||||
build(pl)
|
||||
fill(pl, w, h)
|
||||
|
||||
-- save new world
|
||||
eressea.write_game(get_turn() .. ".dat")
|
62
docker-assets/run-eressea.sh
Executable file
62
docker-assets/run-eressea.sh
Executable file
@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# this script is based on run-eressea.cron
|
||||
# differences to original
|
||||
# it is possible to run a turn with empty orders
|
||||
|
||||
eval "$(luarocks path)"
|
||||
GAME=$1
|
||||
ENABLE_EMPTY_ORDERS=$2
|
||||
(
|
||||
[ "$ENABLED" == "no" ] && exit
|
||||
[ -z "$ERESSEA" ] && ERESSEA="$HOME/eressea"
|
||||
|
||||
export ERESSEA
|
||||
BIN="$ERESSEA/server/bin"
|
||||
TURN=$(cat "$ERESSEA/game-$GAME/turn")
|
||||
if [ ! -e "$ERESSEA/game-$GAME/data/$TURN.dat" ]; then
|
||||
echo "data file $TURN is missing, cannot run turn for game $GAME"
|
||||
exit 1
|
||||
fi
|
||||
REPORTS="$ERESSEA/game-$GAME/reports"
|
||||
if [ -d "$REPORTS" ]; then
|
||||
rm -rf "$REPORTS"
|
||||
fi
|
||||
mkdir "$REPORTS"
|
||||
|
||||
cd "$ERESSEA/game-$GAME" || exit
|
||||
|
||||
if [ -d test ]; then
|
||||
touch test/execute.lock
|
||||
fi
|
||||
|
||||
"$BIN/create-orders" "$GAME" "$TURN"
|
||||
if [ ! -s "$ERESSEA/game-$GAME/orders.$TURN" ]; then
|
||||
if [ "$ENABLE_EMPTY_ORDERS" != "yes"]; then
|
||||
echo "server did not create orders for turn $TURN in game $GAME"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
"$BIN/backup-eressea" "$GAME" "$TURN"
|
||||
rm -f execute.lock
|
||||
"$BIN/run-turn" "$GAME" "$TURN"
|
||||
touch execute.lock
|
||||
|
||||
if [ ! -s "$REPORTS/reports.txt" ]; then
|
||||
echo "server did not create reports.txt in game $GAME"
|
||||
exit 4
|
||||
fi
|
||||
"$BIN/backup-eressea" "$GAME" "$TURN"
|
||||
let TURN=$TURN+1
|
||||
if [ ! -s "$ERESSEA/game-$GAME/data/$TURN.dat" ]; then
|
||||
echo "server did not create data for turn $TURN in game $GAME"
|
||||
exit 3
|
||||
fi
|
||||
echo "sending reports for game $GAME, turn $TURN"
|
||||
"$BIN/compress.sh" "$GAME" "$TURN"
|
||||
"$BIN/sendreports.sh" "$GAME"
|
||||
"$BIN/backup-eressea" "$GAME" "$TURN"
|
||||
rm -f test/execute.lock
|
||||
) | tee -a "$HOME/log/eressea.cron.log"
|
||||
|
559
docker-assets/start.sh
Executable file
559
docker-assets/start.sh
Executable file
@ -0,0 +1,559 @@
|
||||
#!/bin/bash
|
||||
base_dir="$(dirname "$0")"
|
||||
|
||||
# -------------------
|
||||
# -- Helper functions
|
||||
|
||||
function ini_sec() {
|
||||
/eressea/server/bin/inifile /data/game-1/eressea.ini add $1
|
||||
}
|
||||
|
||||
function ini_add() {
|
||||
/eressea/server/bin/inifile /data/game-1/eressea.ini add $1:$2 $3
|
||||
}
|
||||
|
||||
function ini_get() {
|
||||
/eressea/server/bin/inifile /data/game-1/eressea.ini get $1:$2
|
||||
}
|
||||
|
||||
function get_turn() {
|
||||
turn=0
|
||||
[ -e /data/game-1/turn ] && turn=$(cat /data/game-1/turn)
|
||||
[ -z $turn ] && turn=0
|
||||
}
|
||||
|
||||
# -----------------
|
||||
# -- Main-commands
|
||||
|
||||
cmd_help() {
|
||||
usage() {
|
||||
echo ""
|
||||
echo "Usage: $0 COMMAND [-h] [arguments]"
|
||||
echo ""
|
||||
echo "supported COMMANDs:"
|
||||
echo " addpwd adds password in newfactions"
|
||||
echo " bash start a bash shell"
|
||||
echo " generate generate eressea.ini and all relevant files"
|
||||
echo " help show this help"
|
||||
echo " mail process incoming e-mail"
|
||||
echo " map generate/edit game map"
|
||||
echo " run execute Eressea game turn"
|
||||
echo " shutdown remove temporaray Eressea environment"
|
||||
echo " startup create temporaray Eressea environment which is necessary for scripts"
|
||||
echo ""
|
||||
echo "arguments:"
|
||||
echo "-h ... show more details of command"
|
||||
exit 2
|
||||
}
|
||||
usage
|
||||
}
|
||||
|
||||
cmd_bash() {
|
||||
usage() {
|
||||
[ -n "$1" ] && echo -e "\n$1"
|
||||
echo ""
|
||||
echo "Starts an interactive bash shell."
|
||||
echo "Usage: $0 bash [-h] [-n]"
|
||||
echo "-h ... show this help"
|
||||
echo "-n ... start a 'naked' bash, which means eressea is not setup"
|
||||
echo " can be done later by invoking '/eressea/start.sh startup'"
|
||||
echo " before you exit the shell, call '/eressea/start.sh shutdown'"
|
||||
exit 2
|
||||
}
|
||||
|
||||
args=$(getopt --name shutdown -o hn -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
eval set -- "$args"
|
||||
|
||||
naked=0
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h) usage ; shift ;;
|
||||
-n) naked=1; shift ;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ ${naked} == 0 ] && cmd_startup || echo "started bash without any Eressea environment setup"
|
||||
/bin/bash
|
||||
[ ${naked} == 0 ] && cmd_shutdown
|
||||
}
|
||||
|
||||
cmd_startup() {
|
||||
usage() {
|
||||
[ -n "$1" ] && echo -e "\n$1"
|
||||
echo ""
|
||||
echo "Setup an environment which enables Eressea to find a runtime environment where all scripts are functional."
|
||||
echo "Usage: $0 startup [-h]"
|
||||
echo "-h ... show this help"
|
||||
exit 2
|
||||
}
|
||||
|
||||
args=$(getopt --name shutdown -o h -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
eval set -- "$args"
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h) usage ; shift ;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p /data/config
|
||||
mkdir -p /data/log
|
||||
|
||||
ln -sf /data/config/muttrc ~/.muttrc
|
||||
ln -sf /data/config/fetchmailrc ~/.fetchmailrc
|
||||
ln -sf /data/config/procmailrc ~/.procmailrc
|
||||
|
||||
ln -sf /eressea/server /data/server
|
||||
ln -sf /eressea/orders-php /data/orders-php
|
||||
|
||||
mkdir -p /data/game-1
|
||||
mkdir -p /data/game-1/backup
|
||||
ln -sf /data/server/scripts/config.lua /data/game-1/config.lua
|
||||
ln -sf /data/server/bin/eressea /data/game-1/eressea
|
||||
ln -sf /data/server/scripts/reports.lua /data/game-1/reports.lua
|
||||
ln -sf /data/server/scripts/run-turn.lua /data/game-1/run-turn.lua
|
||||
|
||||
cd /data/game-1
|
||||
echo "Eressea environment setup complete"
|
||||
}
|
||||
|
||||
cmd_shutdown() {
|
||||
usage() {
|
||||
[ -n "$1" ] && echo -e "\n$1"
|
||||
echo ""
|
||||
echo "Removes temporary Eressea environment from mapped /data folder."
|
||||
echo "Usage: $0 shutdown [-h]"
|
||||
echo "-h ... show this help"
|
||||
exit 2
|
||||
}
|
||||
|
||||
args=$(getopt --name shutdown -o h -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
eval set -- "$args"
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h) usage ; shift ;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -e /data/game-1/config.lua ] && rm /data/game-1/config.lua
|
||||
[ -e /data/game-1/eressea ] && rm /data/game-1/eressea
|
||||
[ -e /data/game-1/reports.lua ] && rm /data/game-1/reports.lua
|
||||
[ -e /data/game-1/run-turn.lua ] && rm /data/game-1/run-turn.lua
|
||||
|
||||
[ -e /data/server ] && rm /data/server
|
||||
[ -e /data/orders-php ] && rm /data/orders-php
|
||||
|
||||
[ -e ~/.muttrc ] && rm -f ~/.muttrc
|
||||
[ -e ~/.fetchmailrc ] && rm -f ~/.fetchmailrc
|
||||
[ -e ~/.procmailrc ] && rm -f ~/.procmailrc
|
||||
|
||||
[ -e /data/config/logrotate ] && logrotate /data/config/logrotate
|
||||
|
||||
echo "Eressea environment successfully removed"
|
||||
}
|
||||
|
||||
cmd_generate() {
|
||||
usage() {
|
||||
[ -n "$1" ] && echo -e "\n$1"
|
||||
echo ""
|
||||
echo "Generates eressea.ini file and all other necessary files/folders needed by this Docker container."
|
||||
echo "Usage: $0 generate [options]"
|
||||
echo ""
|
||||
echo "General option:"
|
||||
echo "-f force generating of files - delete will be done without prompt!"
|
||||
echo "-g generate all other necessary files and folders (values are defined by eressea.ini and mail.ini)"
|
||||
echo "-h show this help"
|
||||
echo "-i generate eressea.ini and mail.ini file"
|
||||
echo ""
|
||||
echo "If eressea.ini is not available, option -i is mandatory. All of the following options are also necessray:"
|
||||
echo " --from <email> e-mail address Eressea postbox"
|
||||
echo " --imap_server <addr> IMAP server address. If not provided, value of smtp_server is used."
|
||||
echo " --imap_user <user> user for IMAP server. If not provided, value of smtp_user is used."
|
||||
echo " --imap_pass <password> password of IMAP user. If not provided, value of smtp_pass is used."
|
||||
echo " --smtp_server <addr> SMTP server address. If not provided, value of imap_server is used."
|
||||
echo " --smtp_user <user> user for SMTP server. If not provided, value of imap_user is used."
|
||||
echo " --smtp_pass <password> password of SMTP user. If not provided, value of imap_pass is used."
|
||||
echo ""
|
||||
echo " Optional:"
|
||||
echo " --game_name <name> name of self hosted Eressea game. Default=MyEressea"
|
||||
echo " --realname name> real name used for e-Mails. Default=Game Server <game_name>"
|
||||
echo " --smtp_port <port> port of SMTP server, Default=587"
|
||||
echo " --imap_port <port> port of IMAP server, Default=993"
|
||||
echo " --rules <ruleset> ruleset, Defaule=e3"
|
||||
exit 2
|
||||
}
|
||||
|
||||
args=$(getopt --name generate -o fghi --long game_name:,from:,realname:,smtp_server:,smtp_port:,smtp_user:,smtp_pass:,imap_server:,imap_port:,imap_user:,imap_pass:,rules: -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
eval set -- "$args"
|
||||
|
||||
force=0
|
||||
do_gen=0
|
||||
do_ini=0
|
||||
game_name="MyEressea"
|
||||
imap_port=993
|
||||
smtp_port=587
|
||||
rules="e3"
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-f) force=1 ; shift ;;
|
||||
-g) do_gen=1 ; shift ;;
|
||||
-h) usage ; shift ;;
|
||||
-i) do_ini=1 ; shift ;;
|
||||
--game_name) game_name="$2" ; shift 2 ;;
|
||||
--from) from="$2" ; shift 2 ;;
|
||||
--realname) realname="$2" ; shift 2 ;;
|
||||
--smtp_server) smtp_server="$2" ; shift 2 ;;
|
||||
--smtp_port) smtp_port="$2" ; shift 2 ;;
|
||||
--smtp_user) smtp_user="$2" ; shift 2 ;;
|
||||
--smtp_pass) smtp_pass="$2" ; shift 2 ;;
|
||||
--imap_server) imap_server="$2" ; shift 2 ;;
|
||||
--imap_port) imap_port="$2" ; shift 2 ;;
|
||||
--imap_user) imap_user="$2" ; shift 2 ;;
|
||||
--imap_pass) imap_pass="$2" ; shift 2 ;;
|
||||
--rules) rules="$2" ; shift 2 ;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $do_ini == 1 ]; then
|
||||
mkdir -p /data/game-1
|
||||
[ -e /data/game-1/eressea.ini ] && [ $force == 0 ] && usage "eressea.ini already exists. Add option -f"
|
||||
|
||||
[ -z "$imap_server" ] && [ -n "$smtp_server" ] && imap_server=$smtp_server
|
||||
[ -z "$imap_user" ] && [ -n "$smtp_user" ] && imap_user=$smtp_user
|
||||
[ -z "$imap_pass" ] && [ -n "$smtp_pass" ] && imap_pass=$smtp_pass
|
||||
|
||||
[ -z "$smtp_server" ] && [ -n "$imap_server" ] && smtp_server=$imap_server
|
||||
[ -z "$smtp_user" ] && [ -n "$imap_user" ] && smtp_user=$imap_user
|
||||
[ -z "$smtp_pass" ] && [ -n "$imap_pass" ] && smtp_pass=$imap_pass
|
||||
|
||||
[ -z "$realname" ] && realname="Game Server ${game_name}"
|
||||
|
||||
[ -z "$game_name" ] || [ -z "$from" ] || [ -z "$realname" ] || [ -z "$rules" ] || \
|
||||
[ -z "$smtp_server" ] || [ -z "$smtp_port" ] || [ -z "$smtp_user" ] || [ -z "$smtp_pass" ] || \
|
||||
[ -z "$imap_server" ] || [ -z "$imap_port" ] || [ -z "$imap_user" ] || [ -z "$imap_pass" ] && \
|
||||
usage "not all options relevant for eressea.ini were provided"
|
||||
|
||||
[ -e /data/game-1/eressea.ini ] && rm -f /data/game-1/eressea.ini
|
||||
touch /data/game-1/eressea.ini
|
||||
|
||||
ini_sec game
|
||||
ini_add game locales de,en
|
||||
ini_add game id 1
|
||||
ini_add game start 0
|
||||
ini_add game email $from
|
||||
ini_add game name $game_name
|
||||
ini_add game seed `shuf -i 0-9999 -n1`
|
||||
ini_add game dbname eressea.db
|
||||
ini_add game dbswap :memory:
|
||||
ini_add game mailcmd `echo "print '$game_name'.upper()" | python`
|
||||
ini_sec lua
|
||||
ini_add lua install /data/server
|
||||
ini_add lua paths /data/server/scripts:/data/server/lunit
|
||||
ini_add lua rules $rules
|
||||
echo "eressea.ini generated"
|
||||
|
||||
[ -e /data/config/mail.ini ] && rm -f /data/config/mail.ini
|
||||
mkdir -p /data/config
|
||||
echo "[smtp]" > /data/config/mail.ini
|
||||
echo "server = $smtp_server" >> /data/config/mail.ini
|
||||
echo "port = $smtp_port" >> /data/config/mail.ini
|
||||
echo "user = $smtp_user" >> /data/config/mail.ini
|
||||
echo "pass = $smtp_pass" >> /data/config/mail.ini
|
||||
echo "[imap]" >> /data/config/mail.ini
|
||||
echo "server = $imap_server" >> /data/config/mail.ini
|
||||
echo "port = $imap_port" >> /data/config/mail.ini
|
||||
echo "user = $imap_user" >> /data/config/mail.ini
|
||||
echo "pass = $imap_pass" >> /data/config/mail.ini
|
||||
echo "[general]" >> /data/config/mail.ini
|
||||
echo "realname = $realname" >> /data/config/mail.ini
|
||||
echo "mail.ini generated"
|
||||
fi
|
||||
|
||||
if [ $do_gen == 1 ]; then
|
||||
[ ! -e /data/game-1/eressea.ini ] && usage "eressea.ini missing. Use option -i"
|
||||
|
||||
if [ $force == 1 ]; then
|
||||
echo "existing game data deleted"
|
||||
for node in /data/game-1/*
|
||||
do
|
||||
[ $node == "/data/game-1/eressea.ini" ] && continue
|
||||
[ -d $node ] && rm -rf $node || rm -f $node
|
||||
done;
|
||||
else
|
||||
echo "existing game data is not touched. Missing files are recreated"
|
||||
fi
|
||||
|
||||
mkdir -p /data/config
|
||||
tmpfile=$(mktemp ini.XXX)
|
||||
cat /data/game-1/eressea.ini > $tmpfile
|
||||
cat /data/config/mail.ini >> $tmpfile
|
||||
|
||||
[ -e /data/config/fetchmailrc ] && [ $force == 0 ] && rm -f /data/config/fetchmailrc
|
||||
[ ! -e /data/config/fetchmailrc ] && j2 -f ini /eressea/template-config/fetchmailrc $tmpfile > /data/config/fetchmailrc
|
||||
chmod 700 /data/config/fetchmailrc
|
||||
|
||||
[ -e /data/config/procmailrc ] && [ $force == 0 ] && rm -f /data/config/procmailrc
|
||||
[ ! -e /data/config/procmailrc ] && j2 -f ini /eressea/template-config/procmailrc $tmpfile > /data/config/procmailrc
|
||||
|
||||
[ -e /data/config/muttrc ] && [ $force == 0 ] && rm -f /data/config/muttrc
|
||||
[ ! -e /data/config/muttrc ] && j2 -f ini /eressea/template-config/muttrc $tmpfile > /data/config/muttrc
|
||||
|
||||
[ -e /data/config/logrotate ] && [ $force == 0 ] && rm -f /data/config/logrotate
|
||||
[ ! -e /data/config/logrotate ] && cp /eressea/template-config/logrotate /data/config/logrotate
|
||||
|
||||
rm -f $tmpfile
|
||||
|
||||
mkdir -p /data/mail/cache
|
||||
mkdir -p /data/mail/postbox/inbox/{cur,new,tmp}
|
||||
mkdir -p /data/mail/postbox/sent/{cur,new,tmp}
|
||||
mkdir -p /data/mail/postbox/draft/{cur,new,tmp}
|
||||
mkdir -p /data/mail/certificates
|
||||
|
||||
mkdir -p /data/game-1/data
|
||||
mkdir -p /data/game-1/reports
|
||||
mkdir -p /data/game-1/backup
|
||||
[ ! -e /data/game-1/newfactions ] && touch /data/game-1/newfactions
|
||||
[ ! -e /data/game-1/turn ] && echo 0 > /data/game-1/turn
|
||||
|
||||
echo "all basic game files generated"
|
||||
echo "next step would be to create a new game file / map; therefore use '$0 map -h'"
|
||||
fi
|
||||
|
||||
[ $do_gen == 0 ] && [ $do_ini == 0 ] && usage "nothing to generate. Use option -i or -g"
|
||||
}
|
||||
|
||||
cmd_map() {
|
||||
usage() {
|
||||
[ -n "$1" ] && echo -e "\n$1"
|
||||
echo ""
|
||||
echo "Generate or edit Eressea map."
|
||||
echo "Usage: $0 map [options]"
|
||||
echo "-h ... show this help"
|
||||
echo "-n ... generate new map. If map already exists, it will be overwritten!"
|
||||
echo "-w ... width of new map - only relevant together with -n"
|
||||
echo "-e ... height of new map - only relevant together with -n"
|
||||
echo "-t ... turn"
|
||||
echo "-s ... save map when editor is closed"
|
||||
exit 2
|
||||
}
|
||||
|
||||
args=$(getopt --name shutdown -o hnw:e:t:s -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
eval set -- "$args"
|
||||
|
||||
create_new=0
|
||||
export ERESSEA_MAP_WIDTH=60
|
||||
export ERESSEA_MAP_HEIGHT=40
|
||||
get_turn
|
||||
save=0
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h) usage ; shift ;;
|
||||
-n) create_new=1 ; shift ;;
|
||||
-w) ERESSEA_MAP_WIDTH=$2 ; shift 2 ;;
|
||||
-e) ERESSEA_MAP_HEIGHT=$2; shift 2 ;;
|
||||
-t) turn=$2 ; shift 2 ;;
|
||||
-s) save=1 ; shift ;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
cmd_startup
|
||||
|
||||
if [ $create_new == 1 ]; then
|
||||
ini_sec game
|
||||
ini_add game seed `shuf -i 0-9999 -n1`
|
||||
|
||||
./eressea -v 0 -t $turn /eressea/lua-scripts/newgame.lua
|
||||
echo "created new game map with size ${ERESSEA_MAP_WIDTH}x${ERESSEA_MAP_HEIGHT}"
|
||||
fi
|
||||
|
||||
if [ $save == 1 ]; then
|
||||
./eressea -v 0 -t $turn /eressea/lua-scripts/modifymap.lua
|
||||
else
|
||||
./eressea -v 0 -t $turn /data/server/scripts/map.lua
|
||||
fi
|
||||
|
||||
cmd_shutdown
|
||||
}
|
||||
|
||||
cmd_addpwd() {
|
||||
usage() {
|
||||
[ -n "$1" ] && echo -e "\n$1"
|
||||
echo ""
|
||||
echo "In file 'newfactions' on lines without password a secure one is generated and inserted."
|
||||
echo "Usage: $0 addpwd [options]"
|
||||
echo "-f ... force usage of new password"
|
||||
echo "-h ... show this help"
|
||||
exit 2
|
||||
}
|
||||
|
||||
args=$(getopt --name shutdown -o hf -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
eval set -- "$args"
|
||||
|
||||
force=0
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h) usage ; shift ;;
|
||||
-f) force=1; shift ;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ ! -e "/data/game-1/newfactions" ] && echo "file newfactions does not exist" && exit
|
||||
|
||||
tmpfile=$(mktemp newfactions.XXX)
|
||||
touch $tmpfile
|
||||
|
||||
while IFS=" " read -r email race language pass alliance
|
||||
do
|
||||
[ -z "$email" ] && continue
|
||||
echo "found player $email ($race), language $language`[ -n "$alliance" ] && echo " in alliance with $alliance"`"
|
||||
if [ -z "$pass" ] || [ $force == 1 ]; then
|
||||
new_pass="`pwgen -c -n -y 8 1`"
|
||||
echo " new password $new_pass`[ -n "$pass" ] && echo " replaces former password $pass"`"
|
||||
else
|
||||
new_pass=$pass
|
||||
echo " uses password $pass"
|
||||
fi
|
||||
echo "$email $race $language $new_pass`[ -n "$alliance" ] && echo " $alliance"`" >> $tmpfile
|
||||
done < /data/game-1/newfactions
|
||||
|
||||
rm -f /data/game-1/newfactions
|
||||
mv $tmpfile /data/game-1/newfactions
|
||||
}
|
||||
|
||||
cmd_mail() {
|
||||
usage() {
|
||||
[ -n "$1" ] && echo -e "\n$1"
|
||||
echo ""
|
||||
echo "Process incoming e-mails"
|
||||
echo "Usage: $0 mail [options]"
|
||||
echo "-c ... check orders and send email to player"
|
||||
echo "-f ... fetch mail from server and pre-process them"
|
||||
echo "-h ... show this help"
|
||||
exit 2
|
||||
}
|
||||
|
||||
args=$(getopt --name shutdown -o hcf -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
eval set -- "$args"
|
||||
|
||||
fetch=0
|
||||
check=0
|
||||
while :; do
|
||||
case "$1" in
|
||||
-f) fetch=1; shift ;;
|
||||
-c) check=1; shift ;;
|
||||
-h) usage ; shift ;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ $(expr $fetch + $check) == 0 ] && usage "either option -f or -c is necessary"
|
||||
|
||||
cmd_startup
|
||||
|
||||
if [ $fetch == 1 ]; then
|
||||
touch /data/log/fetchmail.log
|
||||
fetchmail >> /data/log/fetchmail.log 2>&1
|
||||
fi
|
||||
|
||||
if [ $check == 1 ]; then
|
||||
mkdir -p /data/game-1/orders.dir
|
||||
rules="$(ini_get lua rules)"
|
||||
/data/orders-php/check-orders.sh 1 $rules
|
||||
fi
|
||||
|
||||
cmd_shutdown
|
||||
}
|
||||
|
||||
cmd_run() {
|
||||
usage() {
|
||||
[ -n "$1" ] && echo -e "\n$1"
|
||||
echo ""
|
||||
echo "Execute next game turn"
|
||||
echo "Usage: $0 rung [options]"
|
||||
echo "-h ... show this help"
|
||||
exit 2
|
||||
}
|
||||
|
||||
args=$(getopt --name shutdown -o h -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
eval set -- "$args"
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-h) usage ; shift ;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
cmd_startup
|
||||
mkdir -p $HOME/log
|
||||
mkdir -p /data/game-1/orders.dir
|
||||
touch /data/log/eressea.cron.log
|
||||
ln -sf /data/log/eressea.cron.log $HOME/log/eressea.cron.log
|
||||
|
||||
get_turn
|
||||
enable_empty_orders="no"
|
||||
[ "$turn" == "0" ] && enable_empty_orders="yes"
|
||||
/eressea/run-eressea.sh 1
|
||||
|
||||
cmd_shutdown
|
||||
}
|
||||
|
||||
# ----------------
|
||||
# -- Main function
|
||||
|
||||
COMMAND="$1"
|
||||
shift
|
||||
|
||||
case $COMMAND in
|
||||
"help" | "startup" | "shutdown" | "bash" | "generate" | "map" | "addpwd" | "mail" | "run") eval cmd_$COMMAND "$@" ;;
|
||||
*) cmd_help ;;
|
||||
esac
|
18
docker-assets/template-config/fetchmailrc
Normal file
18
docker-assets/template-config/fetchmailrc
Normal file
@ -0,0 +1,18 @@
|
||||
##################################
|
||||
## UPDATE EVERYTHING FROM HERE >>>
|
||||
|
||||
# set correct mail server and its credentials
|
||||
# note: mails are removed from IMAP server and copied in local mailbox
|
||||
poll {{imap.server}} proto IMAP
|
||||
with port {{imap.port}}
|
||||
user "{{imap.user}}"
|
||||
pass "{{imap.pass}}"
|
||||
ssl
|
||||
fetchall
|
||||
#keep
|
||||
|
||||
## <<< UPDATE EVERYTHING TO HERE
|
||||
################################
|
||||
|
||||
mda "/usr/bin/procmail -d %T"
|
||||
set no bouncemail
|
9
docker-assets/template-config/logrotate
Normal file
9
docker-assets/template-config/logrotate
Normal file
@ -0,0 +1,9 @@
|
||||
/data/log/*.log {
|
||||
|
||||
weekly
|
||||
create 0644 root root
|
||||
rotate 2
|
||||
compress
|
||||
|
||||
delaycompress
|
||||
}
|
47
docker-assets/template-config/muttrc
Normal file
47
docker-assets/template-config/muttrc
Normal file
@ -0,0 +1,47 @@
|
||||
##################################
|
||||
## UPDATE EVERYTHING FROM HERE >>>
|
||||
|
||||
# name of the sender for eressea mails
|
||||
set from = "{{game.email}}"
|
||||
set realname = "{{general.realname}}"
|
||||
|
||||
# credentials for smtp access
|
||||
set smtp_url = "smtp://{{smtp.user}}@{{smtp.server}}:{{smtp.port}}"
|
||||
set smtp_pass = "{{smtp.pass}}"
|
||||
|
||||
# from time to time change this value from no to yes.
|
||||
# It will clean the mail caches. But it can be slow in big mailboxes
|
||||
set message_cache_clean = no
|
||||
|
||||
## <<< UPDATE EVERYTHING TO HERE
|
||||
################################
|
||||
|
||||
# caches
|
||||
set header_cache = "/data/mail/cache/headers"
|
||||
set message_cachedir = "/data/mail/cache/bodies"
|
||||
set certificate_file = "/data/mail/certificates"
|
||||
|
||||
# mailbox
|
||||
set mbox_type="maildir"
|
||||
set folder="/data/mail/postbox"
|
||||
set spoolfile="+inbox"
|
||||
set record="+sent"
|
||||
set postponed="+draft"
|
||||
set move=no
|
||||
|
||||
mailboxes `echo -n "+ "; find /data/mail/postbox -maxdepth 1 -type d -name "*" -printf "+'%f' "`
|
||||
macro index c "<change-folder>?<toggle-mailboxes>" "open a different folder"
|
||||
macro pager c "<change-folder>?<toggle-mailboxes>" "open a different folder"
|
||||
macro index C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
|
||||
macro index M "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"
|
||||
macro compose A "<attach-message>?<toggle-mailboxes>" "attach message(s) to this message"
|
||||
|
||||
# various options
|
||||
set mail_check = 30
|
||||
set sort = "threads"
|
||||
set sort_aux = "reverse-last-date-received"
|
||||
set auto_tag = yes
|
||||
hdr_order Date From To Cc
|
||||
alternative_order text/plain text/html *
|
||||
auto_view text/html
|
||||
set editor = "nano"
|
25
docker-assets/template-config/procmailrc
Normal file
25
docker-assets/template-config/procmailrc
Normal file
@ -0,0 +1,25 @@
|
||||
SHELL=/bin/bash
|
||||
PATH=/usr/sbin:/usr/bin:/bin
|
||||
MAILDIR=/data/mail/postbox
|
||||
DEFAULT=$MAILDIR
|
||||
LOGFILE=/data/log/procmail.log
|
||||
LOG=""
|
||||
VERBOSE=yes
|
||||
FROM=`formail -cx From:`
|
||||
ERESSEA=/data
|
||||
|
||||
:0:server.lock
|
||||
* ^Subject:.*{{game.mailcmd}} REPORT \/.*
|
||||
* !From: {{game.email}}
|
||||
| tr -d '^Z' | /data/server/bin/sendreport.sh 1 "$FROM" $MATCH
|
||||
|
||||
:0:server.lock
|
||||
* ^Subject:.*{{game.mailcmd}} BEFEHLE
|
||||
| grep -v '>From' | /data/server/bin/orders-accept 1 de
|
||||
|
||||
:0:server.lock
|
||||
* ^Subject:.*{{game.mailcmd}} ORDERS
|
||||
| grep -v '>From' | /data/server/bin/orders-accept 1 en
|
||||
|
||||
:0:
|
||||
$MAILDIR/inbox/
|
Reference in New Issue
Block a user