include_once dirname(__FILE__) . '/framework/frame.class.inc'; $_GET["APT-GET"] = "/usr/bin/apt-get"; if (!is_file($_GET["APT-GET"])) { die; } if (systemMaxOverloaded()) { writelogs("This system is too many overloaded, die()", __FUNCTION__, __FILE__, __LINE__); die; } include_once dirname(__FILE__) . '/framework/class.unix.inc'; if (!Build_pid_func(__FILE__, "MAIN")) { writelogs(basename(__FILE__) . ":Already executed.. aborting the process", basename(__FILE__), __FILE__, __LINE__); die; } if ($argv[1] == '--update') { GetUpdates(); die; } if ($argv[1] == '--upgrade') { UPGRADE(); die; } function GetUpdates() { if (COUNT_REPOS() == 0) { INSERT_DEB_PACKAGES(); } $unix = new unix(); $tmpf = $unix->FILE_TEMP(); $sock = new sockets(); $ini = new Bs_IniHandler();
function UPGRADE($noupdate = false) { if (system_is_overloaded(basename(__FILE__))) { system_admin_events("This system is too many overloaded, die()", __FUNCTION__, __FILE__, __LINE__, "system-update"); die; } $called = null; if (function_exists("debug_backtrace")) { $trace = debug_backtrace(); if (isset($trace[1])) { $called = " called by " . basename($trace[1]["file"]) . " {$trace[1]["function"]}() line {$trace[1]["line"]}"; } } system_admin_events("Running UPGRADE {$called}", __FUNCTION__, __FILE__, __LINE__, "system-update"); @unlink("/usr/share/artica-postfix/ressources/logs/web/debian.update.html"); $unix = new unix(); $sock = new sockets(); $EnableRebootAfterUpgrade = $sock->GET_INFO("EnableRebootAfterUpgrade"); if (!is_numeric($EnableRebootAfterUpgrade)) { $EnableRebootAfterUpgrade = 0; } $tmpf = $unix->FILE_TEMP(); $txt = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin\n"; $txt = $txt . "echo \$PATH >{$tmpf} 2>&1\n"; $txt = $txt . "rm -f {$tmpf}\n"; $tmpf = $unix->FILE_TEMP(); @file_put_contents($tmpf, $txt); @chmod($tmpf, '0777'); shell_exec($tmpf); $tmpf = $unix->FILE_TEMP(); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes update >{$tmpf} 2>&1"; system_admin_events($cmd, __FUNCTION__, __FILE__, __LINE__, "system-update"); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes install -f >{$tmpf} 2>&1"; system_admin_events($cmd, __FUNCTION__, __FILE__, __LINE__, "system-update"); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes upgrade >>{$tmpf} 2>&1"; system_admin_events($cmd, __FUNCTION__, __FILE__, __LINE__, "system-update"); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes dist-upgrade >>{$tmpf} 2>&1"; system_admin_events($cmd, __FUNCTION__, __FILE__, __LINE__, "system-update"); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes autoremove >>{$tmpf} 2>&1"; system_admin_events($cmd, __FUNCTION__, __FILE__, __LINE__, "system-update"); shell_exec($cmd); $datas = @file_get_contents($tmpf); $datassql = addslashes($datas); $q = new mysql(); $sql = "INSERT IGNORE INTO debian_packages_logs(zDate,package_name,events,install_type) VALUES(NOW(),'artica-upgrade','{$datassql}','upgrade');"; $q->QUERY_SQL($sql, "artica_backup"); @unlink('/etc/artica-postfix/apt.upgrade.cache'); if (!$noupdate) { GetUpdates(); } send_email_events("Debian/Ubuntu System upgrade operation", $datas, "update"); INSERT_DEB_PACKAGES(); if ($EnableRebootAfterUpgrade == 1) { send_email_events("Rebooting after upgrade operation", "reboot command has been performed", "update"); shell_exec("reboot"); } }
$_GET["APT-GET"]="/usr/bin/apt-get"; if(!is_file($_GET["APT-GET"])){die();} if(systemMaxOverloaded()){ writelogs("This system is too many overloaded, die()",__FUNCTION__,__FILE__,__LINE__); die(); } include_once(dirname(__FILE__).'/framework/class.unix.inc'); if(!Build_pid_func(__FILE__,"MAIN")){ writelogs(basename(__FILE__).":Already executed.. aborting the process",basename(__FILE__),__FILE__,__LINE__); die(); } if($argv[1]=='--update'){GetUpdates();die();} if($argv[1]=='--upgrade'){UPGRADE();die();} if($argv[1]=='--sources-list'){CheckSourcesList();die();} function GetUpdates(){ if(COUNT_REPOS()==0){INSERT_DEB_PACKAGES();} $unix=new unix(); $tmpf=$unix->FILE_TEMP(); CheckSourcesList(); $sock=new sockets(); $ini=new Bs_IniHandler(); $configDisk=trim($sock->GET_INFO('ArticaAutoUpdateConfig')); $ini->loadString($configDisk);