added inetd and some other stuffs
[wyse_ntpd.git] / src / buildroot-2013.05 / custom / filesystem / etc / init.d / S99final_sequence
index d9e113e..2cede64 100755 (executable)
@@ -7,6 +7,11 @@ else
        mkdir -p /fs/config/
 fi
 
+mkdir /var/www/data/stats
+chmod 777 /var/www/data/stats
+mkdir /var/www/data/logs
+chmod 777 /var/www/data/logs
+
 if [ ! -f /fs/config/dropbear.tar ]
 then
        RD=`pwd`
@@ -23,20 +28,28 @@ fi
 
 if [ -d /var/www/data ]
 then
+       /opt/reboot_daemon.sh > /var/www/data/logs/reboot_daemon 2>&1 &
+       /opt/restart_ssh_daemon.sh > /var/www/data/logs/restart_ssh_daemon 2>&1 &
+       /opt/stats_daemon.sh > /var/www/data/logs/stats_daemon 2>&1 &
+fi
 
-       mknod /var/www/data/reboot p
-       chmod 644 /var/www/data/reboot
-       (echo "Rebooting..." > /var/www/data/reboot; reboot)&
-
-       mknod /var/www/data/restart_ssh p
-       chmod 644 /var/www/data/restart_ssh
-       (echo "SSH Restart" > /var/www/data/restart_ssh; /etc/init.d/S50dropbear restart)&
 
-       cldate=`date '+%d.%m.%Y'`
-       touch /var/www/data/ntp.log.$cldate
-       chmod 644 /var/www/data/ntp.log.$cldate
+if [ -f /fs/config/inetd.conf ]
+then
+       /usr/sbin/inetd /fs/config/inetd.conf
+else 
+       # this is a little silly, i should really be a little more useful with this
+cat > /fs/config/inetd.conf << EOF
+20010 stream tcp nowait root reboot
+20011 stream tcp nowait root sh
+20012 stream tcp nowait root ntpq ntpq -c lpe -n
+20013 stream tcp nowait root ps ps -ef
+20014 stream tcp nowait root free
+EOF
+       /usr/sbin/inetd /fs/config/inetd.conf
 
-       (sleep 30; while(true); do date '+%s' >> /var/www/data/ntp.log.$cldate; ntpq -c lpe -n |grep "127.127.20" >> /var/www/data/ntp.log.$cldate; sleep 30; done) &
 fi
 
-mkdir /var/www/data/stats
+# work around problems with thttpd startup and its stupid stats output (which spams syslog when the time jumps too much)
+killall -9 thttpd_wrapper
+killall -9 thttpd