- enable local DNS server by default, set primary DNS server for MyPLC
[myplc.git] / host.init
index 5c22f9c..0f46162 100755 (executable)
--- a/host.init
+++ b/host.init
@@ -6,7 +6,7 @@
 #
 # description: Manages all PLC services on this machine
 #
-# $Id: host.init,v 1.3 2006/04/07 17:12:52 mlhuang Exp $
+# $Id: host.init,v 1.6 2006/04/20 09:01:00 thierry Exp $
 #
 
 PATH=/sbin:/bin:/usr/bin:/usr/sbin
@@ -37,7 +37,7 @@ mounted ()
     fi
 }
 
-start ()
+mount_plc ()
 {
     echo -n $"Mounting PLC: "
 
@@ -60,17 +60,21 @@ start ()
     [ $ERRORS -eq 0 ] && success $"PLC unmount" || failure $"PLC unmount"      
     echo
 
-    chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS start $*
-    check
 }
 
-stop ()
+start ()
 {
-    if mounted $PLC_ROOT ; then
-       chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS stop $*
-       check
+    # Starting everything
+    if [ -z "$1" ] ; then
+       mount_plc 
     fi
 
+    chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS start $*
+    check
+}
+
+umount_plc ()
+{
     echo -n $"Unmounting PLC: "
 
     for dir in $PLC_ROOT/proc $PLC_ROOT/data $PLC_ROOT ; do
@@ -84,6 +88,30 @@ stop ()
     echo
 }
 
+stop ()
+{
+    if mounted $PLC_ROOT ; then
+       chroot $PLC_ROOT /sbin/service plc $PLC_OPTIONS stop $*
+       check
+    fi
+
+    # Stopped everything
+    if [ -z "$1" ] ; then
+       umount_plc
+    fi
+}
+
+mount_status ()
+{
+  lines=$(mount | grep $PLC_ROOT)
+  if [ -z "$lines" ] ; then
+    echo "==== $PLC_ROOT is *not* mounted"
+  else
+    echo "==== The following mount points remain active"
+    echo "$lines"
+  fi
+}
+
 # Get command
 shift $(($OPTIND - 1))
 command=$1
@@ -101,8 +129,16 @@ case "$command" in
        start $*
        ;;
 
+    mount|umount)
+        ${command}_plc $*
+       ;;
+
+    mountstatus)
+        mount_status $*
+       ;;
+  
     *)
-       echo "Usage: $0 {start|stop|restart}"
+       echo "Usage: $0 {start|stop|restart|mount|umount|mountstatus}"
        RETVAL=1
        ;;
 esac