aboutsummaryrefslogtreecommitdiffstats
path: root/etc/init.d/zfs.lunar
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-05-02 15:39:59 -0700
committerBrian Behlendorf <[email protected]>2011-05-02 15:59:13 -0700
commit712f8bd87b2d3799107e102652875996fa59647b (patch)
tree7accb1ffa17551954bc9b7dbb3451e4efdb94527 /etc/init.d/zfs.lunar
parent5f35b190071048f25d66db81ce9763ecd0c1760e (diff)
Add Gentoo/Lunar/Redhat Init Scripts
Every distribution has slightly different requirements for their init scripts. Because of this the zfs package contains several init scripts for various distributions. These scripts have been contributed by, and are supported by, the larger zfs community. Init scripts for Gentoo/Lunar/Redhat have been contributed by: Gentoo - devsk <[email protected]> Lunar - Jean-Michel Bruenn <[email protected]> Redhat - Fajar A. Nugraha <[email protected]>
Diffstat (limited to 'etc/init.d/zfs.lunar')
-rw-r--r--etc/init.d/zfs.lunar80
1 files changed, 80 insertions, 0 deletions
diff --git a/etc/init.d/zfs.lunar b/etc/init.d/zfs.lunar
new file mode 100644
index 000000000..c7aa1edb4
--- /dev/null
+++ b/etc/init.d/zfs.lunar
@@ -0,0 +1,80 @@
+#!/bin/bash
+#
+# zfs This shell script takes care of starting (mount) and
+# stopping (umount) zfs shares.
+#
+# chkconfig: 35 60 40
+# description: ZFS is a filesystem developed by Sun, ZFS is a
+# combined file system and logical volume manager
+# designed by Sun Microsystems. Made available to Linux
+# using SPL (Solaris Porting Layer) by zfsonlinux.org.
+# probe: true
+
+case $1 in
+ start) echo "$1ing ZFS filesystems"
+
+ if ! grep "zfs" /proc/modules > /dev/null; then
+ echo "ZFS kernel module not loaded yet; loading...";
+ if ! modprobe zfs; then
+ echo "Failed to load ZFS kernel module...";
+ exit 0;
+ fi
+ fi
+
+ if ! [ `uname -m` == "x86_64" ]; then
+ echo "Warning: You're not running 64bit. Currently native zfs in";
+ echo " linux is only supported and tested on 64bit.";
+ # should we break here? People doing this should know what they
+ # do, thus i'm not breaking here.
+ fi
+
+ # mount the filesystems
+ while IFS= read -r -d $'\n' dev; do
+ mdev=$(echo "$dev" | awk '{ print $1; }')
+ echo -n "mounting $mdev..."
+ if `zfs mount $mdev`; then
+ echo -e "done";
+ else
+ echo -e "failed";
+ fi
+ done < <(zfs list -H);
+
+
+ ;;
+
+ stop) echo "$1ping ZFS filesystems"
+
+ if grep "zfs" /proc/modules > /dev/null; then
+ # module is loaded, so we can try to umount filesystems
+ while IFS= read -r -d $'\n' dev; do
+ mdev=$(echo "$dev" | awk '{ print $1 }');
+ echo -n "umounting $mdev...";
+ if `zfs umount $mdev`; then
+ echo -e "done";
+ else
+ echo -e "failed";
+ fi
+ # the next line is, because i have to reverse the
+ # output, otherwise it wouldn't work as it should
+ done < <(zfs list -H | tac);
+
+ # and finally let's rmmod the module
+ rmmod zfs
+
+
+ else
+ # module not loaded, no need to umount anything
+ exit 0
+ fi
+
+ ;;
+
+ restart) echo "$1ing ZFS filesystems"
+ $0 stop
+ $0 start
+ ;;
+
+ *) echo "Usage: $0 {start|stop|restart}"
+ ;;
+
+esac