]> git.proxmox.com Git - mirror_zfs-debian.git/blame - etc/init.d/zfs.gentoo
Removed erroneous backticks in the zfs.lunar init script.
[mirror_zfs-debian.git] / etc / init.d / zfs.gentoo
CommitLineData
712f8bd8
BB
1#!/sbin/runscript
2# Copyright 1999-2011 Gentoo Foundation
3# Distributed under the terms of the GNU General Public License v2
4# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/files/zfs,v 0.9 2011/04/30 10:13:43 devsk Exp $
5
6depend()
7{
8 before net
b59322a0 9 after udev localmount
04c22478 10 keyword -lxc -openvz -prefix -vserver
712f8bd8
BB
11}
12
13CACHEFILE=/etc/zfs/zpool.cache
14ZPOOL=/usr/sbin/zpool
15ZFS=/usr/sbin/zfs
16ZFS_MODULE=zfs
712f8bd8 17
04c22478
AS
18checksystem() {
19 if [ -c /dev/zfs ]; then
20 einfo "ZFS modules already loaded"
21 return 0
22 else
23 einfo "Checking if ZFS modules present"
06abcdd3 24 if [ "x$(modprobe -l $ZFS_MODULE | grep $ZFS_MODULE)" == "x" ]; then
04c22478
AS
25 eerror "$ZFS_MODULE not found. Is the ZFS package installed?"
26 return 1
27 fi
712f8bd8 28 fi
04c22478
AS
29 einfo "Checking if zfs userspace tools present"
30 if [ ! -x $ZPOOL ]; then
31 eerror "$ZPOOL binary not found."
32 return 1
33 fi
34 if [ ! -x $ZFS ]; then
35 eerror "$ZFS binary not found."
36 return 1
37 fi
712f8bd8
BB
38 return 0
39}
40
04c22478 41start() {
712f8bd8
BB
42 ebegin "Starting ZFS"
43 checksystem || return 1
2a005961
BB
44
45 # Delay until all required block devices are present.
46 udevadm settle
47
04c22478
AS
48 if [ ! -c /dev/zfs ]; then
49 modprobe $ZFS_MODULE
712f8bd8 50 rv=$?
04c22478 51 if [ $rv -ne 0 ]; then
712f8bd8
BB
52 eerror "Failed to load the $ZFS_MODULE module, check 'dmesg|tail'."
53 eend $rv
54 return $rv
55 fi
56 fi
57
712f8bd8
BB
58 # Import all pools described by the cache file, and then mount
59 # all filesystem based on their properties.
04c22478 60 if [ -f $CACHEFILE ]; then
712f8bd8 61 einfo "Importing ZFS pools"
712f8bd8
BB
62 # as per fedora script, import can fail if all pools are already imported
63 # The check for $rv makes no sense...but someday, it will work right.
64 $ZPOOL import -c $CACHEFILE -aN 2>/dev/null || true
65 rv=$?
04c22478 66 if [ $rv -ne 0 ]; then
712f8bd8
BB
67 eerror "Failed to import not-yet imported pools."
68 eend $rv
69 return $rv
70 fi
71 fi
72
73 einfo "Mounting ZFS filesystems"
74 $ZFS mount -a
75 rv=$?
04c22478 76 if [ $rv -ne 0 ]; then
712f8bd8
BB
77 eerror "Failed to mount ZFS filesystems."
78 eend $rv
79 return $rv
80 fi
81
712f8bd8
BB
82 eend 0
83 return 0
84}
85
86stop()
87{
712f8bd8 88 ebegin "Unmounting ZFS filesystems"
712f8bd8 89 $ZFS umount -a
06abcdd3 90 rv=$?
04c22478 91 if [ $rv -ne 0 ]; then
712f8bd8
BB
92 eerror "Failed to umount ZFS filesystems."
93 fi
04c22478 94
712f8bd8
BB
95 eend $rv
96}
97
98status()
99{
712f8bd8
BB
100 # show pool status and list
101 $ZPOOL status && echo && $ZPOOL list
102}