change to apt command

This commit is contained in:
Marko Oldenburg 2019-04-29 16:43:53 +02:00
parent f2175114bc
commit 23ec822a11

View File

@ -36,7 +36,7 @@ use strict;
use warnings; use warnings;
use FHEM::Meta; use FHEM::Meta;
my $version = "1.4.4"; my $version = "1.99.7";
sub AptToDate_Initialize($) { sub AptToDate_Initialize($) {
@ -52,7 +52,7 @@ sub AptToDate_Initialize($) {
"disable:1 " "disable:1 "
. "disabledForIntervals " . "disabledForIntervals "
. "upgradeListReading:1 " . "upgradeListReading:1 "
. "distupgrade:1 " # . "distupgrade:1 "
. $readingFnAttributes; . $readingFnAttributes;
foreach my $d ( sort keys %{ $modules{AptToDate}{defptr} } ) { foreach my $d ( sort keys %{ $modules{AptToDate}{defptr} } ) {
@ -558,31 +558,31 @@ sub ExecuteAptGetCommand($) {
if ( $aptget->{host} ne 'localhost' ) { if ( $aptget->{host} ne 'localhost' ) {
$apt->{aptgetupdate} = $apt->{aptgetupdate} =
'ssh ' . $aptget->{host} . ' \'echo n | sudo apt-get -q update\''; 'ssh ' . $aptget->{host} . ' \'echo n | sudo apt -q update\'';
$apt->{distri} = 'ssh ' . $aptget->{host} . ' cat /etc/os-release |'; $apt->{distri} = 'ssh ' . $aptget->{host} . ' cat /etc/os-release |';
$apt->{'locale'} = 'ssh ' . $aptget->{host} . ' locale'; $apt->{'locale'} = 'ssh ' . $aptget->{host} . ' locale';
$apt->{aptgetupgrade} = 'ssh ' $apt->{aptgetupgrade} = 'ssh '
. $aptget->{host} . $aptget->{host}
. ' \'echo n | sudo apt-get -s -q -V upgrade\''; . ' \'echo n | sudo apt -s -q -V upgrade\'';
$apt->{aptgettoupgrade} = 'ssh ' $apt->{aptgettoupgrade} = 'ssh '
. $aptget->{host} . $aptget->{host}
. ' \'echo n | sudo apt-get -y -q -V upgrade\'' . ' \'echo n | sudo apt -y -q -V upgrade\''
if ( $aptget->{distupgrade} == 0 ); if ( $aptget->{distupgrade} == 0 );
$apt->{aptgettoupgrade} = 'ssh ' $apt->{aptgettoupgrade} = 'ssh '
. $aptget->{host} . $aptget->{host}
. ' \'echo n | sudo apt-get -y -q -V dist-upgrade\'' . ' \'echo n | sudo apt -y -q -V dist-upgrade\''
if ( $aptget->{distupgrade} == 1 ); if ( $aptget->{distupgrade} == 1 );
} }
else { else {
$apt->{aptgetupdate} = 'echo n | sudo apt-get -q update'; $apt->{aptgetupdate} = 'echo n | sudo apt -q update';
$apt->{distri} = '</etc/os-release'; $apt->{distri} = '</etc/os-release';
$apt->{'locale'} = 'locale'; $apt->{'locale'} = 'locale';
$apt->{aptgetupgrade} = 'echo n | sudo apt-get -s -q -V upgrade'; $apt->{aptgetupgrade} = 'echo n | sudo apt -s -q -V upgrade';
$apt->{aptgettoupgrade} = 'echo n | sudo apt-get -y -q -V upgrade' $apt->{aptgettoupgrade} = 'echo n | sudo apt -y -q -V upgrade'
if ( $aptget->{distupgrade} == 0 ); if ( $aptget->{distupgrade} == 0 );
$apt->{aptgettoupgrade} = 'echo n | sudo apt-get -y -q -V dist-upgrade' $apt->{aptgettoupgrade} = 'echo n | sudo apt -y -q -V dist-upgrade'
if ( $aptget->{distupgrade} == 1 ); if ( $aptget->{distupgrade} == 1 );
} }
@ -666,6 +666,13 @@ sub AptUpdate($) {
Log3 'Update', 4, "Daten erhalten"; Log3 'Update', 4, "Daten erhalten";
} }
elsif ( $line =~ s#^sudo: no tty present and no askpass program specified## ) { # error
my $error = {};
$error->{message} = 'did you create an /etc/sudoers.d entry? Example: fhem ALL = NOPASSWD: /usr/bin/apt';
push( @{ $update->{error} }, $error );
$update->{'state'} = 'errors';
Log3 'Update', 4, "Error";
}
elsif ( $line =~ s#^E: ## ) { # error elsif ( $line =~ s#^E: ## ) { # error
my $error = {}; my $error = {};
$error->{message} = $line; $error->{message} = $line;
@ -1051,7 +1058,7 @@ sub ToDay() {
<u><b>AptToDate - Retrieves apt information about Debian update state state</b></u> <u><b>AptToDate - Retrieves apt information about Debian update state state</b></u>
<br> <br>
With this module it is possible to read the apt update information from a Debian System.</br> With this module it is possible to read the apt update information from a Debian System.</br>
It's required to insert "fhem ALL=NOPASSWD: /usr/bin/apt-get" via "visudo". It's required to insert "fhem ALL=NOPASSWD: /usr/bin/apt" via "visudo".
<br><br> <br><br>
<a name="AptToDatedefine"></a> <a name="AptToDatedefine"></a>
<b>Define</b> <b>Define</b>
@ -1115,7 +1122,7 @@ sub ToDay() {
<u><b>AptToDate - Stellt aktuelle Update Informationen von apt Debian Systemen bereit</b></u> <u><b>AptToDate - Stellt aktuelle Update Informationen von apt Debian Systemen bereit</b></u>
<br> <br>
Das Modul synct alle Repositotys und stellt dann Informationen &uuml;ber zu aktualisierende Packete bereit.</br> Das Modul synct alle Repositotys und stellt dann Informationen &uuml;ber zu aktualisierende Packete bereit.</br>
Es ist Voraussetzung das folgende Zeile via "visudo" eingef&uuml;gt wird: "fhem ALL=NOPASSWD: /usr/bin/apt-get". Es ist Voraussetzung das folgende Zeile via "visudo" eingef&uuml;gt wird: "fhem ALL=NOPASSWD: /usr/bin/apt".
<br><br> <br><br>
<a name="AptToDatedefine"></a> <a name="AptToDatedefine"></a>
<b>Define</b> <b>Define</b>
@ -1186,7 +1193,7 @@ sub ToDay() {
"fhem-core", "fhem-core",
"Debian", "Debian",
"apt", "apt",
"apt-get", "apt",
"dpkg", "dpkg",
"Package" "Package"
], ],