Преглед изворни кода

fbvncserver start verbessert

Reinhard Russinger пре 6 година
родитељ
комит
bf54b111bc

+ 1 - 1
board/GfA/Display001/BUILD

@@ -1 +1 @@
-628
+631

+ 40 - 0
board/GfA/Display001/rootfs/etc/init.d/S99civetweb

@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Start App	
+#
+#
+APPNAME=civetweb
+APPBIN=/usr/bin/civetweb # full qualified applicationpath
+APPPAR="-document_root /var/GfA/WebVnc/novnc/ -enable_directory_listing no -listening_ports 8080"
+
+
+case "$1" in
+  start)
+        echo -e "Starting ${APPNAME} ...\n"
+	if [ ! -f ${APPBIN} ]; then
+		echo -e "Program ${APPBIN} doesn't exist \n"
+		exit 1
+	fi 
+        screen -dmS ${APPNAME} sh -c "while true; do ${APPBIN} ${APPPAR}; echo '${APPNAME} stopped--> restart'; sleep 2;done"
+        exit 0
+        ;;
+  stop)
+        echo -e "Stopping ${APPNAME} ...\n"
+        KILLPID=`screen -list | grep ${APPNAME} | awk -F'.' '{print $1}'`
+        if [ ${#KILLPID} != "0" ]
+                then
+                kill $KILLPID
+         fi
+         exit 0
+        ;;
+  restart|reload)
+        "$0" stop
+        "$0" start
+        ;;
+  *)
+        echo "Usage: $0 {start|stop|restart}"
+        exit 1
+esac
+
+exit $?
+

+ 20 - 8
board/GfA/Display001/rootfs/etc/init.d/S99fbvncserver

@@ -1,18 +1,29 @@
 #!/bin/sh
 #
-# Start fbvncserver
+# Start App	
 #
-
+#
+APPNAME=fbvncserver
+APPBIN=/usr/sbin/fbvncserver
+APPPAR="-t /dev/input/event1 -k /dev/null -P /etc/vncpwd"
 case "$1" in
   start)
-        echo -e "Starting fbvncserevr ...\n"
-        fbvncserver -t /dev/input/event1 -k /dev/null -P /etc/vncpwd &
-	civetweb -document_root /var/GfA/WebVnc/novnc/ -enable_directory_listing no -listening_ports 8080 &
+        echo -e "Starting ${APPNAME} ...\n"
+	if [ ! -f ${APPBIN} ]; then
+		echo -e "Program ${APPBIN} doesn't exist \n"
+		exit 1
+	fi 
+        screen -dmS ${APPNAME} sh -c "while true; do ${APPBIN} ${APPPAR}; echo '${APPNAME} stopped--> restart'; sleep 2;done"
+        exit 0
         ;;
   stop)
-        echo -e "Stopping fbvncserver ...\n"
-        killall civetweb
-        killall fbvncserver
+        echo -e "Stopping ${APPNAME} ...\n"
+        KILLPID=`screen -list | grep ${APPNAME} | awk -F'.' '{print $1}'`
+        if [ ${#KILLPID} != "0" ]
+                then
+                kill $KILLPID
+         fi
+         exit 0
         ;;
   restart|reload)
         "$0" stop
@@ -24,3 +35,4 @@ case "$1" in
 esac
 
 exit $?
+