Author Topic: some scripts for linux soldat admins  (Read 3282 times)

0 Members and 1 Guest are viewing this topic.

Offline ghengis_kahn

  • Major(1)
  • Posts: 23
  • look for g-k.ath.cx servers. all are welcome!
    • Genghis Khan is alive and well and running a game server in Atlanta
some scripts for linux soldat admins
« on: September 29, 2009, 12:43:58 pm »
EDIT: I have added and changed several scripts. hope someone will find these useful.
these scripts will add, delete servers and provide a easy way to stop and start servers.  it will add a line for each server to the /etc/hosts. it assumes you that you are going to have one directory where all the servers are going to be under and that there is a copy of the soldat server in there in a directory called soldat.  make sure to change the soldatdir variable to match your directory without a / on the end.  I just added them to my .bashrc
almost forgot. all you have to do is specify the server number on the command line, except for the ones with the word all in thier name, they will be executed on all the servers so you dont have to put a server number or the serverlist commands they list all the servers so you cant specify (yet)
so for server 1 you put
stopsoldat 1
or
startsoldat 1
or
delsoldat 1
or
addsoldat 1
yep thats all you have to do create your first server, then it gives you chance to edit the standard soldat.ini file you put in the soldat directory in your soldatdir directory.


startsoldat () {
               soldatdir='/your/dir';
               cd $soldatdir/soldat$1 ;
                nohup ./soldatserver -d 2  -b $(cat /etc/hosts|grep server$1|awk '{ print $1 }') -a 1  >>/var/log/soldat$1.log &               
               }
stopsoldat () {               
               for i in `seq 1 9`; do
              kill -$i $(ps aux |grep $(cat /etc/hosts|grep server$1|awk '{ print $1 }')|grep -v grep|awk '{ print $2 }')
              sleep 1;
              done
              }

 stopall ()
                {
                 soldatdir='/your/dir';
                 cd $soldatdir ;
                 for i in soldat{?,??} ; do
                     echo stopping $i;
                     echo stopsoldat $(echo $i|sed 's/soldat//') 
                     echo ---------------;
                 done;
                }
 startall ()
                {
                 soldatdir='/your/dir';
                 cd $soldatdir ;
                 for i in soldat{?,??} ; do
                     echo stopping $i;
                     echo startsoldat $(echo $i|sed 's/soldat//') 
                     echo ---------------;
                 done;
                }

