Hi Guys,

I managed to patch together some code but now im a little stuck with getting through the rest of it, i want be able to use a script to start, stop, restart and update a cs server, under niether is what i have so far, to update the server i would normal have to locate the server directory and use the command "./steam -command update -game "Counter-Strike Source" -verify_all -dir /games/st0n3r/css_dust2/". any help would be great

#!/bin/sh

cd /games/st0n3r/css_dust2/

case "$1" in
start)
sudo screen -d -S cs ./srcds_run -game cstrike -port 30015 +ip 83.142.54.221 +maxplayers 33 +map de_dust2 +tv_port 30016 -autoupdate
;;

stop)
screen -r css_dust2 -X quit
echo Server Has Been Stopped!
;;

*)
echo "Usage: hlds {start|stop}"
exit 1
;;

esac
exit 0

Hello,

If I understand correctly, you want to add an update section to your case statement but the location of the 'steam' binary varies per server. If that is the case, you can try something like this:

update)
    steam_cmd=$(find / -name steam 2> /dev/null)
    if [ "$steam_cmd" ]; then
        $steam_cmd -command update -game "Counter-Strike Source" -verify_all -dir /games/st0n3r/css_dust2/
    else
        echo "Unable to locate the steam binary; cannot update"
        exit 1
    fi
;;

One recommendation... if you have a better idea of the whereabouts the binary, replace the "/" in the find command with something more accurate, perhaps "/games," otherwise the script will search the entire server for that binary and take some time.

Regards,
Tom

This article has been dead for over six months. Start a new discussion instead.