Skip to content

Commit

Permalink
Onmly execute Mosquitto repairing if we are already on 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mschlenstedt committed Apr 1, 2023
1 parent 674de30 commit b05a7dc
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions sbin/loxberryupdate/update_v3.0.0.3.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@

init();

LOGINF "Repairing broken Mosquitto Installation";
$lbversion = version->parse(vers_tag(LoxBerry::System::lbversion()));
$lbversionmajor = $lbversion =~ s/^v(\d+)\..*/$1/r; # Major Version, e. g. "2"

# Install Mosquitto and overwrite modified conf files with original configuration
execute( command => "APT_LISTCHANGES_FRONTEND=none DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -y --allow-unauthenticated --fix-broken --reinstall --allow-downgrades --allow-remove-essential --allow-change-held-packages -o Dpkg::Options::='--force-confask,confnew,confmiss' install mosquitto", log => $log, ignoreerrors => 1 );
if ($lbversionmajor eq "3") {
LOGINF "Repairing broken Mosquitto Installation";

# Install Mosquitto and overwrite modified conf files with original configuration
execute( command => "APT_LISTCHANGES_FRONTEND=none DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -y --allow-unauthenticated --fix-broken --reinstall --allow-downgrades --allow-remove-essential --allow-change-held-packages -o Dpkg::Options::='--force-confask,confnew,confmiss' install mosquitto", log => $log, ignoreerrors => 1 );

execute( command => "mkdir --parents /opt/backup.mqttgateway", log => $log, ignoreerrors => 1);
execute( command => "mkdir --parents /opt/backup.mqttgateway", log => $log, ignoreerrors => 1);

if ( -e "/etc/mosquitto/mosquitto.conf.dpkg-dist" ) {
execute( command => "cp /etc/mosquitto/mosquitto.conf /opt/backup.mqttgateway/etc_mosquitto.conf", log => $log );
unlink ("/etc/mosquitto/mosquitto.conf");
execute( command => "mv /etc/mosquitto/mosquitto.conf.dpkg-dist /etc/mosquitto/mosquitto.conf", log => $log );
}
if ( -e "/etc/mosquitto/mosquitto.conf.dpkg-dist" ) {
execute( command => "cp /etc/mosquitto/mosquitto.conf /opt/backup.mqttgateway/etc_mosquitto.conf", log => $log );
unlink ("/etc/mosquitto/mosquitto.conf");
execute( command => "mv /etc/mosquitto/mosquitto.conf.dpkg-dist /etc/mosquitto/mosquitto.conf", log => $log );
}

if ( -e "/etc/mosquitto/mosquitto.conf.dpkg-old" ) {
execute( command => "cp /etc/mosquitto/mosquitto.conf.dpkg-old /opt/backup.mqttgateway/etc_mosquitto.conf", log => $log );
if ( -e "/etc/mosquitto/mosquitto.conf.dpkg-old" ) {
execute( command => "cp /etc/mosquitto/mosquitto.conf.dpkg-old /opt/backup.mqttgateway/etc_mosquitto.conf", log => $log );
}
}


LOGOK "Done.";

## If this script needs a reboot, a reboot.required file will be created or appended
Expand Down

0 comments on commit b05a7dc

Please sign in to comment.