tools/gdc-psyfork/example-scripts/gdc_core.sh
author Nicholas Hastings <skamonkey@gmail.com>
Sun May 27 11:39:50 2012 -0400 (2012-05-27)
changeset 3514 377c7da70d7c
child 3694 65d8f56a0006
permissions -rw-r--r--
Added example scripts missing from last commit (NPOTB).
     1 #!/bin/bash
     2 
     3 # Do not run this file directly. It is meant to be called by other scripts
     4 
     5 SM_PATH=/home/gdc/sourcemod-central
     6 
     7 ENGINE_BIN=${ENGINE_PATH}/bin/engine
     8 GAME_BIN=${ENGINE_PATH}/${GAME_DIR}/bin/server
     9 STEAMINF=${ENGINE_PATH}/${GAME_DIR}/steam.inf
    10 BIN_EXT=""
    11 if [ $MOD == 1 ] ; then
    12 	BIN_EXT="_i486"
    13 fi
    14 
    15 echo -e "Checking game ${GAME_DIR}...\n"
    16 
    17 if [ $MOD == 0 ] && [ "$1" == "auto" ] ; then
    18 	./updatecheck.pl "${STEAMINF}"
    19 	if [ $? -ne 0 ] ; then
    20 		exit 1
    21 	elif [ ! -e ${STEAMINF}.new ] ; then
    22 		echo -e "Update (maybe) available but no steam.inf.new written!\n"
    23 	fi
    24 fi
    25 
    26 export RDTSC_FREQUENCY="disabled"
    27 export LD_LIBRARY_PATH=".:${ENGINE_PATH}/bin:$LD_LIBRARY_PATH"
    28 
    29 UPDATE=0
    30 if [ "$1" == "update" ] ; then
    31 	UPDATE=1
    32 elif [ "$1" == "auto" ] ; then
    33 	UPDATE=1
    34 fi
    35 
    36 if [ ${UPDATE} -eq 1 ] ; then
    37 	cd ${DD_PATH}
    38 
    39 	if [ $MOD == 0 ] ; then
    40 		#workaround for DD1 "bug" (won't redownload file of same name/size)
    41 		rm -f ${STEAMINF}.old
    42 		mv ${STEAMINF} ${STEAMINF}.old
    43 	fi
    44 
    45 	for i in 1 2 3 4 5
    46 	do
    47 		mono DepotDownloader.exe     \
    48 			-game "${DD_GAME}"   \
    49 			-dir ${DD_DIR}       \
    50 			-filelist server.txt \
    51 			-all-platforms
    52 
    53 		if [ $? == 0 ] ; then
    54 			break
    55 		elif [ $i == 5 ] ; then
    56 			echo -e "Update failed five times; giving up  �\(�_�)/�\n"
    57 			break
    58 		fi
    59 
    60 		echo -e "Update failed. Trying again in 30 seconds...\n"
    61 		sleep 30
    62 	done
    63 fi
    64 
    65 if [ "$1" == "auto" ] ; then
    66 	DOWNLOADED_VER=`grep -E "^(Patch)?Version=(([0-9]\.?)+)" ${STEAMINF} | grep -Eo "([0-9]\.?)+" | sed s/[^0-9]//g`
    67 	EXPECTED_VER=`cat ${STEAMINF}.new`
    68 
    69 	if [ ${DOWNLOADED_VER} != ${EXPECTED_VER} ] ; then
    70 		echo -e "Download resulted with version ${DOWNLOADED_VER}, but expected ${EXPECTED_VER}. Exiting.\n"
    71 		exit 1
    72 	fi
    73 fi
    74 
    75 # update sourcemod
    76 cd ${SM_PATH}/tools/gdc-psyfork
    77 hg pull -u
    78 
    79 echo -e "\n"
    80 for i in "${gamedata_files[@]}"
    81 do
    82 	./Release/gdc \
    83 	        -g ${GAME_DIR} \
    84         	-e ${ENGINE_NAME} \
    85 	        -f ${SM_PATH}/gamedata/$i \
    86         	-b ${GAME_BIN}${BIN_EXT}.so \
    87 	        -x ${ENGINE_BIN}${BIN_EXT}.so \
    88 	        -w ${GAME_BIN}.dll \
    89 	        -y ${ENGINE_BIN}.dll
    90 	echo -e "------------------------------------------------------\n"
    91 	echo -e "\n"
    92 done
    93 
    94 if [ ! -e ${STEAMINF} ] ; then
    95 	mv ${STEAMINF}.old ${STEAMINF}
    96 fi
    97 
    98 if [ "$1" == "auto" ] && [ -e ${STEAMINF}.new ] ; then
    99 	rm ${STEAMINF}.new
   100 fi
   101 
   102 exit 0