132115b10SPawel Jakub Dawidek#!/bin/sh 232115b10SPawel Jakub Dawidek# 3*4d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause 4f0cfa1b1SPedro F. Giffuni# 532115b10SPawel Jakub Dawidek# Copyright (c) 2010 The FreeBSD Foundation 632115b10SPawel Jakub Dawidek# 732115b10SPawel Jakub Dawidek# This software was developed by Pawel Jakub Dawidek under sponsorship from 832115b10SPawel Jakub Dawidek# the FreeBSD Foundation. 932115b10SPawel Jakub Dawidek# 1032115b10SPawel Jakub Dawidek# Redistribution and use in source and binary forms, with or without 1132115b10SPawel Jakub Dawidek# modification, are permitted provided that the following conditions 1232115b10SPawel Jakub Dawidek# are met: 1332115b10SPawel Jakub Dawidek# 1. Redistributions of source code must retain the above copyright 1432115b10SPawel Jakub Dawidek# notice, this list of conditions and the following disclaimer. 1532115b10SPawel Jakub Dawidek# 2. Redistributions in binary form must reproduce the above copyright 1632115b10SPawel Jakub Dawidek# notice, this list of conditions and the following disclaimer in the 1732115b10SPawel Jakub Dawidek# documentation and/or other materials provided with the distribution. 1832115b10SPawel Jakub Dawidek# 1932115b10SPawel Jakub Dawidek# THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 2032115b10SPawel Jakub Dawidek# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2132115b10SPawel Jakub Dawidek# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2232115b10SPawel Jakub Dawidek# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 2332115b10SPawel Jakub Dawidek# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2432115b10SPawel Jakub Dawidek# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2532115b10SPawel Jakub Dawidek# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2632115b10SPawel Jakub Dawidek# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2732115b10SPawel Jakub Dawidek# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2832115b10SPawel Jakub Dawidek# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2932115b10SPawel Jakub Dawidek# SUCH DAMAGE. 3032115b10SPawel Jakub Dawidek# 3132115b10SPawel Jakub Dawidek 3232115b10SPawel Jakub Dawidek# Shared IP address, unused for now. 3332115b10SPawel Jakub Dawidekaddr="10.99.0.3" 3432115b10SPawel Jakub Dawidek# Password for UCARP communication. 3532115b10SPawel Jakub Dawidekpass="password" 3632115b10SPawel Jakub Dawidek# First node IP and interface for UCARP communication. 3732115b10SPawel Jakub Dawideknodea_srcip="10.99.0.1" 3832115b10SPawel Jakub Dawideknodea_ifnet="bge0" 3932115b10SPawel Jakub Dawidek# Second node IP and interface for UCARP communication. 4032115b10SPawel Jakub Dawideknodeb_srcip="10.99.0.2" 4132115b10SPawel Jakub Dawideknodeb_ifnet="em3" 4232115b10SPawel Jakub Dawidek 4332115b10SPawel Jakub Dawidekexport PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin 4432115b10SPawel Jakub Dawidek 4532115b10SPawel Jakub Dawidekvhid="1" 4632115b10SPawel Jakub Dawidekupscript="/root/hast/sbin/hastd/vip-up.sh" 4732115b10SPawel Jakub Dawidekdownscript="/root/hast/sbin/hastd/vip-down.sh" 4832115b10SPawel Jakub Dawidek 4932115b10SPawel Jakub Dawidekifconfig "${nodea_ifnet}" 2>/dev/null | grep -q "inet ${nodea_srcip} " 5032115b10SPawel Jakub Dawidekif [ $? -eq 0 ]; then 5132115b10SPawel Jakub Dawidek srcip="${nodea_srcip}" 5232115b10SPawel Jakub Dawidek ifnet="${nodea_ifnet}" 5332115b10SPawel Jakub Dawidek node="node A" 5432115b10SPawel Jakub Dawidekfi 5532115b10SPawel Jakub Dawidekifconfig "${nodeb_ifnet}" 2>/dev/null | grep -q "inet ${nodeb_srcip} " 5632115b10SPawel Jakub Dawidekif [ $? -eq 0 ]; then 5732115b10SPawel Jakub Dawidek if [ -n "${srcip}" -o -n "${ifnet}" ]; then 5832115b10SPawel Jakub Dawidek echo "Unable to determine which node is this (both match)." >/dev/stderr 5932115b10SPawel Jakub Dawidek exit 1 6032115b10SPawel Jakub Dawidek fi 6132115b10SPawel Jakub Dawidek srcip="${nodeb_srcip}" 6232115b10SPawel Jakub Dawidek ifnet="${nodeb_ifnet}" 6332115b10SPawel Jakub Dawidek node="node B" 6432115b10SPawel Jakub Dawidekfi 6532115b10SPawel Jakub Dawidekif [ -z "${srcip}" -o -z "${ifnet}" ]; then 6632115b10SPawel Jakub Dawidek echo "Unable to determine which node is this (none match)." >/dev/stderr 6732115b10SPawel Jakub Dawidek exit 1 6832115b10SPawel Jakub Dawidekfi 6932115b10SPawel Jakub Dawidekucarp -i ${ifnet} -s ${srcip} -v ${vhid} -a ${addr} -p ${pass} -u "${upscript}" -d "${downscript}" 70