mrdkoid init script
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          mrdkoid
  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
  10. # Description:       mrdkoid
  11. ### END INIT INFO
  12. set -e
  13.  
  14. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  15.  
  16. . /lib/lsb/init-functions
  17.  
  18. case "$1" in
  19.   start)
  20. #zapnuti mrdkoidu
  21.  
  22. echo ""
  23. echo "MRDKOID is starting up"
  24.  
  25. #maskarada
  26. echo ""
  27. echo "Setting up masquerade"
  28. beep -f 1000 -l 150
  29. iptables -A FORWARD -i wlan0 -o eth0 -s 192.168.1.0/24 -m state --state NEW -j ACCEPT
  30. iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
  31. iptables -A POSTROUTING -t nat -j MASQUERADE
  32. sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
  33. #dhcp
  34. iptables -A INPUT -p udp --destination-port 67:68 -j ACCEPT
  35. iptables -A OUTPUT -p udp --destination-port 67:68 -j ACCEPT
  36. iptables -t filter -A INPUT -i wlan0 -s foo.bar.0/24 -j ACCEPT
  37. #pristup k ap
  38. iptables -I FORWARD -p tcp -d 192.168.1.254 --dport 8080 -j ACCEPT
  39. iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 8080 -j DNAT --to-destination 192.168.1.254:80
  40. iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8080 -j DNAT --to-destination 192.168.1.254:80
  41. #fake dns
  42. echo ""
  43. echo "Setting up DNS"
  44. iptables -t nat -A PREROUTING -d 192.168.1.1 -p tcp --dport 53 -j DNAT --to-destination foo.bar.111
  45. iptables -t nat -A PREROUTING -d 192.168.1.1 -p udp --dport 53 -j DNAT --to-destination foo.bar.111
  46.  
  47. #vypis platby
  48. echo ""
  49. echo "Checking payment"
  50. beep -f 1000 -l 150
  51. PAY="/root/payment"
  52. if [ -f $PAY ] && [ "$(cat $PAY)" == "ok" ]
  53. then
  54. echo "Status: OK"
  55. elif [ -f $PAY ] && [ "$(cat $PAY)" != "ok" ]
  56. then
  57. echo "Status: NOT OK"
  58. fi
  59. #brzda
  60. /bin/brzda.sh
  61.  
  62. #blokace
  63. echo ""
  64. echo "Setting up IPTables"
  65. beep -f 1000 -l 150
  66. beep -f 1000 -l 150
  67. beep -f 1000 -l 150
  68. /bin/banovatko.sh
  69.  
  70. #wifi
  71. echo ""
  72. echo "Setting up auxiliary network settings"
  73. beep -f 1000 -l 150
  74. /sbin/iwconfig wlan0 power off
  75. /sbin/iwconfig wlan0 rate 54M
  76. #iptraf
  77. /usr/sbin/iptraf -i eth0 -B -L /var/log/iptraf/iptraf.log
  78.  
  79.  
  80. #ostatni
  81. beep -f 1000 -l 150
  82. echo ""
  83. echo "Setting up auxiliary system settings"
  84. #vynutit rotaci logu
  85. /usr/sbin/logrotate -f /etc/logrotate.d/iptraf
  86. #vypnout blanking
  87. setterm -powersave off 2> /dev/null
  88. setterm -powerdown 0
  89. setterm -blank 0
  90. #ntpdate-debian
  91. #hdparm -a 2048 -S 240 /dev/sda
  92. #hdparm -S120 /dev/sda
  93. #sleep 2s
  94. #/etc/init.d/udev stop
  95. #/etc/init.d/udev-mtab stop
  96.  
  97. beep -f 2000 -l 1500
  98.  
  99. echo ""
  100. echo "MRDKOID is up and running"
  101. echo ""
  102. ;;
  103.  
  104.   restart|reload|force-reload)
  105. #restart mrdkoidu
  106.  
  107. echo ""
  108. echo "MRDKOID is restarting services"
  109. echo ""
  110. /etc/init.d/mrdkoid stop 1> /dev/null
  111. /etc/init.d/mrdkoid start 1> /dev/null
  112. ;;
  113.  
  114.   stop)
  115. #vypnuti mrdkoidu
  116.  
  117. echo ""
  118. echo "MRDKOID is shutting down"
  119. echo ""
  120. beep -f 1000 -l 800
  121. iptables -F
  122. iptables -F -t nat
  123. killall -USR2 iptraf 2> /dev/null
  124.   ;;
  125. esac
  126.  
  127. exit 0
  128.  
Parsed in 0.021 seconds