#!/bin/bash #echo "$(date)" #uptime: uptime=$(awk '{printf "%.2f\n",$1/86400}' /proc/uptime) #Minecraft: vanilla=$(netstat -tn | grep -i 25565 | grep ESTABLISHED | wc -l) build=$(netstat -tn | grep -i 1234 | grep ESTABLISHED | wc -l) wasteland=$(netstat -tn | grep -i 2222 | grep ESTABLISHED | wc -l) #Minecraft=$(($vanilla+$wasteland)) #(simpel) #mit vergleich: last=$(<.minecraftlog) #echo "last: $last" if [ $(($vanilla+$wasteland+$build)) -gt 0 ]; then if [ "$last" == "1" ]; then Minecraft=$(($vanilla+$wasteland+$build)) else echo "note: minecraft: $(($vanilla+$wasteland+$build)) aber vorher 0 =>ignorieren" echo "1" > .minecraftlog Minecraft=0 fi else echo "0" > .minecraftlog Minecraft=0 fi #Teeworlds: telnet_teeworlds_zcatch () { expect << EOF spawn telnet -e q raidworld.net 6431 #expect -re ".*>" sleep 0.1 send "jiawkose\r" sleep 0.1 send "status\r" #send "status\r" #send "status\r" sleep 0.2 send "q\r" expect -re ".*>" EOF } telnet_teeworlds_vanilla () { expect << EOF spawn telnet -e q raidworld.net 6432 #expect -re ".*>" sleep 0.1 send "jiawkose\r" sleep 0.1 send "status\r" #send "status\r" #send "status\r" sleep 0.2 send "q\r" expect -re ".*>" EOF } echo "debug: fetching teeworlds players via telnet..." tw_zcatch="$(telnet_teeworlds_zcatch | sed 's/^..//' | grep -o 'rver]: id=' | wc -l)" tw_vanilla="$(telnet_teeworlds_vanilla | sed 's/^..//' | grep -o 'rver]: id=' | wc -l)" Teeworlds=$(($tw_zcatch+$tw_vanilla)) ########################### #######Urbanterror:######## echo "debug: fetching urbanterro players via lynx" output="$(lynx -dump -nolist http://www.Urbanterror.info/servers/91.250.87.150:27960/ | grep Slots | cut -c 18-19)" Urbanterror="${output// /}" Urbanterror=0 ########################## ###3####7daystodie:####### ###echo "debug: fetching 7daystodie players via lynx" ###output="$(lynx -dump -nolist https://7daystodie-servers.com/server/60948/ | grep Players | cut -c 21-22)" ###daystodie="${output// /}" #echo $daystodie daystodie=0 ############################# #######Factorio:################# ### disconnected="$(grep -o "Disconnect notification" /home/factorio/factorio/factorio-current.log | wc -l)" ### connected="$(grep -o "JoinGame" /home/factorio/factorio/factorio-current.log | wc -l)" ### #echo "Factorio-disconnected: $disconnected" ### #echo "Factorio-connected: $connected" ### if [ $(($connected - $disconnected)) -gt 0 ]; then ### Factorio=$(($connected - $disconnected)) ### else ### Factorio=0 ### fi ### ##echo "=>Factorio-Players: $Factorio" Factorio=0 #Minecraft=2 Minecraft=$((Minecraft+0)) #Teeworlds=12 #Urbanterror=4 #daystodie=1 #Factorio=2 #player or players function: (OLD) players_function () { #./players_function input output if [ $1 -gt 1 ]; then echo "Players" else echo "Player" fi } #text function (-game: number player/players) +exeptions (NEW) game_players_function () { #./players_function input output if [ ${!1} -gt 1 ]; then if [ "$1" == "daystodie" ]; then echo "-7 Days to Die: ${!1} Players" else echo "-$1:${!1} Players" fi else if [ "$1" == "daystodie" ]; then echo "-7 Days to Die: ${!1} Player" else echo "-$1: ${!1}Player" fi fi } #text function (-game: number player/players) +exeptions (NEW) game_players_function_ohne_minus () { #./players_function input output if [ ${!1} -gt 1 ]; then if [ "$1" == "daystodie" ]; then echo "7 Days to Die: ${!1} Players" else echo "$1: ${!1} Players" fi else if [ "$1" == "daystodie" ]; then echo "7 Days to Die: ${!1} Player" else echo "$1: ${!1} Player" fi fi } firstgame=1 text="null" #when at least one player is online, write text to variable echo "debug: checking if at least one player online" for game in Minecraft Teeworlds Urbanterror daystodie Factorio #list of games do #echo "$game: ${!game}" if [[ ${!game} -gt 0 ]]; then if [ $firstgame -eq 1 ]; then text=$(game_players_function_ohne_minus $game) firstgame=0 else text="$text | $(game_players_function_ohne_minus $game)" fi fi done #convert: add text: #inputpath="/home/raidworld/www.raidworld.eu/secretfiles/other/Raidworld_Banner_meanwhile_default.jpg" #outputpath="/home/raidworld/www.raidworld.eu/secretfiles/other/Raidworld_Banner_meanwhile_dynamic.jpg" inputpath="/var/www/files.raidworld.net/teamspeak/Banner_original.jpg" outputpath="/var/www/files.raidworld.net/teamspeak/Banner_dynamic.jpg" #outputpath="/home/raidworld/www.raidworld.net/wordpress/wp-content/uploads/ts-banner/Raidworld_Banner_final-dynamic.jpg" posx=78 posy=52 textcolor="gray49" #colorlist: showrgb undercolor="none" #"none" for no color line=0 if [ "$text" != "null" ]; then echo "debug: generating banner" echo "TEXT: $text" gm convert -font /home/teamspeak/dynamic-banner/FatFrank.otf -undercolor $undercolor -pointsize 40 -fill black -draw "text $(($posx+1)), $(($posy+1)) \"$text" $inputpath "./banner-temp.jpg" gm convert -font /home/teamspeak/dynamic-banner/FatFrank.otf -pointsize 40 -fill $textcolor -draw "text $posx, $posy \"$text" "./banner-temp.jpg" $outputpath echo "-----------------------------" else echo "TEXT: $text" echo "=>noone playing... copying default image" cp $inputpath $outputpath sleep 1 echo "-----------------------------" fi chmod 666 $outputpath #/home/teamspeak/dynamic-banner/FatFrank-Free.otf <<"COMMENT" if false then ###OLD (ohne schleifen) ############################################################################# players_function () { #./players_function input output if [ $1 -gt 1 ]; then echo "Players" else echo "Player" fi } if [ $minecraft -gt 0 ]; then A="-Minecraft: $minecraft $(players_function $minecraft)" if [ $teeworlds -gt 0 ]; then B="-Teeworlds: $teeworlds $(players_function $teeworlds)" if [ $urbanterror -gt 0 ]; then C="-Urbanterror: $urbanterror $(players_function $urbanterror)" fi elif [ $urbanterror -gt 0 ]; then B="-Urbanterror: $urbanterror $(players_function $urbanterror)" fi elif [ $teeworlds -gt 0 ]; then A="-Teeworlds: $teeworlds $(players_function $teeworlds)" if [ $urbanterror -gt 0 ]; then B="-Urbanterror: $urbanterror $(players_function $urbanterror)" fi elif [ $urbanterror -gt 0 ]; then A="-Urbanterror: $urbanterror $(players_function $urbanterror)" fi #echo "a=$A" #echo "b=$B" #echo "c=$C" pos1="text 80,100" pos2="text 80,150" pos3="text 80,200" textcolor="blue" #colorlist: showrgb undercolor="gray70" #"none" for no color if [ "$A" != "null" ] && [ "$B" != "null" ] && [ "$C" != "null" ]; then #convert -font /usr/share/fonts/OTF/Z003-MediumItalic.otf -pointsize 40 -fill blue -draw "$pos1 \"$A" banner.jpg banner1.jpg gm convert -undercolor $undercolor -pointsize 40 -fill $textcolor -draw " $pos1 \"$A" /home/teamspeak/dynamic-banner/banner.jpg /home/teamspeak/dynamic-banner/banner1.jpg gm convert -undercolor $undercolor -pointsize 40 -fill $textcolor -draw " $pos2 \"$B" /home/teamspeak/dynamic-banner/banner1.jpg /home/teamspeak/dynamic-banner/banner2.jpg gm convert -undercolor $undercolor -pointsize 40 -fill $textcolor -draw " $pos3 \"$C" /home/teamspeak/dynamic-banner/banner2.jpg /home/teamspeak/dynamic-banner/banner3.jpg #echo 123 elif [ "$A" != "null" ] && [ "$B" != "null" ]; then gm convert -undercolor $undercolor -pointsize 40 -fill $textcolor -draw "$pos1 \"$A" /home/teamspeak/dynamic-banner/banner.jpg /home/teamspeak/dynamic-banner/banner1.jpg gm convert -undercolor $undercolor -pointsize 40 -fill $textcolor -draw "$pos2 \"$B" /home/teamspeak/dynamic-banner/banner1.jpg /home/teamspeak/dynamic-banner/banner3.jpg #echo 12 elif [ "$A" != "null" ]; then gm convert -undercolor $undercolor -pointsize 40 -fill $textcolor -draw "$pos1 \"$A" /home/teamspeak/dynamic-banner/banner.jpg /home/teamspeak/dynamic-banner/banner3.jpg #echo 1 else cp /home/teamspeak/dynamic-banner/banner.jpg /home/teamspeak/dynamic-banner/banner3.jpg fi #convert -background black -fill white \ #-font Helvetica -pointsize 14 \ ##-border 10 -bordercolor black \ #label:@- cmd.png cp /home/teamspeak/dynamic-banner/banner3.jpg /home/raidworld/www.raidworld.eu/secretfiles/other/banner3.jpg chmod o+r /home/raidworld/www.raidworld.eu/secretfiles/other/banner3.jpg #convert -pointsize 40 -fill blue -draw "text 100,500 \"-Uptime: $uptime Days" banner.jpg banner1.jpg #convert -pointsize 40 -fill green -draw "text 100,550 \"-Minecraft: $minecraft Players" banner1.jpg banner2.jpg #convert -pointsize 40 -fill orange -draw "text 100,600 \"-Teeworlds: $teeworlds Players" banner2.jpg banner3.jpg #cp banner3.jpg /home/raidworld/www.raidworld.eu/secretfiles #chmod 777 /home/raidworld/www.raidworld.eu/secretfiles/banner3.jpg #sleep 1 #convert -gravity south -fill white -pointsize 30 -annotate 0 'Teeworlds: 6 Players online' banner.jpg banner2.jpg #convert test.jpg -gravity south -fill white -pointsize 70 -annotate 0 '2-Gang Riemengetriebe # ' test1.jpg #convert test.jpg -pointsize 100 -comment '2-Gang Getriebe' test2.jpg #convert test.jpg -fill white -pointsize 75 -annotate 0 -caption '2-Gang Riemengetriebe' test1.jpg fi COMMENT