Advertisement
khampf

/etc/rc.d/zfs-fuse

Oct 24th, 2011
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.02 KB | None | 0 0
  1. #!/bin/bash
  2. # /etc/rc.d/zfs-fuse for archlinux
  3. # worked over by khampf@users.sourceforge.net 2011
  4.  
  5. . /etc/rc.conf
  6. . /etc/rc.d/functions
  7.  
  8. ZFS_IMPORT=("-a")
  9. ZFS_MOUNT=("-a")
  10. ZFS_DELAY=1
  11.  
  12. [ -f /etc/conf.d/zfs-fuse ] && . /etc/conf.d/zfs-fuse
  13.  
  14. case "$1" in
  15.     start)
  16.         stat_busy "Starting ZFS daemon"
  17.         PID=`pidof -o %PPID /usr/sbin/zfs-fuse`
  18.         if [ -z "$PID" ]; then
  19.             if [ -e /var/run/zfs-fuse.pid ]; then
  20.               rm /var/run/zfs-fuse.pid
  21.             fi
  22.  
  23.             # currently SEGFAULTS using --pidfile
  24.             /usr/sbin/zfs-fuse # --pidfile /var/run/zfs-fuse.pid
  25.             pidof -o %PPID /usr/sbin/zfs-fuse > '/var/run/zfs-fuse.pid'
  26.        
  27.             # wait for zfs-fuse daemon to come up
  28.             sleep $ZFS_DELAY;
  29.  
  30.             if [ ${#ZFS_IMPORT} -ne 0 ]; then
  31.                 for dataset in ${ZFS_IMPORT[@]}; do
  32.                     /usr/sbin/zpool import "$dataset"
  33.                 done
  34.             fi
  35.             if [ ${#ZFS_MOUNT} -ne 0 ]; then
  36.                 for dataset in ${ZFS_MOUNT[@]}; do
  37.                     /usr/sbin/zfs mount "$dataset" 2>/dev/null
  38.                 done
  39.             fi
  40.  
  41.             add_daemon zfs-fuse
  42.             stat_done
  43.         else
  44.             stat_append "- ZFS daemon seems to be running!"
  45.             stat_done
  46.         fi
  47.         ;;
  48.     stop)
  49.         stat_busy "Stopping ZFS daemon"
  50.  
  51.         /usr/sbin/zfs unmount -a
  52.         for pool in $(/usr/sbin/zpool list -o name | /bin/grep -v NAME); do
  53.             /usr/sbin/zpool export "$pool" 2>/dev/null
  54.         done
  55.  
  56.         PID=`pidof -o %PPID /usr/sbin/zfs-fuse`
  57.         kill $PID &>/dev/null
  58.         if [ $? -gt 0 ]; then
  59.             stat_fail
  60.         fi
  61.         if [ -e /var/run/zfs-fuse.pid ]; then
  62.             rm /var/run/zfs-fuse.pid
  63.         fi
  64.         rm_daemon zfs-fuse
  65.         stat_done
  66.         ;;
  67.     restart)
  68.         PID=`pidof -o %PPID /usr/sbin/zfs-fuse`
  69.         $0 stop
  70.         sleep 5
  71.         $0 start
  72.         ;;
  73.     *)
  74.         echo "usage: $0 {start|stop|restart}"
  75. esac
  76. exit 0
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement