Add pinentry for gnupg
[hvlinux.git] / stage2 / bootscripts / mountnetfs
index d397af7..893792f 100755 (executable)
@@ -7,13 +7,46 @@ source /etc/rc.d/init.d/functions
 
 log_script_name "$0 $*"
 
+# Load global network parameters
+source /etc/sysconfig/network/network-parameters
+
+# Make sure networking is up. If not, this bootscript will wait forever
+if [ ! -f "${NETWORKING_UP_FILE}" ]; then
+    msg_log "${0}: Network is down"
+    exit ${EXIT_CODE_WARNING}
+fi
+
+mountnetfs_start() {
+    if ! grep -q "_netdev" /etc/fstab; then
+        msg_log "No network filesystem found in fstab"
+        exit ${EXIT_CODE_SUCCESS}
+    fi
+
+    if grep -q "nfs" /etc/fstab; then
+        # rpc.statd is required to mount nfs shares
+        if [ ! -x /sbin/rpc.statd ]; then
+            msg_log "Missing rpc.statd executable"
+            exit ${EXIT_CODE_WARNING}
+        fi
+
+       if ! statusproc rpc.statd | grep -q "running"; then
+            cmd_run_log_box "Starting rpc.statd" loadproc rpc.statd
+        fi
+    fi
+
+    # Walk through /etc/fstab and mount all file systems that have the
+    #_netdev option set in the fs_mntops field (the 4th field. See man
+    # fstab for more info).
+    cmd_run_log_box "Mounting network file systems" mount -a -O _netdev
+}
+
 mountnetfs_stop() {
     # The following line obtains a list from the output of
     # mount for all netfs types and anything that was
     # mounted with the _netdev option.
     NETMOUNTS=`/bin/mount \
         | /bin/grep '_netdev\|smbfs\|ncpfs|\coda\|nfs' \
-       | /usr/bin/cut -d " " -f 3 | /bin/sed 's/$/ /g'`
+       | /usr/bin/cut -d " " -f 3 | /bin/sed ':a;$!N;s/\n/ /;ta'`
 
     # Check to see if anything was listed from above
     # (see if anything is actually needs to be unmounted)
@@ -21,13 +54,13 @@ mountnetfs_stop() {
        # There is something mounted
        # Try and stop processes the nice way
        # (probably won't work in most cases)
-       /bin/fuser -TERM -m $NETMOUNTS > /dev/null
-       
+       /bin/fuser -SIGTERM -km $NETMOUNTS > /dev/null
+
        # Check and see if it found anything.  If it
        # did, then give 3 seconds for things to exit
        # the nice way before killing them off.
        # This one will work all of the time!
-       if [ $? == 0 ]; then
+       if [ $? -eq 0 ]; then
            /bin/sleep 3
            /bin/fuser -km $NETMOUNTS > /dev/null
        fi
@@ -40,7 +73,7 @@ mountnetfs_stop() {
        /bin/umount -a -O _netdev
 
        # save the return value from umount
-       if [ $? != 0 ]; then
+       if [ $? -ne 0 ]; then
            NERRVAL=${EXIT_CODE_FAILURE}
        fi
 
@@ -48,7 +81,7 @@ mountnetfs_stop() {
        # by fstype.  This list can be extended later as
        # more network filesystems are supported by mount.
        /bin/umount -a -t coda,ncpfs,nfs,smbfs
-       if [ $? == 0 ]; then
+       if [ $? -eq 0 ]; then
            return ${NERRVAL}
        else
            # make certain that we return an error
@@ -60,17 +93,16 @@ mountnetfs_stop() {
     fi
 }
 
-
 case "$1" in
     start)
-        # Walk through /etc/fstab and mount all file systems that have the
-       # _netdev option set in the fs_mntops field (the 4th field. See man
-       # fstab for more info).
-       cmd_run_log_box "Mounting network file systems" mount -a -O _netdev
+        mountnetfs_start
         ;;
 
     stop)
        cmd_run_log_box "Unmounting network file systems" mountnetfs_stop
+       if statusproc rpc.statd | grep -q "running"; then
+            cmd_run_log_box "Stopping rpc.statd" killproc rpc.statd
+        fi
         ;;
 
     *)