updated on Sat Jan 21 16:18:39 UTC 2012
[aur-mirror.git] / zfs-fuse / zfs-fuse.rcd
blob44e5574bd0895e3e5743145362c4c1c46b2e5460
1 #!/bin/bash
2 # /etc/rc.d/zfs-fuse for archlinux
3 # worked over by khampf@users.sourceforge.net 2011
5 . /etc/rc.conf
6 . /etc/rc.d/functions
8 ZFS_IMPORT=("-a")
9 ZFS_MOUNT=("-a")
10 ZFS_DELAY=1
12 [ -f /etc/conf.d/zfs-fuse ] && . /etc/conf.d/zfs-fuse
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
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'
27 # wait for zfs-fuse daemon to come up
28 sleep $ZFS_DELAY;
30 if [ ${#ZFS_IMPORT} -ne 0 ]; then
31 for dataset in ${ZFS_IMPORT[@]}; do
32 /usr/sbin/zpool import "$dataset"
33 done
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
41 add_daemon zfs-fuse
42 stat_done
43 else
44 stat_append "- ZFS daemon seems to be running!"
45 stat_done
48 stop)
49 stat_busy "Stopping ZFS daemon"
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
56 PID=`pidof -o %PPID /usr/sbin/zfs-fuse`
57 kill $PID &>/dev/null
58 if [ $? -gt 0 ]; then
59 stat_fail
61 if [ -e /var/run/zfs-fuse.pid ]; then
62 rm /var/run/zfs-fuse.pid
64 rm_daemon zfs-fuse
65 stat_done
67 restart)
68 PID=`pidof -o %PPID /usr/sbin/zfs-fuse`
69 $0 stop
70 sleep 5
71 $0 start
74 echo "usage: $0 {start|stop|restart}"
75 esac
76 exit 0