From 5a43e7a2ea0cf7af35c100cb67e4a53566cbc496 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Fri, 03 Feb 2012 05:58:01 -0500
Subject: [PATCH] - Implemented new backup and restore functions for websites and databases (see also FS#1389) - Added "actions" framework in server to replace the functions provided by the core modules - Moved system update function from remoteactins core module to software update plugin.

---
 server/plugins-available/software_update_plugin.inc.php |   34 ++++++++++++++++++++++++++++------
 1 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/server/plugins-available/software_update_plugin.inc.php b/server/plugins-available/software_update_plugin.inc.php
index 55feaee..a6b7162 100644
--- a/server/plugins-available/software_update_plugin.inc.php
+++ b/server/plugins-available/software_update_plugin.inc.php
@@ -1,7 +1,7 @@
 <?php
 
 /*
-Copyright (c) 2007, Till Brehm, projektfarm Gmbh
+Copyright (c) 2007-2012, Till Brehm, projektfarm Gmbh, Oliver Vogel www.muv.com
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification,
@@ -35,7 +35,7 @@
 	
 	//* This function is called during ispconfig installation to determine
 	//  if a symlink shall be created for this plugin.
-	function onInstall() {
+	public function onInstall() {
 		global $conf;
 		
 		return true;
@@ -47,29 +47,31 @@
 	 	This function is called when the plugin is loaded
 	*/
 	
-	function onLoad() {
+	public function onLoad() {
 		global $app;
 		
 		/*
 		Register for the events
 		*/
 		
-		//* Mailboxes
 		$app->plugins->registerEvent('software_update_inst_insert',$this->plugin_name,'process');
 		//$app->plugins->registerEvent('software_update_inst_update',$this->plugin_name,'process');
 		//$app->plugins->registerEvent('software_update_inst_delete',$this->plugin_name,'process');
 		
+		//* Register for actions
+		$app->plugins->registerAction('os_update',$this->plugin_name,'os_update');
+		
 		
 	}
 	
-	function set_install_status($inst_id, $status) {
+	private function set_install_status($inst_id, $status) {
         global $app;
         
         $app->db->query("UPDATE software_update_inst SET status = '{$status}' WHERE software_update_inst_id = '{$inst_id}'");
         $app->dbmaster->query("UPDATE software_update_inst SET status = '{$status}' WHERE software_update_inst_id = '{$inst_id}'");
     }
     
-	function process($event_name,$data) {
+	public function process($event_name,$data) {
 		global $app, $conf;
 		
 		//* Get the info of the package:
@@ -271,6 +273,26 @@
 		}
 		
 	}
+	
+	//* Operating system update
+	public function os_update($action_name,$data) {
+		global $app;
+		 
+		//** Debian and compatible Linux distributions
+		if(file_exists('/etc/debian_version')) {
+			exec("aptitude update");
+			exec("aptitude safe-upgrade -y");
+			$app->log('Execeuted Debian / Ubuntu update',LOGLEVEL_DEBUG);
+		}
+
+		//** Gentoo Linux
+		if(file_exists('/etc/gentoo-release')) {
+			exec("glsa-check -f --nocolor affected");
+			$app->log('Execeuted Gentoo update',LOGLEVEL_DEBUG);
+		}
+		
+		return 'ok';
+	}
 
 } // end class
 

--
Gitblit v1.9.1