addsoldat () {
              soldatdir='/your/dir';
             
               #first make sure it doesnt exist
               if [ -d "$soldatdir/soldat$1" ] ; then
                  echo already exists;
               else
               #second add it to /etc/hosts
               echo $(head -n1 <(comm -23 <(ifconfig |grep inet|grep -v inet6|grep -v 127.0.0.1|awk '{ print $2 }'|awk -F':' '{ print $2 }'|sort) <(grep -i local -v /etc/hosts|grep -v \#|awk '{ print $1 }'|grep -v '^$'|sort)))  server$1.cok                    server$1 >>/etc/hosts
               echo "added to /etc/hosts"
               #third create the directory
               mkdir $soldatdir/soldat$1
               echo created directory
               #fourth copy the files
               cp -R $soldatdir/soldat/* $soldatdir/soldat$1
               #choose config.
               #adding latter
               #edit config.
               vi $soldatdir/soldat$1/soldat.ini
               #run the server
               echo starting your newly created server
               startsoldat $1
               fi
              }
delsoldat () {
             soldatdir='/your/dir';
             
               #first make sure it does exist
               if [ ! -d "$soldatdir/soldat$1" ] ; then
                  echo doesnt exist;
               else
               #stop the server
               echo stopping server
               stopsoldat $1
               #second remove it to /etc/hosts
               grep -v server$1 /etc/hosts>/tmp/hosts.soldat
               echo "dont worry there is a backup in /tmp"
               rm /etc/hosts
               cp /tmp/hosts.soldat /etc/hosts
               echo "delete from /etc/hosts"
               #third delete the directory
               rm -Rf $soldatdir/soldat$1
               echo deleted directory
               fi
              }
due to scripting issues you have to add soldat to /etc/services
soldat          23073/tcp                       #soldat server
soldat          23073/udp                       #soldat server

adminsoldat () {
                soldatdir='/your/dir';
                echo the admin password for this server is $(grep '^Admin_Password'  $soldatdir/soldat$1/soldat.ini|awk -F '=' '{ print $2 }')
                telnet $(cat /etc/hosts|grep server$1|awk '{ print $1 }'|head -n 1) soldat             
               }

This is useful for posting in the adverts section, since they require alot of info this should be enough.

fullserverlist ()
                {
                 soldatdir='/your/dir';
                 cd $soldatdir ;
                 for i in soldat{?,??} ; do
                    echo ---------------;
                    echo $i;
                    echo ip=$(grep server$(echo $i|sed 's/soldat//') /etc/hosts|awk '{ print $1 }'|head -n 1);
                    grep "^Port" $i/soldat.ini;
                    grep "^Server_Name" $i/soldat.ini;
                    echo "Server Greeting Message";
                    grep "^Greeting_Message" $i/soldat.ini|awk -F'=' '{ print $2 }';
                    echo "END Server Greeting Message";
                    grep "^Server_Info" $i/soldat.ini;
          grep "^Respawn_Time" $i/soldat.ini;
          grep "^WaveRespawn_Time" $i/soldat.ini;
          grep "^Deathmatch_Limit" $i/soldat.ini;
          grep "^Pointmatch_Limit" $i/soldat.ini;
          grep "^Teammatch_Limit" $i/soldat.ini;
          grep "^Capture_Limit" $i/soldat.ini;
          grep "^Rambomatch_Limit" $i/soldat.ini;
          grep "^Infiltration_Limit" $i/soldat.ini;
          grep "^Hold_Limit" $i/soldat.ini;
                    case $(grep "^GameStyle" $i/soldat.ini|tr -d '\r'|awk -F '=' '{ print $2 }') in
                    0)
                     echo GameStyle is DEATH MATCH
                    ;;
                    1)
                     echo GameStyle is POINT MATCH
                    ;;
                    2)
                     echo GameStyle is TEAM MATCH
                    ;;
                    3)
                     echo GameStyle is CAPTURE THE FLAG
                    ;;
                    4)
                     echo GameStyle is RAMBO MATCH
                    ;;
                    5)
                     echo GameStyle is INFILTRATION
                    ;;
                    6)
                     echo GameStyle is  HOLD THE FLAG
                    ;;
                    esac
          grep "^Friendly_Fire" $i/soldat.ini;
          grep "^Guns_Collide" $i/soldat.ini;
          grep "^Kits_Collide" $i/soldat.ini;
          grep "^Loop_Maps" $i/soldat.ini;
          grep "^Bonus_Frequency" $i/soldat.ini;
          grep "^Bonus_FlameGod" $i/soldat.ini;
          grep "^Bonus_Predator" $i/soldat.ini;
          grep "^Bonus_Berserker" $i/soldat.ini;
          grep "^Bonus_Vest" $i/soldat.ini;
          grep "^Bonus_Cluster" $i/soldat.ini;
          grep "^Time_Limit" $i/soldat.ini;
          if [ "$(grep "^Weapon_1\=" $i/soldat.ini|tr -d '\r')" = "Weapon_1=1" ]; then echo "Deseret Eagles are on"; else echo "Deseret Eagles are off"; fi
          if [ "$(grep "^Weapon_2\=" $i/soldat.ini|tr -d '\r')" = "Weapon_2=1" ]; then echo "HK MP5 is on"; else echo "HK MP5 is off"; fi
          if [ "$(grep "^Weapon_3\=" $i/soldat.ini|tr -d '\r')" = "Weapon_3=1" ]; then echo "AK-74 is on"; else echo "AK-74 is off"; fi
          if [ "$(grep "^Weapon_4\=" $i/soldat.ini|tr -d '\r')" = "Weapon_4=1" ]; then echo "SteyrAUG is on"; else echo "SteyrAUG is off"; fi
          if [ "$(grep "^Weapon_5\=" $i/soldat.ini|tr -d '\r')" = "Weapon_5=1" ]; then echo "SPAS-12 is on"; else echo "SPAS-12 is off"; fi
          if [ "$(grep "^Weapon_6\=" $i/soldat.ini|tr -d '\r')" = "Weapon_6=1" ]; then echo "Ruger 77 is on"; else echo "Ruger 77 is off"; fi
          if [ "$(grep "^Weapon_7\=" $i/soldat.ini|tr -d '\r')" = "Weapon_7=1" ]; then echo "M79 is on"; else echo "M79 is off"; fi 
          if [ "$(grep "^Weapon_8\=" $i/soldat.ini|tr -d '\r')" = "Weapon_8=1" ]; then echo "Barret M82A1 is on"; else echo "Barret M82A1 is off"; fi
          if [ "$(grep "^Weapon_9\=" $i/soldat.ini|tr -d '\r')" = "Weapon_9=1" ]; then echo "FM Minimi is on"; else echo "FM Minimi is off"; fi
          if [ "$(grep "^Weapon_10\=" $i/soldat.ini|tr -d '\r')" = "Weapon_10=1" ]; then echo "XM214 Minigun is on"; else echo "XM214 Minigun is off"; fi
          if [ "$(grep "^Weapon_11\=" $i/soldat.ini|tr -d '\r')" = "Weapon_11=1" ]; then echo "USSOCOM is on"; else echo "USSOCOM is off"; fi
          if [ "$(grep "^Weapon_12\=" $i/soldat.ini|tr -d '\r')" = "Weapon_12=1" ]; then echo "Combat Knife is on"; else echo "Combat Knife is off"; fi
          if [ "$(grep "^Weapon_13\=" $i/soldat.ini|tr -d '\r')" = "Weapon_13=1" ]; then echo "Chainsaw is on"; else echo "Chainsaw is off"; fi
          if [ "$(grep "^Weapon_14\=" $i/soldat.ini|tr -d '\r')" = "Weapon_14=1" ]; then echo "LAW is on"; else echo "LAW is off"; fi
          grep "^Max_Grenades" $i/soldat.ini ;
          grep "^Survival_Mode" $i/soldat.ini ;
          grep "^Realistic_Mode" $i/soldat.ini ;
          grep "^Weapons_Mode" $i/soldat.ini ;
          grep "^Random_Bots\=" $i/soldat.ini ;
          echo bots on alpha team $(grep "^Random_Bots_1" $i/soldat.ini|sed '/s/Random_Bots_1//') ;
          echo bots on Bravo team $(grep "^Random_Bots_2" $i/soldat.ini|sed '/s/Random_Bots_2//') ;
          echo bots on Charlie team $(grep "^Random_Bots_3" $i/soldat.ini|sed '/s/Random_Bots_3//') ;
          echo bots on Delta team $(grep "^Random_Bots_4" $i/soldat.ini|sed '/s/Random_Bots_4//') ;
          if [ "$(grep "^Stationary_Guns\=" $i/soldat.ini|tr -d '\r')" = "Stationary_Guns=1" ]; then echo "Stationary Guns is on"; else echo "Stationary Guns is off"; fi
          grep "^Bullet_Time\=" $i/soldat.ini ;
          grep "^NoSniperLine\=" $i/soldat.ini ;
          echo Number of kills required in Advance Mode to gain a weapon $(grep "^Advance_Amount" $i/soldat.ini|sed 's/Advance\_Amount//') ;
          echo "Infiltration: Time for blue team to get points in seconds. $(grep "^Blue_Points_Time" $i/soldat.ini|sed 's/Blue_Points_Time//')" ;
          echo "Infiltration: Points awarded for a flag capture. $(grep "^Red_Points_Capture" $i/soldat.ini|sed 's/Red_Points_Capture//')" ;
          echo "Hold the Flag: Time for the teams to get points in seconds. $(grep "^HTF_Points_Time" $i/soldat.ini|sed 's/HTF_Points_Time//')" ;
          if [ "$(grep "^Radio\=" $i/soldat.ini|tr -d '\r'|head -n 1)" = "Radio=1" ]; then echo "Radio is on"; else echo "Radio is off"; fi
                    echo ------------------------------------------------------------------------;
                    echo                      MAP LIST
                    echo ------------------------------------------------------------------------;
                    cat $i/mapslist.txt
                  done;
                }



serverlist ()
                {
                 soldatdir='/your/dir';
                 cd $soldatdir ;
                 for i in soldat{?,??} ; do
                     echo ---------------;
                     echo $i;
                     echo ip=$(grep server$(echo $i|sed 's/soldat//') /etc/hosts|awk '{ print $1 }'|head -n 1);
                     grep "^Port" $i/soldat.ini;
                     grep "^Server_Name" $i/soldat.ini;
                 done;
                }
to see the output of full servers list look in the adverts section of the forum.                                                                         

these will ranomize your map files for you.
                                                                   
randommap ()
                {
                 soldatdir='/your/dir';
                 cd $soldatdir/soldat$1 ;
                 for i in `cat mapslist.txt`; do echo `printf "%08d" $RANDOM` $i; done | sort | colrm 1 9 >mapslist.txt.rand;
                 mv mapslist.txt mapslist.txt.old ;
                 mv mapslist.txt.rand mapslist.txt ;
                 cd ..
                }

randommapall ()
                {
                 soldatdir='/your/dir';
                 cd $soldatdir ;
                 for i in soldat{?,??} ; do
                     echo randomizing $i;
                     randommap $(echo $i|sed 's/soldat//') 
                     echo ---------------;
                 done;
                }
« Last Edit: October 01, 2009, 08:25:05 pm by ghengis_kahn »
Genghis Khan is alive and well and running a game server in Atlanta
look for g-k.ath.cx servers. all are welcome!
http://wiki.soldat.nl/Genghis-kahn
I run alot of  servers right now. dont think I can run many more but trying.
my favorite is rocket pistol, only pistols, law's and chainsaws allowed.
check out http://g-k.ath.cx/  I now have a server list page, http://g-k.ath.cx/cgi-bin/serverlist.cgi


Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5036
Re: some scripts for linux soldat admins
« Reply #2 on: September 29, 2009, 02:11:31 pm »
http://forums.soldat.pl/index.php?topic=35875.0

Thanks for posting something completely unrelated. ::)

ghengis_kahn, I'm moving this to the Fan Apps thread since this board is for pascal Soldat server scripting.
There are other worlds than these

Offline ghengis_kahn

  • Major(1)
  • Posts: 23
  • look for g-k.ath.cx servers. all are welcome!
    • Genghis Khan is alive and well and running a game server in Atlanta
Re: some scripts for linux soldat admins
« Reply #3 on: October 27, 2009, 12:11:49 am »
has anyone used these? I have been writing some bash based cgi scripts to provide server stats. Yes, thats right bash!!! I was thinking about posting them but if no one is using the current scripts I dont know if I should post the cgi script, for fear that all it will do is allow someone to get a idea on how to attack me and no one will get any benefit from it. if there are server admins that use these speak up and I will keep posting scripts and the cgi scripts I am writing allow people to monitor and control soldat.

http://g-k.ath.cx/cgi-bin/serverlist.cgi
Genghis Khan is alive and well and running a game server in Atlanta
look for g-k.ath.cx servers. all are welcome!
http://wiki.soldat.nl/Genghis-kahn
I run alot of  servers right now. dont think I can run many more but trying.
my favorite is rocket pistol, only pistols, law's and chainsaws allowed.
check out http://g-k.ath.cx/  I now have a server list page, http://g-k.ath.cx/cgi-bin/serverlist.cgi