Author Topic: automatic map download (for headless server)  (Read 963 times)

treba

  • Guest
automatic map download (for headless server)
« on: 18 February 2012, 16:57:47 »
hey,

i wrote a little script, mainly for my headless server, to download all maps from the mods-server that are not yet there.
it's a little bit dirty and the crc-check does not yet work on mashines without a graphics card (which will hopefully be fixed in the next mg version), but it works well for me
Code: [Select]
#!/bin/bash

cd `dirname $0`

MAPLIST=`curl http://master.megaglest.org/showMapsForGlest.php 2>/dev/null`
MAPFOLDER=../megaglest/maps # the folder to put the maps. must be one of the ones that mg checks for maps
GAMEEXECPATH=../megaglest/megaglest # the path to the megaglest executable. can also be the launchscript
LOGFILE=./logs/syncmaps.log

while IFS= read;do
        OIFS=$IFS
        IFS='|' read -ra ARRAY <<< "$REPLY"
        if [ ! -e $MAPFOLDER/"${ARRAY[0]}" ]; then
                echo "download map ${ARRAY[0]}" >> $LOGFILE
                wget -P "$MAPFOLDER" "${ARRAY[4]}" > /dev/null 2>&1
                #CRC=`$GAMEEXECPATH --show-map-crc="${ARRAY[0]%.*m}" | grep "${ARRAY[2]:1}"`
                #if [ -z "$CRC" ]; then
                        #echo "crc-check failed - removed file" >> $LOGFILE
                        #rm $MAPFOLDER/"${ARRAY[0]}" > /dev/null 2>&1
                #fi
        fi
        IFS=$OIFS
done< <(echo "$MAPLIST")

if you care for the license, it's gpl 3 :)
« Last Edit: 18 February 2012, 17:03:44 by treba »