function UPGRADE() { $unix = new unix(); $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"; writelogs($cmd, __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes install -f >{$tmpf} 2>&1"; writelogs($cmd, __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes upgrade >>{$tmpf} 2>&1"; writelogs($cmd, __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); $datas = @file_get_contents($tmpf); $datassql = addslashes($datas); $q = new mysql(); $sql = "INSERT 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'); send_email_events("Debian/Ubuntu System upgrade operation", $datas, "system"); INSERT_DEB_PACKAGES(); THREAD_COMMAND_SET(LOCATE_PHP5_BIN() . " /usr/share/artica-postfix/exec.admin.status.postfix.flow.php --services"); }
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"); } }
function UPGRADE() { @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"; writelogs($cmd, __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes install -f >{$tmpf} 2>&1"; writelogs($cmd, __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes upgrade >>{$tmpf} 2>&1"; writelogs($cmd, __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes dist-upgrade >>{$tmpf} 2>&1"; writelogs($cmd, __FUNCTION__, __FILE__, __LINE__); shell_exec($cmd); $cmd = "DEBIAN_FRONTEND=noninteractive {$_GET["APT-GET"]} -o Dpkg::Options::=\"--force-confnew\" --force-yes --yes autoremove >>{$tmpf} 2>&1"; writelogs($cmd, __FUNCTION__, __FILE__, __LINE__); 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'); send_email_events("Debian/Ubuntu System upgrade operation", $datas, "system"); INSERT_DEB_PACKAGES(); if ($EnableRebootAfterUpgrade == 1) { send_email_events("Rebooting after upgrade operation", "reboot command has been performed", "system"); shell_exec("reboot"); } }