Provide a rc.d script for archlinux
[zfs.git] / etc / init.d / zfs.arch
1 #!/bin/bash
2
3 . /etc/rc.conf
4 . /etc/rc.d/functions
5
6 case "$1" in
7   start)
8     stat_busy "Starting zfs"
9
10     if [ ! -c /dev/zfs ]; then
11       modprobe zfs
12       if [ $? -ne 0 ]; then
13         stat_fail
14         exit 1
15       fi
16     fi
17
18     # Import ZFS pools (via cache file)
19     if [ -f /etc/zfs/zpool.cache ]; then
20       /usr/sbin/zpool import -c /etc/zfs/zpool.cache -aN 2>/dev/null
21       if [ $? -ne 0 ]; then
22         stat_fail
23         exit 1
24       fi
25     fi
26
27     # Mount ZFS filesystems
28     /usr/sbin/zfs mount -a
29     if [ $? -ne 0 ]; then
30         stat_fail
31         exit 1
32     fi
33
34     # Export ZFS flesystems
35     /usr/sbin/zfs share -a
36     if [ $? -ne 0 ]; then
37         stat_fail
38         exit 1
39     fi
40
41     add_daemon zfs
42     stat_done
43     ;;
44   stop)
45     stat_busy "Stopping zfs"
46     zfs umount -a
47     rm_daemon zfs
48     stat_done
49     ;;
50   restart)
51     $0 stop
52     $0 start
53     ;;
54   *)
55     echo "usage: $0 {start|stop|restart}"
56 esac
57
58 exit 0