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); $AUTOUPDATE=$ini->_params["AUTOUPDATE"]; if(trim($AUTOUPDATE["auto_apt"])==null){$AUTOUPDATE["auto_apt"]="no";} shell_exec("{$_GET["APT-GET"]} update >/dev/null 2>&1"); shell_exec("{$_GET["APT-GET"]} -f install --force-yes >/dev/null 2>&1"); shell_exec("{$_GET["APT-GET"]} upgrade -s >$tmpf 2>&1"); $datas=@file_get_contents($tmpf); $tbl=explode("\n",$datas); writelogs("Found ". strlen($datas)." bytes for apt",__FUNCTION__,__FILE__,__LINE__); @unlink($tmpf); while (list ($num, $val) = each ($tbl) ){ if($val==null){continue;} if(preg_match("#^Inst\s+(.+?)\s+#",$val,$re)){ $packages[]=$re[1]; writelogs("Found {$re[1]} new package",__FUNCTION__,__FILE__,__LINE__); //dpkg_configure_a(); }else{ if(preg_match("#dpkg was interrupted.+?dpkg --configure -a#",$val)){ writelogs("Error found ",__FUNCTION__,__FILE__,__LINE__); } writelogs("Garbage \"$val\"",__FUNCTION__,__FILE__,__LINE__); } } $count=count($packages); if($count>0){ @file_put_contents("/etc/artica-postfix/apt.upgrade.cache",implode("\n",$packages)); $text="You can perform upgrade of linux packages for\n".@file_get_contents("/etc/artica-postfix/apt.upgrade.cache"); send_email_events("new upgrade $count packages(s) ready",$text,"system"); THREAD_COMMAND_SET(LOCATE_PHP5_BIN()." /usr/share/artica-postfix/exec.admin.status.postfix.flow.php --services"); if($AUTOUPDATE["auto_apt"]=="yes"){ UPGRADE(); } }else{ writelogs("No new packages...",__FUNCTION__,__FILE__,__LINE__); @unlink("/etc/artica-postfix/apt.upgrade.cache"); } }
function GetUpdates() { @mkdir("/usr/share/artica-postfix/ressources/logs/web", 755, true); @unlink("/usr/share/artica-postfix/ressources/logs/web/debian.update.html"); 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); $AUTOUPDATE = $ini->_params["AUTOUPDATE"]; if (trim($AUTOUPDATE["auto_apt"]) == null) { $AUTOUPDATE["auto_apt"] = "no"; } shell_exec("{$_GET["APT-GET"]} update >/dev/null 2>&1"); shell_exec("{$_GET["APT-GET"]} -f install --force-yes >/dev/null 2>&1"); shell_exec("{$_GET["APT-GET"]} upgrade -s >{$tmpf} 2>&1"); $datas = @file_get_contents($tmpf); $tbl = explode("\n", $datas); writelogs("Found " . strlen($datas) . " bytes for apt", __FUNCTION__, __FILE__, __LINE__); @unlink($tmpf); while (list($num, $val) = each($tbl)) { if ($val == null) { continue; } if (preg_match("#^Inst\\s+(.+?)\\s+#", $val, $re)) { $packages[] = $re[1]; writelogs("Found {$re[1]} new package", __FUNCTION__, __FILE__, __LINE__); //dpkg_configure_a(); } else { if (preg_match("#dpkg was interrupted.+?dpkg --configure -a#", $val)) { writelogs("Error found ", __FUNCTION__, __FILE__, __LINE__); } writelogs("Garbage \"{$val}\"", __FUNCTION__, __FILE__, __LINE__); } } $count = count($packages); if ($count > 0) { @file_put_contents("/etc/artica-postfix/apt.upgrade.cache", implode("\n", $packages)); $text = "You can perform upgrade of linux packages for\n" . @file_get_contents("/etc/artica-postfix/apt.upgrade.cache"); send_email_events("new upgrade {$count} packages(s) ready", $text, "system"); $paragraph = ParagrapheTEXT('32-infos.png', "{$count} {system_packages}", "{$count} {system_packages_can_be_upgraded}", "javascript:Loadjs('artica.repositories.php');\n\t\t", "{system_packages_can_be_upgraded}", 300, 80); @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/debian.update.html", $paragraph); shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/web/debian.update.html"); if ($AUTOUPDATE["auto_apt"] == "yes") { UPGRADE(); } } else { writelogs("No new packages...", __FUNCTION__, __FILE__, __LINE__); @unlink("/etc/artica-postfix/apt.upgrade.cache"); } }
function GetUpdates() { if (system_is_overloaded(basename(__FILE__))) { system_admin_events("This system is too many overloaded, die()", __FUNCTION__, __FILE__, __LINE__, "system-update"); die; } $sock = new sockets(); $EnableSystemUpdates = $sock->GET_INFO("EnableSystemUpdates"); if (!is_numeric($EnableSystemUpdates)) { $EnableSystemUpdates = 0; } if ($EnableSystemUpdates == 0) { clean_upgrade(); return; } @mkdir("/usr/share/artica-postfix/ressources/logs/web", 0755, true); @unlink("/usr/share/artica-postfix/ressources/logs/web/debian.update.html"); $unix = new unix(); if (is_file("/etc/artica-postfix/FROM_ISO")) { $time = $unix->file_time_min("/etc/artica-postfix/FROM_ISO"); if ($time < 60) { return; } } $tmpf = $unix->FILE_TEMP(); exim_remove(); CheckSourcesList(); wsgate_debian(); $sock = new sockets(); $ini = new Bs_IniHandler(); $users = new usersMenus(); $configDisk = trim($sock->GET_INFO('ArticaAutoUpdateConfig')); $ini->loadString($configDisk); $AUTOUPDATE = $ini->_params["AUTOUPDATE"]; $EXEC_NICE = EXEC_NICE(); $nohup = $unix->find_program("nohup"); if (trim($AUTOUPDATE["auto_apt"]) == null) { $AUTOUPDATE["auto_apt"] = "no"; } $q = new mysql(); php_fpm(); if ($GLOBALS["VERBOSE"]) { system_admin_events("Running apt-check", __FUNCTION__, __FILE__, __LINE__, "system-update"); } exec("{$_GET["APT-GET"]} check 2>&1", $results); if ($GLOBALS["VERBOSE"]) { system_admin_events("Running apt-check -> " . count($results) . " items", __FUNCTION__, __FILE__, __LINE__, "update"); } while (list($num, $line) = each($results)) { if ($GLOBALS["VERBOSE"]) { system_admin_events("apt-check: {$line}", __FUNCTION__, __FILE__, __LINE__, "update"); } if (preg_match("#dpkg --configure -a#", $line)) { $cmd = "DEBIAN_FRONTEND=noninteractive dpkg --configure -a --force-confold 2>&1"; if ($GLOBALS["VERBOSE"]) { system_admin_events("apt-check: Executing {$cmd}", __FUNCTION__, __FILE__, __LINE__, "update"); } exec("{$cmd}", $results1); while (list($num1, $line1) = each($results1)) { if (preg_match("#hardlink between a file in.+?backuppc#", $line1)) { if ($GLOBALS["VERBOSE"]) { system_admin_events("apt-check: remove backuppc", __FUNCTION__, __FILE__, __LINE__, "update"); } shell_exec("{$_GET["APT-GET"]} -y remove backuppc --force-yes "); } } system_admin_events("dpkg was interrupted\nReconfigure has been performed\n" . @implode("\n", $results1), __FUNCTION__, __FILE__, __LINE__, "update", "update"); if ($GLOBALS["VERBOSE"]) { system_admin_events("apt-check: reconfigure:\n" . @implode("\n", $results1), __FUNCTION__, __FILE__, __LINE__, "update"); } return; } } exec("{$_GET["APT-GET"]} update 2>&1", $results); while (list($num, $line) = each($results)) { if ($GLOBALS["VERBOSE"]) { system_admin_events("update: {$line}", __FUNCTION__, __FILE__, __LINE__, "system-update"); } } $results = array(); exec("{$_GET["APT-GET"]} -f install --force-yes 2>&1", $results); while (list($num, $line) = each($results)) { if (preg_match("#hardlink between a file in.+?backuppc#", $line)) { if ($GLOBALS["VERBOSE"]) { system_admin_events("apt-check: remove backuppc \"{$_GET["APT-GET"]} remove backuppc --force-yes\"", __FUNCTION__, __FILE__, __LINE__, "system-update"); } shell_exec("{$_GET["APT-GET"]} -y remove backuppc --force-yes "); } if ($GLOBALS["VERBOSE"]) { system_admin_events("-f install: {$line}", __FUNCTION__, __FILE__, __LINE__, "system-update"); } } if (COUNT_REPOS() == 0) { if ($GLOBALS["VERBOSE"]) { system_admin_events(" -> INSERT_DEB_PACKAGES()", __FUNCTION__, __FILE__, __LINE__, "system-update"); } INSERT_DEB_PACKAGES(); } shell_exec("{$_GET["APT-GET"]} -f install --force-yes >/dev/null 2>&1"); shell_exec("{$_GET["APT-GET"]} upgrade -s >{$tmpf} 2>&1"); $datas = @file_get_contents($tmpf); $tbl = explode("\n", $datas); system_admin_events("Found " . strlen($datas) . " bytes for apt", __FUNCTION__, __FILE__, __LINE__, "system-update"); @unlink($tmpf); $q->QUERY_SQL("TRUNCATE TABLE syspackages_updt", "artica_backup"); while (list($num, $val) = each($tbl)) { if ($val == null) { continue; } if (preg_match("#^Inst\\s+(.+?)\\s+#", $val, $re)) { $packages[] = $re[1]; if (preg_match("#libclamav#", $re[1])) { if ($users->KASPERSKY_WEB_APPLIANCE) { shell_exec("{$EXEC_NICE}{$_GET["APT-GET"]} remove -y -q libclamav* clamav* --purge"); continue; } } system_admin_events("Found {$re[1]} new package", __FUNCTION__, __FILE__, __LINE__, "system-update"); $q->QUERY_SQL("INSERT IGNORE INTO syspackages_updt (package) VALUES('" . addslashes(trim($re[1])) . "')", "artica_backup"); if (!$q->ok) { echo "{$q->mysql_error}\n"; } if (!$q->ok) { if (preg_match("#doesn't exist#", $q->mysql_error)) { $q->BuildTables(); $q->QUERY_SQL("INSERT IGNORE INTO syspackages_updt (package) VALUES('" . trim($re[1]) . "')", "artica_backup"); } } } else { if (preg_match("#dpkg was interrupted.+?dpkg --configure -a#", $val)) { send_email_events("dpkg was interrupted", "{reconfigure} all will be performed\n{$val}", "update"); shell_exec("DEBIAN_FRONTEND=noninteractive dpkg --configure -a --force-confold >/dev/null"); return; } if (preg_match("#dpkg --configure -a#", $val)) { send_email_events("dpkg was interrupted", "{reconfigure} all will be performed\n{$val}", "update"); shell_exec("DEBIAN_FRONTEND=noninteractive dpkg --configure -a --force-confold >/dev/null"); return; } system_admin_events("Garbage \"{$val}\"", __FUNCTION__, __FILE__, __LINE__, "system-update"); } } $count = count($packages); if ($count > 0) { @file_put_contents("/etc/artica-postfix/apt.upgrade.cache", implode("\n", $packages)); $text = "You can perform upgrade of linux packages for\n" . @file_get_contents("/etc/artica-postfix/apt.upgrade.cache"); system_admin_events("New upgrade {$count} packages(s) ready {$text}", __FUNCTION__, __FILE__, __LINE__, "update"); send_email_events("new upgrade {$count} packages(s) ready", $text, "update"); $paragraph = ParagrapheTEXT('32-infos.png', "{$count} {system_packages}", "{$count} {system_packages_can_be_upgraded}", "javascript:Loadjs('artica.update.php');\n\t\t", "{system_packages_can_be_upgraded}", 300, 80); @file_put_contents("/usr/share/artica-postfix/ressources/logs/web/debian.update.html", $paragraph); shell_exec("/bin/chmod 777 /usr/share/artica-postfix/ressources/logs/web/debian.update.html"); if ($AUTOUPDATE["auto_apt"] == "yes") { UPGRADE(true); } } else { system_admin_events("No new packages...", __FUNCTION__, __FILE__, __LINE__, "update"); @unlink("/etc/artica-postfix/apt.upgrade.cache"); } exec("/usr/share/artica-postfix/bin/setup-ubuntu --check-base-system 2>&1", $results2); system_admin_events("Checks Artica required packages done\n" . @implode("\n", $results2), __FUNCTION__, __FILE__, __LINE__, "update"); }