]> git.proxmox.com Git - mirror_zfs-debian.git/blob - etc/init.d/zfs.lunar.in
Make Gentoo initscript use modinfo
[mirror_zfs-debian.git] / etc / init.d / zfs.lunar.in
1 #!/bin/bash
2 #
3 # zfs This shell script takes care of starting (mount) and
4 # stopping (umount) zfs shares.
5 #
6 # chkconfig: 35 60 40
7 # description: ZFS is a filesystem developed by Sun, ZFS is a
8 # combined file system and logical volume manager
9 # designed by Sun Microsystems. Made available to Linux
10 # using SPL (Solaris Porting Layer) by zfsonlinux.org.
11 # probe: true
12
13 ZFS="@sbindir@/zfs"
14 ZPOOL="@sbindir@/zpool"
15 ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
16
17 case $1 in
18 start) echo "$1ing ZFS filesystems"
19
20 # Delay until all required block devices are present.
21 udevadm settle
22
23 if ! grep "zfs" /proc/modules > /dev/null; then
24 echo "ZFS kernel module not loaded yet; loading...";
25 if ! modprobe zfs; then
26 echo "Failed to load ZFS kernel module...";
27 exit 0;
28 fi
29 fi
30
31 if ! [ `uname -m` == "x86_64" ]; then
32 echo "Warning: You're not running 64bit. Currently native zfs in";
33 echo " linux is only supported and tested on 64bit.";
34 # should we break here? People doing this should know what they
35 # do, thus i'm not breaking here.
36 fi
37
38 # mount the filesystems
39 while IFS= read -r -d $'\n' dev; do
40 mdev=$(echo "$dev" | awk '{ print $1; }')
41 echo -n "mounting $mdev..."
42 if $ZFS mount $mdev; then
43 echo -e "done";
44 else
45 echo -e "failed";
46 fi
47 done < <($ZFS list -H);
48
49 # export the filesystems
50 echo -n "exporting ZFS filesystems..."
51 if $ZFS share -a; then
52 echo -e "done";
53 else
54 echo -e "failed";
55 fi
56
57
58 ;;
59
60 stop) echo "$1ping ZFS filesystems"
61
62 if grep "zfs" /proc/modules > /dev/null; then
63 # module is loaded, so we can try to umount filesystems
64 while IFS= read -r -d $'\n' dev; do
65 mdev=$(echo "$dev" | awk '{ print $1 }');
66 echo -n "umounting $mdev...";
67 if $ZFS umount $mdev; then
68 echo -e "done";
69 else
70 echo -e "failed";
71 fi
72 # the next line is, because i have to reverse the
73 # output, otherwise it wouldn't work as it should
74 done < <($ZFS list -H | tac);
75
76 # and finally let's rmmod the module
77 rmmod zfs
78
79
80 else
81 # module not loaded, no need to umount anything
82 exit 0
83 fi
84
85 ;;
86
87 restart) echo "$1ing ZFS filesystems"
88 $0 stop
89 $0 start
90 ;;
91
92 *) echo "Usage: $0 {start|stop|restart}"
93 ;;
94
95 esac