2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

74_HOMBOT: check path for sshpass

git-svn-id: https://svn.fhem.de/fhem/trunk@11639 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
markooldenburg 2016-06-10 04:54:26 +00:00
parent ad04afd640
commit a086937c67
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix : 74_HOMBOT: check path for sshpass
- feature: fhem_codemirror: Added new codemirrorParams:
keyMap, jumpToLine, jumpToLine_extraKey
- feature: 10_pilight_ctrl: NEW: protocol oregon_21 for temperature

View File

@ -35,7 +35,7 @@ use Time::HiRes qw(gettimeofday);
use HttpUtils;
use Blocking;
my $version = "0.2.3";
my $version = "0.2.4";
@ -67,13 +67,15 @@ sub HOMBOT_Define($$) {
my ( $hash, $def ) = @_;
my @a = split( "[ \t][ \t]*", $def );
return "too few parameters: define <name> HOMBOT <HOST>" if( @a != 3 );
return "please check if ssh installed" unless( -X "/usr/bin/ssh" );
return "please check if /opt/fhem/.ssh/known_hosts exist" unless( -R "/opt/fhem/.ssh/known_hosts" );
return "please check if sshpass installed" unless( -X "/usr/bin/sshpass" );
return "please check if $attr{global}{modpath}/.ssh/known_hosts or /root/.ssh/known_hosts exist" unless( -R "$attr{global}{modpath}/.ssh/known_hosts" or -R "/root/.ssh/known_hosts" );
return "please check if sshpass installed" unless( -X "/usr/bin/sshpass" or -X "/usr/local/bin/sshpass" );
my $name = $a[0];
my $host = $a[2];
my $port = 6260;
@ -85,6 +87,8 @@ sub HOMBOT_Define($$) {
$hash->{VERSION} = $version;
$hash->{helper}{requestErrorCounter} = 0;
$hash->{helper}{setErrorCounter} = 0;
$hash->{helper}{sshpass} = "/usr/bin/sshpass";
$hash->{helper}{sshpass} = "/usr/local/bin/sshpass" unless( -X "/usr/bin/sshpass");
Log3 $name, 3, "HOMBOT ($name) - defined with host $hash->{HOST} on port $hash->{PORT} and interval $hash->{INTERVAL} (sec)";
@ -844,19 +848,20 @@ sub HOMBOT_Check_Bot_Alive($) {
my $hash = $defs{$name};
my $host = $hash->{HOST};
my $sshalive;
my $sshpass = $hash->{helper}{sshpass};
Log3 $name, 3, "HOMBOT ($name) - Start SSH Connection for check Hombot alive";
$sshalive = qx(/usr/bin/sshpass -p 'most9981' /usr/bin/ssh root\@$host 'uname' );
$sshalive = qx($sshpass -p 'most9981' /usr/bin/ssh root\@$host 'uname' );
if( $sshalive ) {
my $lgSrvPID = ((split (/\s+/,qx(/usr/bin/sshpass -p 'most9981' /usr/bin/ssh root\@$host 'ps | grep -v grep | grep /usr/bin/lg.srv' )))[1]);
my $lgSrvPID = ((split (/\s+/,qx($sshpass -p 'most9981' /usr/bin/ssh root\@$host 'ps | grep -v grep | grep /usr/bin/lg.srv' )))[1]);
if( not defined( $lgSrvPID ) ) {
qx(/usr/bin/sshpass -p 'most9981' /usr/bin/ssh root\@$host '/usr/bin/lg.srv &' );
qx($sshpass -p 'most9981' /usr/bin/ssh root\@$host '/usr/bin/lg.srv &' );
return "$name|$callingtype|restarted";