mrdkoid souhrn init script
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          mrdkoid-souhrn
  4. # Should-Start:      console-screen
  5. # Required-Start:    $network $local_fs
  6. # Required-Stop:     $network $local_fs
  7. # Default-Start:     2 3 4 5
  8. # Default-Stop:      0 1 6
  9. # Short-Description: mrdkoid-souhrn
  10. # Description:       mrdkoid-souhrn
  11. ### END INIT INFO
  12. set -e
  13.  
  14. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  15.  
  16. . /lib/lsb/init-functions
  17.  
  18. SOUHRN () {
  19. clear
  20. echo ""
  21. echo "souhrn - mrdkoid @ localhost"
  22. echo ""
  23. #uptime
  24. uptime=$(</proc/uptime)
  25. uptime=${uptime%%.*}
  26. seconds=$(( uptime%60 ))
  27. minutes=$(( uptime/60%60 ))
  28. hours=$(( uptime/60/60%24 ))
  29. days=$(( uptime/60/60/24 ))
  30. echo "MRDKOID je zapnut: $(echo $days dnu $hours hodin $minutes minut $seconds sekund)"
  31. echo ""
  32. #vypis platby
  33. if [ -f /root/payment ]
  34. then
  35. PAY=$(cat /root/payment)
  36. if [ "$PAY" == "ok" ]
  37. then
  38. PLATBA="\e[00;32mVse v poradku!\e[00m"
  39. elif [ "$PAY" != "ok" ]
  40. then
  41. PLATBA="\e[00;31mNEZAPLACENO\e[00m"
  42. fi
  43. else
  44. PLATBA="\e[01;31mOvereni selhalo\e[00m"
  45. fi
  46. echo -e "Stav platby: $PLATBA"
  47. echo ""
  48. #lze vypnout
  49. if [ "$(who)" != "" ]
  50. then
  51. HLASKA="\e[00;31mNevypinat!\e[00m"
  52. else
  53. HLASKA="\e[00;32mLze vypnout\e[00m"
  54. fi
  55. echo -e "Lze nyni MRDKOID vypnout?: $HLASKA"
  56. echo ""
  57. #rychlost spojeni
  58. echo "Rychlost bezdratoveho spojeni: $(/sbin/iwconfig wlan0 |grep -i rate |awk '{print $2 $3}' |sed 's/Rate=//g')"
  59. echo ""
  60. #kvalita spojeni
  61. echo "Kvalita bezdratoveho spojeni: $(/sbin/iwconfig wlan0 |grep -i link |awk '{print $2}' |sed 's/Quality=//g')"
  62. echo ""
  63. #uroven signalu
  64. echo "Uroven bezdratoveho signalu: $(/sbin/iwconfig wlan0 |grep -i link |awk '{print $4$5}' |sed 's/level=//g')"
  65. echo ""
  66. #disk
  67. echo "Volne misto na disku: $(df -h |grep sda1 |awk '{print $4" z celkovych "$2}')"
  68. echo ""
  69. #ram
  70. MEM=$(cat /proc/meminfo |grep Mem)
  71. echo "Vyuziti pameti RAM: $(echo $MEM |awk '{print $5" "$6" z celkovych "$2" "$3}')"
  72. echo ""
  73. echo ""
  74. echo ""
  75. #prihlaseni uzivatele
  76. echo "Aktualne prihlaseni uzivatele:"
  77. who |sed 's/10.0.0/foo.bar/g' > /tmp/usrs.tmp
  78. echo -e "\e[00;31m$(cat /tmp/usrs.tmp)\e[00m"
  79. rm /tmp/usrs.tmp
  80. }
  81.  
  82. case "$1" in
  83.   start)
  84. echo ""
  85. echo "MRDKOID is opening status script ..."
  86. echo ""
  87. sleep 2s
  88. until (())
  89. do
  90. SOUHRN
  91. sleep 120s
  92. done
  93. ;;
  94.   stop)
  95. kill -9 $(pidof sleep)
  96. kill -9 $(pidof -x mrdkoid-init-souhrn.sh)
  97. ;;
  98.   *)
  99. #do nothing
  100. ;;
  101. esac
  102.  
Parsed in 0.035 seconds