3
# External STONITH module for ssh.
5
# Copyright (c) 2004 SUSE LINUX AG - Lars Marowsky-Bree <lmb@suse.de>
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of version 2 of the GNU General Public License as
9
# published by the Free Software Foundation.
11
# This program is distributed in the hope that it would be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
# Further, this software is distributed without any warranty that it is
16
# free of the rightful claim of any third person regarding infringement
17
# or the like. Any license provided herein, whether implied or
18
# otherwise, applies only to this software file. Patent licenses, if
19
# any, provided herein do not apply to combinations of this program with
20
# other software, or any other product whatsoever.
22
# You should have received a copy of the GNU General Public License
23
# along with this program; if not, write the Free Software Foundation,
24
# Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
27
SSH_COMMAND="/usr/bin/ssh -q -x -o PasswordAuthentication=no -o StrictHostKeyChecking=no -n -l root"
28
#SSH_COMMAND="/usr/bin/ssh -q -x -n -l root"
30
REBOOT_COMMAND="echo 'sleep 2; /sbin/reboot -nf' | SHELL=/bin/sh at now >/dev/null 2>&1"
32
# Warning: If you select this poweroff command, it'll physically
33
# power-off the machine, and quite a number of systems won't be remotely
35
# TODO: Probably should touch a file on the server instead to just
36
# prevent heartbeat et al from being started after the reboot.
37
# POWEROFF_COMMAND="echo 'sleep 2; /sbin/poweroff -nf' | SHELL=/bin/sh at now >/dev/null 2>&1"
38
POWEROFF_COMMAND="echo 'sleep 2; /sbin/reboot -nf' | SHELL=/bin/sh at now >/dev/null 2>&1"
40
# Rewrite the hostlist to accept "," as a delimeter for hostnames too.
41
hostlist=`echo $hostlist | tr ',' ' '`
44
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
47
ping -w1 -c1 "$1" >/dev/null 2>&1
60
for h in $hostlist ; do
66
# Can't really be implemented because ssh cannot power on a system
67
# when it is powered off.
71
# Shouldn't really be implemented because if ssh cannot power on a
72
# system, it shouldn't be allowed to power it off.
84
case ${livedangerously} in
85
[Yy]*) is_host_up $h;;
89
$SSH_COMMAND "$2" "$REBOOT_COMMAND"
90
# Good thing this is only for testing...
99
# well... Let's call it successful, after all this is only for testing...
114
ping -w1 -c1 "$h" 2>&1 | grep "unknown host"
126
echo "ssh STONITH device"
130
echo "ssh STONITH external device"
134
echo "ssh-based Linux host reset"
135
echo "Fine for testing, but not suitable for production!"
139
echo "http://openssh.org"
145
<parameter name="hostlist" unique="1" required="1">
146
<content type="string" />
147
<shortdesc lang="en">
151
The list of hosts that the STONITH device controls
155
<parameter name="livedangerously" unique="0" required="0">
156
<content type="enum" />
157
<shortdesc lang="en">
161
Set to "yes" if you want to risk your system's integrity.
162
Of course, since this plugin isn't for production, using it
163
in production at all is a bad idea. On the other hand,
164
setting this parameter to yes makes it an even worse idea.