From 2099f39d58c06f09dd438307e7137b368a63f01b Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 25 Oct 2016 12:41:06 -0400 Subject: [PATCH] Add the auto-update hooks directly into the sysadm server. Now the automatic 15 minute health checks will startup the update process if the autoupdate option is set rather than relying on anacrontab. --- src/server/EventWatcher.cpp | 13 ++++++++++++- src/server/library/sysadm-update.cpp | 5 +++++ src/server/library/sysadm-update.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/server/EventWatcher.cpp b/src/server/EventWatcher.cpp index d26562e..8b54458 100644 --- a/src/server/EventWatcher.cpp +++ b/src/server/EventWatcher.cpp @@ -371,6 +371,18 @@ void EventWatcher::CheckSystemState(){ if(updates.value("status").toString()!="noupdates"){ int tmp = 2; if(updates.value("status").toString()=="rebootrequired"){ tmp = 9; } //user input required + else if(updates.value("status").toString()!="updaterunning"){ + //updates are available - see if the auto-update flag is set, and start the updates as needed + QJsonObject upset = sysadm::Update::readSettings(); + QDateTime last = sysadm::Update::lastFullCheck().addSecs(60); //wait one interval before starting auto-updates (15 min intervals usually) + if( (!upset.contains("auto_update") || updates.value("auto_update").toString().toLower()!="all") && (QDateTime::currentDateTime() > last) ){ + QJsonObject obj; + obj.insert("target", "pkgupdate"); //since everything is run with pkg now + sysadm::Update::startUpdate(obj); + QCoreApplication::processEvents(); //make sure everything gets started + updates = sysadm::Update::checkUpdates(true); //will be almost instant - updates should already be running now + } + } if(priority