1 |
ae75bcb4
|
Scott Ullrich
|
#!/usr/local/bin/php -f
|
2 |
|
|
<?php
|
3 |
|
|
/* $Id$ */
|
4 |
|
|
/*
|
5 |
|
|
rc.carpup
|
6 |
|
|
part of pfSense (http://www.pfSense.com)
|
7 |
|
|
Copyright (C) 2004 Scott Ullrich
|
8 |
|
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
require_once("functions.inc");
|
33 |
|
|
require_once("config.inc");
|
34 |
|
|
require_once("notices.inc");
|
35 |
9ea0cb90
|
jim-p
|
require_once("openvpn.inc");
|
36 |
e3449857
|
PiBa-NL
|
require_once("interfaces.inc");
|
37 |
ae75bcb4
|
Scott Ullrich
|
|
38 |
e3449857
|
PiBa-NL
|
$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "MASTER"',$argv[1],convert_friendly_interface_to_friendly_descr($argv[1]));
|
39 |
ae75bcb4
|
Scott Ullrich
|
|
40 |
|
|
notify_via_smtp($notificationmsg);
|
41 |
|
|
notify_via_growl($notificationmsg);
|
42 |
|
|
|
43 |
9ea0cb90
|
jim-p
|
/* Start OpenVPN clients running on this VIP, since they should be in the stopped state while the VIP is CARP Backup. */
|
44 |
|
|
global $config;
|
45 |
2156f02a
|
jim-p
|
if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-client'])) {
|
46 |
|
|
foreach ($config['openvpn']['openvpn-client'] as $settings) {
|
47 |
|
|
if ($settings['interface'] == $argv[1]) {
|
48 |
|
|
log_error("Starting OpenVPN instance on {$settings['interface']} because of transition to CARP master.");
|
49 |
|
|
openvpn_restart('client', $settings);
|
50 |
|
|
}
|
51 |
9ea0cb90
|
jim-p
|
}
|
52 |
|
|
}
|
53 |
9db8c46d
|
jim-p
|
if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-server'])) {
|
54 |
|
|
foreach ($config['openvpn']['openvpn-server'] as $settings) {
|
55 |
|
|
if ($settings['interface'] == $argv[1]) {
|
56 |
|
|
log_error("Starting OpenVPN instance on {$settings['interface']} because of transition to CARP master.");
|
57 |
|
|
openvpn_restart('server', $settings);
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
9ea0cb90
|
jim-p
|
|
62 |
ae75bcb4
|
Scott Ullrich
|
?>
|