bash cgi mrdkoid souhrn.sh
  1. #!/bin/sh
  2. cat << EOF
  3. Content-Type: text/html
  4.  
  5. <html>
  6. <head>
  7. <title>souhrn - mrdkoid @ localhost</title>
  8. <link rel="shortcut icon" href="data:image/x-ico;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAPbSURBVHjaYpwx4zgDDuDEzsZix8jIwMAIhMjgPxCzszFb/f33Tx8ggFhevHgFFmRiYmT4+/cvAyNIB1ADkO8ooyRQ8/v/T4Zf//4w/AfKM/39B9XOwPCPkYPhw9tfnwACiJGNjQsswM/Pz8DCwsLw8eNHhj9//jD8/fVfpmSWw1VNbW2+C3cfMgh++crwQU6YgYmFmYGNlZXh9qdLDBtrL20GCCCWX7++gQ348YOJQUREhOHtm+8Mv37/ZhA1Y3tvJPrtv7OBBAOrwEcGxVcsDN8tTRl+sn5l+M70iEHolQTDmv8nPwIEEAvMX0xMzAz//v0HawYClq/v/jCz8vD8f/X9NcMN/v8Mr6UlGX6/P83Ayy/GYLnvOcMLLqDXWRmYAAIIbsC/f/9AXjCzsLDI+Pnzp9aTRy+/7V93n0tZ05BB5KUiw4/LHxk+a3xk+Mr5l4H7wx8GJgawRQwAAQQ3QFBQMLCmpmahs7Mz7759BxgePHzI8O7ZS4aqmr0MQk6CDLLvNBg41QQZ3n18znBWX57h03dg2P05wwAQQExQ/ZIGBgYz/Pz8eGVlZRl+/frLEBwSwjBxxmSGn0/4GHbtOM/A7cfA8PXPN4bvP34xnDnFzPD6rBQDOysLA0AAwVwQ+OHDe7F9+44wODkrMNiadDCI/49gOLDfm+HyxfPAkJdl+PeDjeHTv68MPKyCDJfEtzB8/vKd4e+ffwwAAQRygQgQx1++fIXh+/cvDDy8SgwaauEMvOLWDCJiogwSUtIMXz/eYrh/4AFQoQID/3dphp9SnxjeiL0FhxtAADEDNa8GYgczMzOGnp5uBlYWDoZvfxwZ3v8UB6U2BmVlNYYDB/YyvDz9noGfW4hB5L4yg5qaJsObn68Z7m95dxkggEAumADE22NiohmYmZkZPn/+xvD+/RuGD+/eMDx//opBVESaQdvIgMHATo/hPx8jw/pLqxkefXjCoMFpyPAfmDABAggUBruB+I24uKwdMAlwv3v/jeHL508Mnz59Bxr2k+Hzux8M0s7yDKauWgz3vt5kYJNnYvjM8ZmB6w8fOFUDBBAzCws43b9iYPymY2Uto/P541eGL18YgJq/MDD+f8Jw5tYmhkNsBxjOMVxmePj5EQMrKxPDz/+/Ga6+u8Tw6sDnGwABxFhfzwQSzIoOk5+qIPKb4eelTwwbL8UzaDk/Z9BRucvw+95lhhUrfzHErQGawMzwBpo1GYFsRoYHDIcBAohRRRnIY2JQ09dgrBJh+S/95D7D731XGc4pqzMwmGsyGDB8ZmA/d4nh3flnDEuBLj4BzY6MUPwPIMAA9ORio5qu/OAAAAAASUVORK5CYII=" type="image/x-icon">
  9. <meta http-equiv="refresh" content="60">
  10. </head>
  11. <body>
  12. EOF
  13.  
  14. #hlaska
  15. if [ "$(who)" != "" ]; then HLASKA='<br><center><blink><font color="red" style="font-size: 60px; font-weight: bold; font-variant: small-caps;">NEVYPINAT!</font></blink></center><br><br>'; fi
  16. echo $HLASKA
  17.  
  18. echo "<h1>souhrn pro mrdkoid:</h1>"
  19. echo "<pre>"
  20.  
  21. #uptime
  22. uptime=$(</proc/uptime)
  23. uptime=${uptime%%.*}
  24. seconds=$(( uptime%60 ))
  25. minutes=$(( uptime/60%60 ))
  26. hours=$(( uptime/60/60%24 ))
  27. days=$(( uptime/60/60/24 ))
  28. echo "<strong>MRDKOID je zapnut:</strong>" '<font color="#585858" style="font-weight: bold; font-variant: small-caps;">' $(echo $days dni $hours hodin $minutes minut $seconds sekund) "</font> <br>"
  29.  
  30. #vypis platby
  31. PAY=$(sudo cat /root/payment)
  32. if [ "$PAY" == "ok" ]
  33. then
  34. PLATBA='<font color="green" style="font-weight: bold; font-variant: small-caps;">Vse v poradku!</font>'
  35. elif
  36. [ "$PAY" != "ok" ]
  37. then
  38. PLATBA='<font color="red" style="font-weight: bold; font-variant: small-caps;">NEZAPLACENO</font>'
  39. fi
  40. echo "<strong>Stav platby:</strong>" '<font color="red" style="font-weight: bold; font-variant: small-caps;">' $PLATBA '</font> <br>'
  41.  
  42. #lze vypnout
  43. if [ "$(who)" != "" ]
  44. then HLASKA2='<font color="red" style="font-weight: bold; font-variant: small-caps;">Nevypinat!</font>'
  45. else
  46. HLASKA2='<font color="green" style="font-weight: bold; font-variant: small-caps;">Lze vypnout</font>'
  47. fi
  48. echo "<strong>Lze nyni MRDKOID vypnout?:</strong>" $HLASKA2 "<br>"
  49.  
  50. #rychlost spojeni
  51. echo "Rychlost bezdratoveho spojeni:" '<font color="#585858" style="font-weight: bold; fotn-variant: small-caps;">' $(/sbin/iwconfig wlan0 |grep -i rate |awk '{print $2 $3}' |sed 's/Rate=//g') '</font> <br>'
  52.  
  53. #kvalita spojeni
  54. echo "Kvalita bezdratoveho spojeni:" '<font color="#585858" style="font-weight: bold; font-variant: small-caps;">' $(/sbin/iwconfig wlan0 |grep -i link |awk '{print $2}' |sed 's/Quality=//g') '</font><br>'
  55.  
  56. #uroven signalu
  57. echo "Uroven bezdratoveho signalu:" '<font color="#585858" style="font-weight: bold; font-variant: small-caps;">' $(/sbin/iwconfig wlan0 |grep -i link |awk '{print $4$5}' |sed 's/level=//g') '</font> <br>'
  58.  
  59. #disk
  60. echo "Volne misto na disku:" '<font color="#585858" style="font-weight: bold; font-variant: small-caps;">' $(df -h |grep sda1 |awk '{print $4" z celkovych "$2}') '</font><br>'
  61.  
  62. #ram
  63. MEM=$(cat /proc/meminfo |grep Mem)
  64. echo "Vyuziti pameti RAM:" '<font color="#585858" style="font-weight: bold; font-variant: small-caps;">' $(echo $MEM |awk '{print $5" "$6" z celkovych "$2" "$3}') '</font><br>'
  65.  
  66. #prihlaseni uzivatele
  67. echo "<br><br><br><strong>Aktualne prihlaseni uzivatele:</strong>" $(who |sed 's/10.10.10/foo.bar/g' > /tmp/usrs.tmp) '<pre><font color="red">' $(cat -E /tmp/usrs.tmp |sed 's/\$/<br>/g'; rm /tmp/usrs.tmp) "</font></pre><br>"
  68. cat << EOF
  69. </pre>
  70. </body>
  71. </html>
  72. EOF
  73.  
Parsed in 0.045 seconds