server/s/setup

73 lines
1.7 KiB
Plaintext
Raw Normal View History

2014-08-12 17:34:02 +02:00
#!/bin/bash
function abort() {
echo $1
[ -z $2 ] && exit -1
exit $2 # otherwise
}
function usage() {
cat <<USAGE
Usage: $u [-hf] [-d DIR] [-g <game>] [-r <rules>] [-s DIR]
-h print this message
-f force overwrite of existing game
-g game id
-r name of ruleset
-s server installation directory
-d override directory name
USAGE
}
game=0
force=0
src=server
2014-08-12 17:34:02 +02:00
while getopts :d:g:r:s:hf o; do
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 ;;
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
[ -d $ERESSEA ] || abort "invalid or missing env variable ERESSEA ($ERESSEA)"
[ -z $SOURCE ] && SOURCE=$ERESSEA/$src
[ -d $SOURCE ] || abort "invalid source directory $SOURCE"
[ -z $rules ] && rules=e$game
[ -z $dir ] && dir=game-$game
[ -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
[ -e $INIFILE ] || abort "tool is not installed: $INIFILE"
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
function ini_sec() {
$INIFILE eressea.ini add $1
}
function ini_add() {
$INIFILE eressea.ini add $1 $2
}
2014-08-12 22:00:26 +02:00
touch eressea.ini
ini_sec eressea
2014-08-12 22:00:26 +02:00
ini_add eressea:locales de,en
ini_sec lua
2014-08-12 22:00:26 +02:00
ini_add lua:install $SOURCE
ini_add lua:install $SOURCE
ini_add lua:paths $SOURCE/scripts:$SOURCE/lunit
ini_add lua:rules $rules
2014-08-12 17:34:02 +02:00
ln -f $SOURCE/scripts/run-turn.lua