diff --git a/FatFrank.otf b/FatFrank.otf new file mode 100644 index 0000000..dfbe776 Binary files /dev/null and b/FatFrank.otf differ diff --git a/banner-input.jpg b/banner-input.jpg index fa7db0b..ff874e4 100644 Binary files a/banner-input.jpg and b/banner-input.jpg differ diff --git a/generate-banner.sh b/generate-banner.sh index 21e2a3c..7bdd22a 100755 --- a/generate-banner.sh +++ b/generate-banner.sh @@ -7,17 +7,18 @@ 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)) -gt 0 ]; then +if [ $(($vanilla+$wasteland+$build)) -gt 0 ]; then if [ "$last" == "1" ]; then - Minecraft=$(($vanilla+$wasteland)) + Minecraft=$(($vanilla+$wasteland+$build)) else - echo "note: minecraft: $(($vanilla+$wasteland)) aber vorher 0 =>ignorieren" + echo "note: minecraft: $(($vanilla+$wasteland+$build)) aber vorher 0 =>ignorieren" echo "1" > .minecraftlog Minecraft=0 fi @@ -59,35 +60,53 @@ telnet_teeworlds_vanilla () { 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: +########################### +#######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 -#7daystodie: -output="$(lynx -dump -nolist https://7daystodie-servers.com/server/60948/ | grep Players | cut -c 21-22)" -daystodie="${output// /}" + + + + +########################## +###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_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" + + + +############################# +#######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 @@ -97,16 +116,14 @@ fi - - - -#Minecraft=3 -#Teeworlds=10 -#Urbanterror=2 +#Minecraft=2 +Minecraft=$((Minecraft+0)) +#Teeworlds=12 +#Urbanterror=4 #daystodie=1 -#Factorio=1 +#Factorio=2 -#player oder players function: (OLD) +#player or players function: (OLD) players_function () { #./players_function input output if [ $1 -gt 1 ]; then echo "Players" @@ -119,116 +136,96 @@ fi - - -#NEW mit schleifen - -#text funktion (-game: number player/players) +ausnahmen (NEW) +#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" + echo "-$1:${!1} Players" fi else if [ "$1" == "daystodie" ]; then echo "-7 Days to Die: ${!1} Player" else - echo "-$1: ${!1} Player" + echo "-$1: ${!1}Player" fi fi } -A="null" -B="null" -C="null" -D="null" -E="null" -F="null" -G="null" +#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 +} -#falls mind einer online ist in text in variable schreiben: + +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 [ "$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" + 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 -#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 + + +#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 -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 + + + 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 "-----------------------------" - break 1; else - cp $outputfile $outputpath + echo "TEXT: $text" + echo "=>noone playing... copying default image" + cp $inputpath $outputpath + sleep 1 echo "-----------------------------" - break 1; fi -done -chmod o+r $outputpath - - +chmod 666 $outputpath @@ -239,6 +236,13 @@ chmod o+r $outputpath + + +#/home/teamspeak/dynamic-banner/FatFrank-Free.otf + + + + <<"COMMENT" if false then diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..5807fe9 --- /dev/null +++ b/start.sh @@ -0,0 +1,7 @@ +#!/bin/bash + while true; do + echo $(date); + ./generate-banner.sh; + sleep 60; + done +}