updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / zfs-fuse-git-critical / zfs-fuse.rcd
blob92bd22d8baee7c5c349bceab43273d012781e2c2
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 ZFS_IMPORT=("-a")
7 ZFS_MOUNT=("-a")
8 ZFS_DELAY=1
10 [ -f /etc/conf.d/zfs-fuse ] && . /etc/conf.d/zfs-fuse
12 case "$1" in
13 start)
14 stat_busy "Starting ZFS daemon"
15 PID=`pidof -o %PPID /usr/sbin/zfs-fuse`
16 if [ -z "$PID" ]; then
17 if [ -e /var/run/zfs-fuse.pid ]; then
18 rm /var/run/zfs-fuse.pid
19 /usr/sbin/zfs-fuse -p /var/run/zfs-fuse.pid
21 # wait for zfs-fuse daemon to come up
22 sleep $ZFS_DELAY;
24 if [ ${#ZFS_IMPORT} -ne 0 ]; then
25 for dataset in ${ZFS_IMPORT[@]}; do
26 /usr/sbin/zpool import "$dataset"
27 done
29 if [ ${#ZFS_MOUNT} -ne 0 ]; then
30 for dataset in ${ZFS_MOUNT[@]}; do
31 /usr/sbin/zfs mount "$dataset" 2>/dev/null
32 done
35 add_daemon zfs-fuse
36 stat_done
37 else
38 /usr/sbin/zfs-fuse -p /var/run/zfs-fuse.pid
40 # wait for zfs-fuse daemon to come up
41 sleep $ZFS_DELAY;
43 if [ ${#ZFS_IMPORT} -ne 0 ]; then
44 for dataset in ${ZFS_IMPORT[@]}; do
45 /usr/sbin/zpool import "$dataset"
46 done
48 if [ ${#ZFS_MOUNT} -ne 0 ]; then
49 for dataset in ${ZFS_MOUNT[@]}; do
50 /usr/sbin/zfs mount "$dataset" 2>/dev/null
51 done
54 add_daemon zfs-fuse
55 stat_done
57 else
58 stat_append "- ZFS daemon seems to be running!"
59 stat_done
62 stop)
63 stat_busy "Stopping ZFS daemon"
65 /usr/sbin/zfs unmount -a
66 for pool in $(/usr/sbin/zpool list -o name | /bin/grep -v NAME); do
67 /usr/sbin/zpool export "$pool" 2>/dev/null
68 done
70 PID=`pidof -o %PPID /usr/sbin/zfs-fuse`
71 kill $PID &>/dev/null
72 if [ $? -gt 0 ]; then
73 stat_fail
75 if [ -e /var/run/zfs-fuse.pid ]; then
76 rm /var/run/zfs-fuse.pid
77 rm_daemon zfs-fuse
78 stat_done
79 else
80 rm_daemon zfs-fuse
81 stat_done
84 restart)
85 $0 stop
86 sleep 5
87 $0 start
90 echo "usage: $0 {start|stop|restart}"
91 esac
92 exit 0