2014-08-12 17:34:02 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-01-14 17:19:08 +01:00
|
|
|
ROOT=$(pwd)
|
|
|
|
while [ ! -d $ROOT/.git ]; do
|
|
|
|
ROOT=$(dirname $ROOT)
|
|
|
|
if [ "/" = "$ROOT" ]; then
|
|
|
|
echo "could not find root, are you in the git repository?"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
ERESSEA=$(dirname $ROOT)
|
|
|
|
|
2014-08-12 17:34:02 +02:00
|
|
|
function abort() {
|
|
|
|
echo $1
|
|
|
|
[ -z $2 ] && exit -1
|
|
|
|
exit $2 # otherwise
|
|
|
|
}
|
|
|
|
|
|
|
|
function usage() {
|
|
|
|
cat <<USAGE
|
2014-08-17 11:19:04 +02:00
|
|
|
Usage: $u [-hfn] [-d DIR] [-g <game>] [-r <rules>] [-s DIR]
|
2014-08-12 17:34:02 +02:00
|
|
|
-h print this message
|
|
|
|
-f force overwrite of existing game
|
|
|
|
-g game id
|
2014-08-17 11:19:04 +02:00
|
|
|
-n create new eressea.ini file
|
2014-08-12 17:34:02 +02:00
|
|
|
-r name of ruleset
|
|
|
|
-s server installation directory
|
|
|
|
-d override directory name
|
|
|
|
USAGE
|
|
|
|
}
|
|
|
|
|
|
|
|
game=0
|
|
|
|
force=0
|
|
|
|
src=server
|
2014-08-17 11:19:04 +02:00
|
|
|
edit=1
|
|
|
|
while getopts :d:g:r:s:hfn o; do
|
2014-08-12 17:34:02 +02:00
|
|
|
case "${o}" in
|
2014-08-12 22:00:26 +02:00
|
|
|
h) usage ; exit 0 ;;
|
2014-08-12 17:34:02 +02:00
|
|
|
s) src=${OPTARG} ;;
|
|
|
|
d) dir=${OPTARG} ;;
|
|
|
|
f) force=1 ;;
|
2014-08-17 11:19:04 +02:00
|
|
|
n) edit=0 ;;
|
2014-08-12 17:34:02 +02:00
|
|
|
g) game=${OPTARG} ;;
|
|
|
|
r) rules=${OPTARG} ;;
|
|
|
|
*) echo "not implemented ${o} ${OPTARG}" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2014-08-12 22:00:26 +02:00
|
|
|
[ $game -gt 0 ] || abort "must use a positive integer for game id"
|
2014-08-12 17:34:02 +02:00
|
|
|
[ -z $SOURCE ] && SOURCE=$ERESSEA/$src
|
|
|
|
[ -d $SOURCE ] || abort "invalid source directory $SOURCE"
|
|
|
|
[ -z $rules ] && rules=e$game
|
|
|
|
[ -z $dir ] && dir=game-$game
|
2014-08-12 22:54:55 +02:00
|
|
|
[ -z $TOOLS ] && TOOLS=$SOURCE/build-x86_64-gcc-Debug
|
|
|
|
[ -e $TOOLS ] || TOOLS=$SOURCE/bin
|
|
|
|
[ -z $INIFILE ] && INIFILE=$TOOLS/inifile
|
|
|
|
[ -e $INIFILE ] || INIFILE=$TOOLS/iniparser/inifile
|
2017-01-14 17:19:08 +01:00
|
|
|
|
2017-05-08 08:15:18 +02:00
|
|
|
[ -e $SOURCE/conf/$rules/config.json ] || abort "cannot find conf/$rules/config.json"
|
2014-08-12 17:34:02 +02:00
|
|
|
|
|
|
|
cd $ERESSEA
|
|
|
|
if [ -d $dir ] ; then
|
|
|
|
[ $force -eq 1 ] || abort "$dir directory exists. Use -f to force"
|
|
|
|
fi
|
|
|
|
mkdir -p $dir
|
|
|
|
cd $dir || abort "could not chdir to game-$game"
|
|
|
|
mkdir -p data reports
|
2014-08-12 22:00:26 +02:00
|
|
|
|
2014-08-12 22:54:55 +02:00
|
|
|
function ini_sec() {
|
2014-08-17 11:19:04 +02:00
|
|
|
if [ $edit -eq 1 ]; then
|
2014-08-12 22:54:55 +02:00
|
|
|
$INIFILE eressea.ini add $1
|
2014-08-17 11:19:04 +02:00
|
|
|
else
|
|
|
|
echo "[$1]" >> eressea.ini
|
|
|
|
fi
|
2014-08-12 22:54:55 +02:00
|
|
|
}
|
|
|
|
function ini_add() {
|
2014-08-17 11:19:04 +02:00
|
|
|
if [ $edit -eq 1 ]; then
|
|
|
|
$INIFILE eressea.ini add $1:$2 $3
|
|
|
|
else
|
|
|
|
echo "$2 = $3" >> eressea.ini
|
|
|
|
fi
|
2014-08-12 22:54:55 +02:00
|
|
|
}
|
2014-08-17 11:19:04 +02:00
|
|
|
function ini_start() {
|
|
|
|
if [ -e eressea.ini ]; then
|
|
|
|
if [ ! -e $INIFILE ] && [ $edit -eq 1 ]; then
|
|
|
|
abort "missing editor for eressea.ini. use -n to create new file."
|
|
|
|
fi
|
|
|
|
rm -f eressea.ini
|
|
|
|
edit=0
|
|
|
|
else
|
|
|
|
edit=0
|
|
|
|
fi
|
2014-08-12 22:00:26 +02:00
|
|
|
touch eressea.ini
|
2014-08-17 11:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ini_start
|
2017-01-20 18:44:58 +01:00
|
|
|
ini_sec game
|
|
|
|
ini_add game locales de,en
|
2017-01-22 05:13:44 +01:00
|
|
|
ini_add game id $game
|
|
|
|
ini_add game start 1
|
2014-08-12 22:54:55 +02:00
|
|
|
ini_sec lua
|
2014-08-17 11:19:04 +02:00
|
|
|
ini_add lua install $SOURCE
|
|
|
|
ini_add lua paths $SOURCE/scripts:$SOURCE/lunit
|
|
|
|
ini_add lua rules $rules
|
2014-08-12 22:00:26 +02:00
|
|
|
|
2015-05-12 23:30:49 +02:00
|
|
|
echo 0 > turn
|
2015-05-10 22:41:48 +02:00
|
|
|
touch newfactions
|
|
|
|
ln -sf $SOURCE/bin/eressea
|
|
|
|
ln -sf $SOURCE/scripts/run-turn.lua
|
|
|
|
ln -sf $SOURCE/scripts/reports.lua
|
|
|
|
ln -sf $SOURCE/scripts/config.lua
|