]> git.proxmox.com Git - mirror_zfs-debian.git/blame - etc/init.d/zfs.lunar.in
Imported Upstream version 0.6.4.2
[mirror_zfs-debian.git] / etc / init.d / zfs.lunar.in
CommitLineData
712f8bd8
BB
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
5faa9c03
KF
13ZFS="@sbindir@/zfs"
14ZPOOL="@sbindir@/zpool"
1a2e6a63 15ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
5faa9c03 16
c06d4368
AX
17if [ -z "$init" ]; then
18 # Not interactive
a08ee875 19 grep -qE '(^|[^\\](\\\\)* )zfs=(off|no)( |$)' /proc/cmdline && exit 3
c06d4368
AX
20fi
21
712f8bd8
BB
22case $1 in
23 start) echo "$1ing ZFS filesystems"
24
2a005961
BB
25 # Delay until all required block devices are present.
26 udevadm settle
27
712f8bd8
BB
28 if ! grep "zfs" /proc/modules > /dev/null; then
29 echo "ZFS kernel module not loaded yet; loading...";
30 if ! modprobe zfs; then
31 echo "Failed to load ZFS kernel module...";
32 exit 0;
33 fi
34 fi
35
36 if ! [ `uname -m` == "x86_64" ]; then
37 echo "Warning: You're not running 64bit. Currently native zfs in";
38 echo " linux is only supported and tested on 64bit.";
39 # should we break here? People doing this should know what they
40 # do, thus i'm not breaking here.
41 fi
42
0f4524cc
GB
43 # mount the filesystems
44 while IFS= read -r -d $'\n' dev; do
45 mdev=$(echo "$dev" | awk '{ print $1; }')
46 echo -n "mounting $mdev..."
5faa9c03 47 if $ZFS mount $mdev; then
0f4524cc
GB
48 echo -e "done";
49 else
50 echo -e "failed";
51 fi
5faa9c03 52 done < <($ZFS list -H);
712f8bd8 53
8b0cf399
GB
54 # export the filesystems
55 echo -n "exporting ZFS filesystems..."
5faa9c03 56 if $ZFS share -a; then
8b0cf399
GB
57 echo -e "done";
58 else
59 echo -e "failed";
60 fi
61
712f8bd8
BB
62
63 ;;
64
65 stop) echo "$1ping ZFS filesystems"
66
67 if grep "zfs" /proc/modules > /dev/null; then
68 # module is loaded, so we can try to umount filesystems
69 while IFS= read -r -d $'\n' dev; do
70 mdev=$(echo "$dev" | awk '{ print $1 }');
71 echo -n "umounting $mdev...";
5faa9c03 72 if $ZFS umount $mdev; then
712f8bd8
BB
73 echo -e "done";
74 else
75 echo -e "failed";
76 fi
77 # the next line is, because i have to reverse the
78 # output, otherwise it wouldn't work as it should
5faa9c03 79 done < <($ZFS list -H | tac);
712f8bd8
BB
80
81 # and finally let's rmmod the module
82 rmmod zfs
83
84
85 else
86 # module not loaded, no need to umount anything
87 exit 0
88 fi
89
90 ;;
91
92 restart) echo "$1ing ZFS filesystems"
93 $0 stop
94 $0 start
95 ;;
96
97 *) echo "Usage: $0 {start|stop|restart}"
98 ;;
99
100esac