#!/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) wasteland=$(netstat -tn | grep -i 2222 | grep ESTABLISHED | wc -l) #Minecraft=$(($vanilla+$wasteland)) #(simpel) #mit vergleich: last=$(<.minecraftlog) #echo "last: $last" if [ $(($vanilla+$wasteland)) -gt 0 ]; then if [ "$last" == "1" ]; then Minecraft=$(($vanilla+$wasteland)) else echo "note: minecraft: $(($vanilla+$wasteland)) 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 } 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: output="$(lynx -dump -nolist http://www.Urbanterror.info/servers/91.250.87.150:27960/ | grep Slots | cut -c 18-19)" Urbanterror="${output// /}" #7daystodie: output="$(lynx -dump -nolist https://7daystodie-servers.com/server/60948/ | grep Players | cut -c 21-22)" daystodie="${output// /}" #echo $daystodie #Factorio: disconnected="$(grep -o "Disconnect notification" /home/factorio/factorio_0.15.31/factorio-current.log | wc -l)" connected="$(grep -o "JoinGame" /home/factorio/factorio_0.15.31/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" #Minecraft=3 #Teeworlds=10 #Urbanterror=2 #daystodie=1 #Factorio=1 #player oder players function: (OLD) players_function () { #./players_function input output if [ $1 -gt 1 ]; then echo "Players" else echo "Player" fi } #NEW mit schleifen #text funktion (-game: number player/players) +ausnahmen (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 } A="null" B="null" C="null" D="null" E="null" F="null" G="null" #falls mind einer online ist in text in variable schreiben: for game in Minecraft Teeworlds Urbanterror daystodie Factorio #list of games do #echo "$game: ${!game}" if [ ${!game} -gt 0 ]; then if [ "$A" == "null" ]; then #B="-$game: ${!game} $(players_function ${!game})" A=$(game_players_function $game) elif [ "$B" == "null" ]; then #B="-$game: ${!game} $(players_function ${!game})" B=$(game_players_function $game) elif [ "$C" == "null" ]; then #C="-$game: ${!game} $(players_function ${!game})" C=$(game_players_function $game) elif [ "$D" == "null" ]; then #D="-$game: ${!game} $(players_function ${!game})" D=$(game_players_function $game) elif [ "$E" == "null" ]; then #E="-$game: ${!game} $(players_function ${!game})" E=$(game_players_function $game) elif [ "$F" == "null" ]; then #F="-$game: ${!game} $(players_function ${!game})" F=$(game_players_function $game) elif [ "$G" == "null" ]; then #G="-$game: ${!game} $(players_function ${!game})" G=$(game_players_function $game) else echo "Error: too many games => for erweitern" fi fi done #echo "A$A" #echo "B$B" #echo "C$C" #echo "D$D" #echo "E$E" #echo "F$F" #echo "G$G" #convert: text reinschreiben: outputpath="/home/raidworld/www.raidworld.eu/secretfiles/other/banner-dynamic.jpg" posx=80 textcolor="blue" #colorlist: showrgb undercolor="gray70" #"none" for no color line=0 for input in "$A" "$B" "$C" "$D" "$E" "$F" "$G" do if [ "$input" != "null" ]; then #echo "$input accepted" echo "line$line: $input" posy=$((100+50*$line)) #####config: posy start position line=$(($line+1)) inputfile="./banner$line.jpg" ######config: input file path banner1.jpg outputfile="./banner$(($line+1)).jpg" #echo "inputfile: $inputfile" #echo "outputfile: $outputfile" gm convert -undercolor $undercolor -pointsize 40 -fill $textcolor -draw "text $posx, $posy \"$input" $inputfile $outputfile elif [ "$line" == "0" ]; then echo "=>noone playing... copying default image" cp ./banner1.jpg $outputpath ######config: input file path banner1.jpg sleep 2 echo "-----------------------------" break 1; else cp $outputfile $outputpath echo "-----------------------------" break 1; fi done chmod o+r $outputpath <<"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