mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
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.
This commit is contained in:
@@ -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<tmp){priority = tmp;} //bump up the priority to the top of the "Information" range (updates available/running)
|
||||
}
|
||||
obj.insert("updates",updates);
|
||||
@@ -385,4 +397,3 @@ void EventWatcher::CheckSystemState(){
|
||||
HASH.insert(SYSSTATE, obj);
|
||||
emit NewEvent(SYSSTATE, obj);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,11 @@ using namespace sysadm;
|
||||
|
||||
//PLEASE: Keep the functions in the same order as listed in pcbsd-general.h
|
||||
|
||||
//Return the date/time that the last full check for updates was run
|
||||
QDateTime Update::lastFullCheck(){
|
||||
return QFileInfo(UP_UPFILE).lastModified();
|
||||
}
|
||||
|
||||
// Return a list of updates available
|
||||
QJsonObject Update::checkUpdates(bool fast) {
|
||||
//NOTE: The "fast" option should only be used for automated/timed checks (to prevent doing this long check too frequently)
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace sysadm{
|
||||
|
||||
class Update{
|
||||
public:
|
||||
static QDateTime lastFullCheck();
|
||||
static QJsonObject checkUpdates(bool fast = false);
|
||||
static QJsonObject listBranches();
|
||||
//Start/stop update routine
|
||||
|
||||
Reference in New Issue
Block a user