SHARE
TWEET

santisaez

a guest Jul 2nd, 2008 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          stop-open-iscsi.sh
  4. # Required-Start:
  5. # Required-Stop:     $remote_fs sendsigs open-iscsi
  6. # Default-Start:
  7. # Default-Stop:      0 6
  8. # Short-Description: Unmounts iSCSI filesystems and stops iSCSI services
  9. ### END INIT INFO
  10.  
  11. . /lib/init/vars.sh
  12.  
  13. . /lib/lsb/init-functions
  14.  
  15. do_stop () {
  16.     log_daemon_msg "Unmounting iscsi-backed filesystems"
  17.  
  18.     for HOST_DIR in /sys/devices/platform/host*; do
  19.         if ! [ -d $HOST_DIR/iscsi_host* ]; then
  20.             continue
  21.         fi
  22.         for TARGET_DIR in $HOST_DIR/session*/target*/*\:*; do
  23.             for BLOCK_FILE in $TARGET_DIR/block\:*; do
  24.                 BLOCK_DEV=`echo "$BLOCK_FILE" | sed 's/.*block\://'`
  25.                 DOS_PARTITIONS="`awk "/^\/dev\/$BLOCK_DEV/ { print \\$2; }" < /proc/mounts`"
  26.                 for DEVICE in $DOS_PARTITIONS; do
  27.                     log_progress_msg $DEVICE
  28.                     umount $DEVICE
  29.                 done
  30.             done
  31.         done
  32.     done
  33.     log_end_msg 0
  34. }
  35.  
  36. case "$1" in
  37.     start)
  38.         # No-op
  39.         ;;
  40.     restart|reload|force-reload)
  41.         echo "Error: argument '$1' not supported" >&2
  42.         exit 3
  43.         ;;
  44.     stop|"")
  45.         do_stop
  46.         ;;
  47.     *)
  48.         echo "Usage: stop-open-iscsi.sh [start|stop]" >&2
  49.         exit 3
  50.         ;;
  51. esac
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top