Jump to content


dunno how to name it.


  • Please log in to reply
6 replies to this topic

#1 Guest_

Guest_
  • Guests

Posted 27 December 2009 - 11:44 PM

Well guys who I want to read this topic is ur www guy.

Two things... how to make somethin like this:

Posted Image

Was it ur idea and did u do all the programmin to make such a script?
and the other thing is how do You get that demo uploadin automatically on ur www when it appears in ur cstrike directory? Is it a well known script or did u write it urself?

Anyway can You share that info with me? I'm asking bcoz I myself got a server now and want to launch source tv and want to have that nice thing I showed in the img.

Thanks for Ur time and btw. Hi ppl that remeber me!

#2 k1ller

k1ller

    Admin

  • Moderators - Admin
  • 4,250 posts
457

Posted 28 December 2009 - 08:39 AM

The mappic + playerlist is a script done by Tim at Un4given: http://forum.un4give....php?f=16&t=651.

how do You get that demo uploadin automatically on ur www when it appears in ur cstrike directory?

It's a custom script which links demos from the cstrike directory to the web dir. It finds the last 30 days of demos in the cstrike dir and links them to the website. It's run in crontab every 5 minutes.
Posted Image

#3 Guest_

Guest_
  • Guests

Posted 28 December 2009 - 09:12 AM

Ok thanks, could You share that script with me?

Umm firstly I need to pack it up so I'm doin it that way:
BACKUP=/home/css/cstrike/demos/

DEM=/home/css/cstrike/

 

# Dla rar'a (jesli mamy na serverze funkcje rar)

rar a -df $BACKUP"`date +%d_%m_%Y-%H-%M-%S.rar`" $DEM*.dem

But now I need to check if that file exists and is complete, I mean it'll be when the map changes, but before that it's just growin larger and if I turn my crontab to every 30 mins (about 20-30 mins for a map) it still packs my uncomplete files and if there aren't any it packs nuthin makin a 46b packed file. Now there is another thing, when I have 3 demo files it'll pack them all up makin one file and I want each of .dem files to be packed as a single file... how?

Can You help me, coz google seems that doesn't like me :P

#4 k1ller

k1ller

    Admin

  • Moderators - Admin
  • 4,250 posts
457

Posted 28 December 2009 - 02:19 PM

Here's the script. You can add rar compression there yourself.

Bash scripts are very useful for this kind of things so it's worthwhile to learn the most common commands.
#!/bin/bash



# Links all except "last" file from one directory to somewhere else

# Update: 2007-03-25 links last file too



sourcedir="path/to/your/home/css/cstrike/"

targetdir="path/to/web/videos/"

storedays=31



for i in `(

    find $sourcedir -name "*dem" -ctime -$storedays -printf "%fn"

    (

	(

	    find $sourcedir -name "*dem" -ctime -$storedays -printf "%fn"

	    find $targetdir -name "*dem" -printf "%fn"

	) | sort | uniq -d

    )

) | sort | uniq -u`



  do

  ln -s $sourcedir/$i $targetdir/$i

done



# Remove old links

find $targetdir -type l -name "*dem" -ctime +$storedays | sort | xargs rm -f

Posted Image

#5 Guest_

Guest_
  • Guests

Posted 29 December 2009 - 12:36 AM

Yea I'm learnin bash but really slowly.

Um could You plz place some comments what does some parts of it do? I think I get it, but when I try to add packin it up by rar it crashes at my face sayin im so stupid.

Oh and if You got any really good site to learn bash at plz place the link in here.

#6 k1ller

k1ller

    Admin

  • Moderators - Admin
  • 4,250 posts
457

Posted 29 December 2009 - 08:32 AM

The structure there is
for i in (set of files); do smthing; done
Similar syntax can be used in Windows command line too. Very few seem to know about it, for example:
for %i in (*.jpg) do dir "%i"
You'll figure it out if you just put some time in to it. To add rar packing I guess you would do something like
rar a $targetdir/$i.rar $sourcedir/$i
instead of the ln command.

After that you can of course move files or do whatever stuff by
for i in ... do

rar a $targetdir/$i.rar $sourcedir/$i

mv $targetdir/$i.rar /www/videos

...other commands here...

done
You can also start from scratch and work your way from there. There's no need to learn 100% bash if you only need couple common commands. If you start from scratch you can come up with other just as good solution.

For example start with something simple like "ls *.dem", then expand it to "for i in `ls -1 *.dem` do echo $i; done". Then "for i in `ls -1 *.dem`; do echo rar -a $i.rar $i; done", then "for i in `ls -1 *.dem | tail -n 10`; do echo rar -a $i.rar $i; done". And so on ...
Posted Image

#7 k1ller

k1ller

    Admin

  • Moderators - Admin
  • 4,250 posts
457

Posted 31 December 2009 - 01:25 PM

Here's one more bash script example in relation to this map balance thread: viewtopic.php?f=2&t=988. You can find syntax highlighted version at http://pastebin.ca/1732993.

#!/bin/bash



TRAIL=10000

MAPS=( cs_office de_losttemple_pro de_train de_nuke de_dust2 de_cbble de_piranesi cs_italy de_siena de_aztec )



cd /home/css/csds/cstrike/logs



for map in "${MAPS[@]}"

do

    rounds=0

    diff=0

    sum=0

    avg=0

    data=$(ls -rtA /home/css/csds/cstrike/logs | tail -n $TRAIL | xargs grep "Loading map "$map"" | cut -f 1 -d ":" | cut -c 2-8 | sed 's/$/+1/' | bc | sed -e 's/^/L/' -e 's/$/.log/')

    for f in $(echo "$data")

    do

	data=$(cat "$f" | grep scored | tac | head -n 2)

	data=$(echo "$data" | sed '$!N;s/n/ /' | grep "CT.*TERRORIST|TERRORIST.*CT" | grep -E '[123][0-9]" players|[7-9]" players')

	if [ "$data" = "" ]

	then

	    continue

	fi

	diff=$(echo "$data" | cut -f 8,19 -d " " | tr -d '"' | tr ' ' '-' | bc | tr -d '-')

	rounds=$(($rounds + 1))

	sum=$(($sum + $diff))

    done



    avg=$(echo "scale=2; $sum / $rounds" | bc)

    echo "$map: $sum / $rounds = $avg"

done

Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users