3 # Copyright (c) 2010 The FreeBSD Foundation
6 # This software was developed by Pawel Jakub Dawidek under sponsorship from
7 # the FreeBSD Foundation.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
22 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 # Resource name as defined in /etc/hast.conf.
34 # Supported file system types: UFS, ZFS
36 # ZFS pool name. Required only when fstype == ZFS.
38 # File system mount point. Required only when fstype == UFS.
39 mountpoint="/mnt/test"
40 # Name of HAST provider as defined in /etc/hast.conf.
41 # Required only when fstype == UFS.
42 device="/dev/hast/${resource}"
44 export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
46 # KIll UP script if it still runs in the background.
49 pgid=`pgrep -f ucarp_up.sh | head -1`
50 [ -n "${pgid}" ] || break
51 kill -${sig} -- -${pgid}
55 if [ -n "${pgid}" ]; then
56 logger -p local0.error -t hast "UCARP UP process for resource ${resource} is still running after 30 seconds."
59 logger -p local0.debug -t hast "UCARP UP is not running."
63 mount | egrep -q "^${device} on "
65 # Forcibly unmount file system.
66 out=`umount -f "${mountpoint}" 2>&1`
68 logger -p local0.error -t hast "Unable to unmount file system for resource ${resource}: ${out}."
71 logger -p local0.debug -t hast "File system for resource ${resource} unmounted."
75 zpool list | egrep -q "^${pool} "
77 # Forcibly export file pool.
78 out=`zpool export -f "${pool}" 2>&1`
80 logger -p local0.error -t hast "Unable to export pool for resource ${resource}: ${out}."
83 logger -p local0.debug -t hast "ZFS pool for resource ${resource} exported."
88 # Change role to secondary for our resource.
89 out=`hastctl role secondary "${resource}" 2>&1`
91 logger -p local0.error -t hast "Unable to change to role to secondary for resource ${resource}: ${out}."
94 logger -p local0.debug -t hast "Role for resource ${resource} changed to secondary."
96 logger -p local0.info -t hast "Successfully switched to secondary for resource ${resource}."