本文整理汇总了PHP中unix::TARGZ_TEST_CONTAINER方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::TARGZ_TEST_CONTAINER方法的具体用法?PHP unix::TARGZ_TEST_CONTAINER怎么用?PHP unix::TARGZ_TEST_CONTAINER使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unix
的用法示例。
在下文中一共展示了unix::TARGZ_TEST_CONTAINER方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ufdbtables_artica_meta
//.........这里部分代码省略.........
}
if (!is_file("/etc/artica-postfix/ufdbcounts.txt")) {
$curl = $meta->buildCurl("/meta-updates/webfiltering/ufdbcounts.txt");
if (!$curl->GetFile("/etc/artica-postfix/ufdbcounts.txt")) {
artica_update_event(0, "Failed Downloading webfiltering/ufdbcounts.txt", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed Downloading webfiltering/ufdbcounts.txt", @implode("\n", $curl->errors), __FILE__, __LINE__);
}
}
$Remote_version = intval(@file_get_contents("{$tmpdir}/ufdbartica.txt"));
echo "Current............: {$myVersion}\n";
echo "Available..........: {$Remote_version}\n";
$Remote_versionTime = date("Y-m-d H:i:s", $Remote_version);
$rm = $unix->find_program("rm");
$cat = $unix->find_program("cat");
$tar = $unix->find_program("tar");
if ($myVersion == $Remote_version) {
echo "My version {$myVersion} is the same than {$Remote_version} {$Remote_versionTime}, aborting\n";
return;
}
if ($myVersion > $Remote_version) {
echo "My version {$myVersion} is newest than {$Remote_version} {$Remote_versionTime}, aborting\n";
return;
}
$curl = $meta->buildCurl("/meta-updates/webfiltering/ufdbartica/ufdbartica.txt");
//***************************************************************************************************************
if ($curl->GetFile("{$tmpdir}/ufdbartica.txt")) {
$ufdbartica_tmp = "{$tmpdir}/ufdbartica_tmp";
@mkdir($ufdbartica_tmp, 0755, true);
$splitted = unserialize(@file_get_contents("{$tmpdir}/ufdbartica.txt"));
if (is_array($splitted)) {
if (count($splitted) > 2) {
while (list($targetFile, $md5file) = each($ARRAY)) {
$BaseName = basename($targetFile);
$HTTP_LINK = "/meta-updates/webfiltering/ufdbartica/{$BaseName}";
$LOCAL_FILE = "{$ufdbartica_tmp}/{$BaseName}";
writelogs_meta("Checking {$LOCAL_FILE}", __FUNCTION__, __FILE__, __LINE__);
if (is_file($LOCAL_FILE)) {
$md5Local = md5_file($LOCAL_FILE);
if ($md5Local == $md5file) {
continue;
}
writelogs_meta("{$LOCAL_FILE} corrupted...", __FUNCTION__, __FILE__, __LINE__);
@unlink($LOCAL_FILE);
}
writelogs_meta("Downloading {$HTTP_LINK}", __FUNCTION__, __FILE__, __LINE__);
$curl = $meta->buildCurl($HTTP_LINK);
if (!$curl->GetFile($LOCAL_FILE)) {
writelogs_meta("Unable to download {$HTTP_LINK} {$curl->error}\n" . @implode("\n", $curl->errors), __FUNCTION__, __FILE__, __LINE__);
return true;
}
$md5Local = md5_file($LOCAL_FILE);
if ($md5Local == $md5file) {
writelogs_meta("{$HTTP_LINK} success...", __FUNCTION__, __FILE__, __LINE__);
continue;
}
}
system("{$cat} {$ufdbartica_tmp}/*.tgz.* >{$tmpdir}/ufdbartica.tgz");
}
}
}
//***************************************************************************************************************
@unlink("{$tmpdir}/ufdbartica.txt");
if (!is_file("{$tmpdir}/ufdbartica.tgz")) {
$curl = $meta->buildCurl("/meta-updates/webfiltering/ufdbartica.tgz");
if (!$curl->GetFile("{$tmpdir}/ufdbartica.tgz")) {
artica_update_event(0, "Failed Downloading webfiltering/ufdbartica.tgz", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed Downloading webfiltering/ufdbartica.tgz", @implode("\n", $curl->errors), __FILE__, __LINE__);
@unlink("{$tmpdir}/ufdbartica.tgz");
return false;
}
}
$curl = $meta->buildCurl("/meta-updates/webfiltering/index.txt");
if (!$curl->GetFile("/etc/artica-postfix/artica-webfilter-db-index.txt")) {
artica_update_event(0, "Failed Downloading webfiltering/index.txt", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed Downloading webfiltering/index.txt", @implode("\n", $curl->errors), __FILE__, __LINE__);
}
$curl = $meta->buildCurl("/meta-updates/webfiltering/ARTICAUFDB_LAST_DOWNLOAD");
$curl->GetFile("/etc/artica-postfix/ARTICAUFDB_LAST_DOWNLOAD");
$STATUS = unserialize(@file_get_contents("/etc/artica-postfix/ARTICAUFDB_LAST_DOWNLOAD"));
$STATUS["LAST_DOWNLOAD"]["LAST_CHECK"] = time();
@file_put_contents("/etc/artica-postfix/ARTICAUFDB_LAST_DOWNLOAD", serialize($STATUS));
if (!$unix->TARGZ_TEST_CONTAINER("{$tmpdir}/ufdbartica.tgz")) {
artica_update_event(0, "Failed {$tmpdir}/ufdbartica.tgz corrupted package", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed {$tmpdir}/ufdbartica.tgz corrupted package", @implode("\n", $curl->errors), __FILE__, __LINE__);
@unlink("{$tmpdir}/ufdbartica.tgz");
return false;
}
@file_put_contents("/etc/artica-postfix/ufdbartica.txt", $Remote_version);
$tar = $unix->find_program("tar");
$php5 = $unix->LOCATE_PHP5_BIN();
shell_exec("{$tar} -xf {$tmpdir}/ufdbartica.tgz -C {$WORKDIR}/");
@unlink("{$tmpdir}/ufdbartica.tgz");
if (!is_file("/opt/ufdbcat/bin/ufdbcatdd")) {
system("{$php5} /usr/share/artica-postfix/exec.ufdbcat.php --install --noupdate");
}
shell_exec("/etc/init.d/ufdbcat reload");
artica_update_event(0, "Success Artica Webfiltering databases v.{$Remote_version}", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Success Artica Webfiltering databases v.{$Remote_version}", @implode("\n", $curl->errors), __FILE__, __LINE__);
updatev2_progress(100, "{done} [" . __LINE__ . "]");
}
示例2: install_package
function install_package($filename, $expected = null)
{
$unix = new unix();
$sock = new sockets();
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$rm = $unix->find_program("rm");
$RebootAfterArticaUpgrade = $sock->GET_INFO("RebootAfterArticaUpgrade");
if (!is_numeric($RebootAfterArticaUpgrade)) {
$RebootAfterArticaUpgrade = 0;
}
events("Starting......: " . date("H:i:s") . " install_package() Extracting package {$filename}, please wait... ");
echo "Starting......: " . date("H:i:s") . " install_package() Extracting package {$filename}, please wait... \n";
$tarbin = $unix->find_program("tar");
$killall = $unix->find_program("killall");
echo "Starting......: " . date("H:i:s") . " tar: {$tarbin}\n";
echo "Starting......: " . date("H:i:s") . " killall: {$killall}\n";
@file_put_contents("/usr/share/artica-postfix/download_progress", 10);
events("Starting......: " . date("H:i:s") . " install_package() Testing Package");
echo "Starting......: " . date("H:i:s") . " Testing Package " . basename($filename) . "\n";
if (!$unix->TARGZ_TEST_CONTAINER($filename)) {
echo "Starting......: " . date("H:i:s") . " Testing Package " . basename($filename) . " failed\n";
_artica_update_event(0, "Compressed package seems corrupted", null, __FILE__, __LINE__);
events("Fatal, Compressed package seems corrupted");
events($GLOBALS["TARGZ_TEST_CONTAINER_ERROR"]);
@unlink($filename);
@file_put_contents("/usr/share/artica-postfix/download_progress", 100);
return false;
}
events("Starting......: " . date("H:i:s") . " Purge directories...");
@file_put_contents("/usr/share/artica-postfix/download_progress", 40);
system("{$rm} -f /usr/share/artica-postfix/ressources/logs/*");
system("{$rm} -f /usr/share/artica-postfix/ressources/logs/web/*");
if (is_dir("/usr/share/artica-postfix/ressources/conf/upload")) {
system("{$rm} -f /usr/share/artica-postfix/ressources/conf/upload/*");
}
if (is_dir("/usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded")) {
system("{$rm} -f /usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded/*");
}
events("Starting......: " . date("H:i:s") . " Extracting...");
exec("{$tarbin} xf {$filename} -C /usr/share/ 2>&1", $results);
if (is_file("{$killall}")) {
shell_exec("{$killall} artica-install >/dev/null 2>&1");
}
@unlink($filename);
shell_exec("{$nohup} {$php} " . dirname(__FILE__) . "/exec.checkfolder-permissions.php --force >/dev/null 2>&1 &");
$MyCurrentVersion = GetCurrentVersionString();
if ($expected != null) {
if ($MyCurrentVersion != $expected) {
_artica_update_event(1, "install_package(): Expected version:{$expected} does not match {$MyCurrentVersion}", $results, __FILE__, __LINE__);
return;
}
}
_artica_update_event(2, "install_package(): Success updating to a new version v{$MyCurrentVersion}", $results, __FILE__, __LINE__);
if ($RebootAfterArticaUpgrade == 1) {
@file_put_contents("/usr/share/artica-postfix/download_progress", 100);
_artica_update_event(1, "install_package() Reboot the server in 10s...", null, __FILE__, __LINE__);
events("Reboot the server in 10s...");
system_admin_events("Warning: Reboot the server in 10s...", __FUNCTION__, __FILE__, __LINE__, "artica-update");
$shutdown = $unix->find_program("shutdown");
shell_exec("shutdown -r -t 10");
return true;
}
_artica_update_event(2, "install_package(): restart dedicated services...", null, __FILE__, __LINE__);
system_admin_events("Warning: Restart Artica dedicated services after an upgrade...", __FUNCTION__, __FILE__, __LINE__, "artica-update");
RestartDedicatedServices();
_artica_update_event(2, "install_package(): finish", null, __FILE__, __LINE__);
return true;
}
示例3: artica_meta_client
function artica_meta_client($force = false)
{
$unix = new unix();
$WORKDIR = "/var/lib/ftpunivtlse1fr";
@mkdir($WORKDIR, 0755, true);
@chmod($WORKDIR, 0755);
$tmpdir = $unix->TEMP_DIR();
$myVersion = intval(trim(@file_get_contents("/etc/artica-postfix/ftpunivtlse1fr.txt")));
$tmpdir = $unix->TEMP_DIR();
$meta = new artica_meta();
$curl = $meta->buildCurl("/meta-updates/webfiltering/ftpunivtlse1fr.txt");
if (!$curl->GetFile("{$tmpdir}/ftpunivtlse1fr.txt")) {
artica_update_event(0, "Failed Downloading webfiltering/ftpunivtlse1fr.txt", @implode("\n", $curl->errors), __FILE__, __LINE__);
$meta->events($curl->errors, __FUNCTION__, __FILE__, __LINE__);
meta_admin_mysql(0, "Failed Downloading webfiltering/ftpunivtlse1fr.txt", @implode("\n", $curl->errors), __FILE__, __LINE__);
return false;
}
$Remote_version = intval(trim(@file_get_contents("{$tmpdir}/ftpunivtlse1fr.txt")));
@unlink("{$tmpdir}/ftpunivtlse1fr.txt");
echo "Current............: {$myVersion}\n";
echo "Available..........: {$Remote_version}\n";
$datev = date("Y-m-d H:i:s", $myVersion);
$STATUS = unserialize(@file_get_contents("/etc/artica-postfix/TLSE_LAST_DOWNLOAD"));
$STATUS["LAST_CHECK"] = time();
@file_put_contents("/etc/artica-postfix/TLSE_LAST_DOWNLOAD", serialize($STATUS));
if ($myVersion > $Remote_version) {
echo "My version {$myVersion} is newest than {$Remote_version}, aborting\n";
build_progress("{version-up-to-date} {$datev}", 100);
return;
}
if ($myVersion == $Remote_version) {
build_progress("{version-up-to-date} {$datev}", 100);
echo "My version {$myVersion} is the same than {$Remote_version}, aborting\n";
return;
}
$curl = $meta->buildCurl("/meta-updates/webfiltering/ftpunivtlse1fr.tgz");
$curl->Timeout = 120;
if (!$curl->GetFile("{$tmpdir}/ftpunivtlse1fr.tgz")) {
artica_update_event(0, "Failed Downloading webfiltering/ftpunivtlse1fr.tgz", @implode("\n", $curl->errors), __FILE__, __LINE__);
$meta->events($curl->errors, __FUNCTION__, __FILE__, __LINE__);
meta_admin_mysql(0, "Failed Downloading webfiltering/ftpunivtlse1fr.tgz", @implode("\n", $curl->errors), __FILE__, __LINE__);
@unlink("{$tmpdir}/ftpunivtlse1fr.tgz");
return false;
}
if (!$unix->TARGZ_TEST_CONTAINER("{$tmpdir}/ftpunivtlse1fr.tgz")) {
artica_update_event(0, "Failed {$tmpdir}/ftpunivtlse1fr.tgz corrupted package", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed {$tmpdir}/ftpunivtlse1fr.tgz corrupted package", @implode("\n", $curl->errors), __FILE__, __LINE__);
@unlink("{$tmpdir}/ftpunivtlse1fr.tgz");
return false;
}
$tar = $unix->find_program("tar");
shell_exec("{$tar} -xf {$tmpdir}/ftpunivtlse1fr.tgz -C {$WORKDIR}/");
@unlink("{$tmpdir}/ftpunivtlse1fr.tgz");
artica_update_event(0, "Success update categories statistics v.{$Remote_version}", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Success update categories statistics v.{$Remote_version}", @implode("\n", $curl->errors), __FILE__, __LINE__);
@file_put_contents("/etc/artica-postfix/ftpunivtlse1fr.txt", $Remote_version);
build_progress("Using Artica Meta server {done}", 100);
CoherenceOffiels();
CoherenceRepertoiresUfdb();
BuildDatabaseStatus();
remove_bad_files();
}
示例4: backup_squidlogs
function backup_squidlogs($tablename)
{
$q = new mysql_squid_builder();
$unix = new unix();
$mysqldump = $unix->find_program("mysqldump");
$tar = $unix->find_program("tar");
$mysqldump_prefix = "{$mysqldump} {$q->MYSQL_CMDLINES} --skip-add-locks --insert-ignore --quote-names --skip-add-drop-table --verbose --force {$q->database} ";
$container = "/home/artica/squid/backup-statistics/{$tablename}.sql";
if (is_file($container)) {
return;
}
$cmdline = "{$mysqldump_prefix}{$tablename} >{$container}";
echo "{$cmdline}\n";
if ($GLOBALS["VERBOSE"]) {
echo "\n*******\n{$cmdline}\n*******\n";
}
exec($cmdline, $resultsZ);
if (!$unix->Mysql_TestDump($resultsZ, $container)) {
stats_admin_events(0, "Fatal Error: day: Dump failed {$tablename}", "", __FILE__, __LINE__);
}
$size = @filesize($container);
@mkdir("/home/artica/squid/backup-statistics", 0755, true);
chdir("/home/artica/squid/backup-statistics");
$cmdline = "{$tar} cfz {$container}.tar.gz {$container} 2>&1";
$resultsZ = array();
exec($cmdline, $resultsZ);
if ($GLOBALS["VERBOSE"]) {
while (list($a, $b) = each($resultsZ)) {
echo "Compress: `{$b}`\n";
}
}
if (!$unix->TARGZ_TEST_CONTAINER("{$container}.tar.gz")) {
stats_admin_events(0, "Test container failed: {$container}.tar.gz", "", __FILE__, __LINE__);
@unlink($container);
@unlink("{$container}.tar.gz");
return;
}
$size = FormatBytes($size / 1024);
@unlink($container);
return true;
}
示例5: purge
//.........这里部分代码省略.........
}
}
$tableTMP = "quotaday_" . date("Ymd", $DayTime) . "";
if ($q->TABLE_EXISTS($tableTMP)) {
$tablesB[$tableTMP] = true;
} else {
if ($GLOBALS["VERBOSE"]) {
echo "{$tableTMP} no such table, continue\n";
}
}
$tableTMP = date("Ymd", $DayTime) . "_catfam";
if ($q->TABLE_EXISTS($tableTMP)) {
$tablesB[$tableTMP] = true;
} else {
if ($GLOBALS["VERBOSE"]) {
echo "{$tableTMP} no such table, continue\n";
}
}
$c = array();
while (list($a, $b) = each($tablesB)) {
$c[] = $a;
}
reset($tablesB);
echo "Backup tables: " . @implode(", ", $c) . "\n";
if (count($tablesB) > 0) {
$cmdline = "{$mysqldump_prefix}" . @implode(" ", $c) . " >{$container}";
if ($GLOBALS["VERBOSE"]) {
echo "\n*******\n{$cmdline}\n*******\n";
}
$resultsZ = array();
exec($cmdline, $resultsZ);
if (!TestDump($resultsZ, $container)) {
ufdbguard_admin_events("Fatal Error: day: Dump failed {$day}", __FUNCTION__, __FILE__, __LINE__, "backup");
KillMountPoint();
return;
}
$size = @filesize($container);
chdir($ArticaProxyStatisticsBackupFolder);
$cmdline = "{$tar} cfz {$container}.tar.gz {$container} 2>&1";
$resultsZ = array();
exec($cmdline, $resultsZ);
while (list($a, $b) = each($resultsZ)) {
echo "Compress: `{$b}`\n";
}
if (!$unix->TARGZ_TEST_CONTAINER("{$container}.tar.gz")) {
squid_admin_purge(0, "Error {$container} failed", __FILE__, __LINE__);
ufdbguard_admin_events("Fatal Error: tar {$container} failed", __FUNCTION__, __FILE__, __LINE__, "backup");
@unlink($container);
@unlink("{$container}.tar.gz");
KillMountPoint();
return;
}
$TotalSize = $TotalSize + $size;
@unlink($container);
reset($tablesB);
while (list($tablename, $line) = each($tablesB)) {
if ($GLOBALS["VERBOSE"]) {
echo "Delete table `{$tablename}`\n";
}
if (!$q->DELETE_TABLE($tablename)) {
if ($GLOBALS["VERBOSE"]) {
echo "Delete {$tablename} failed {$q->mysql_error} ...\n";
}
ufdbguard_admin_events("Fatal Error: Delete {$tablename} failed {$q->mysql_error} ", __FUNCTION__, __FILE__, __LINE__, "backup");
KillMountPoint();
return;
}
$DeleteTables++;
}
}
if ($GLOBALS["VERBOSE"]) {
echo "Delete table `{$TableKey}` from tables_day\n";
}
$q->QUERY_SQL("DELETE FROM tables_day WHERE tablename='{$TableKey}'");
}
$container = "{$ArticaProxyStatisticsBackupFolder}/squidlogs.FULL.sql";
$resultsZ = array();
$cmd = "{$mysqldump_prefix} >{$container}";
exec($cmd, $resultsZ);
chdir($ArticaProxyStatisticsBackupFolder);
$cmdline = "{$tar} cfz {$container}.tar.gz {$container} 2>&1";
exec($cmdline);
if (!$unix->TARGZ_TEST_CONTAINER("{$container}.tar.gz")) {
squid_admin_purge(0, "Error {$container}.tar.gz, not a valid compressed file", __FILE__, __LINE__);
ufdbguard_admin_events("Error {$container}.tar.gz, not a valid compressed file", __FUNCTION__, __FILE__, __LINE__, "backup");
@unlink("{$container}.tar.gz");
} else {
$size = @filesize($container);
$TotalSize = $TotalSize + $size;
@unlink("{$container}");
}
if ($DeleteTables > 0) {
$TotalSize = FormatBytes($TotalSize / 1024);
$took = $unix->distanceOfTimeInWords($t, time(), true);
squid_admin_purge(2, "Success backup and purge {$DeleteTables} table(s) ({$TotalSize})", "took:{$took}", __FILE__, __LINE__);
ufdbguard_admin_events("Success backup and purge {$DeleteTables} table(s) ({$TotalSize}) took:{$took}", __FUNCTION__, __FILE__, __LINE__, "backup");
}
CleanQuotas();
KillMountPoint();
}
示例6: artica_updates_scheduled
//.........这里部分代码省略.........
$curl = $meta->buildCurl("/meta-updates/releases/");
if (!$curl->GetFile("{$tmpdir}/releases.txt")) {
events("Fatal: /meta-updates/releases/releases.txt {$curl->errors}", __FUNCTION__, __FILE__, __LINE__);
artica_update_event(0, "Failed Downloading /meta-updates/releases/", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed Downloading /meta-updates/releases/", @implode("\n", $curl->errors), __FILE__, __LINE__);
return false;
}
$data = @file_get_contents("{$tmpdir}/releases.txt");
$f = explode("\n", $data);
@unlink("{$tmpdir}/releases.txt");
while (list($index, $ligne) = each($f)) {
if (!preg_match("#href.*?artica-([0-9\\.]+)\\.tgz#", $ligne, $re)) {
if ($GLOBALS["VERBOSE"]) {
echo "Not Found {$ligne}\n";
}
continue;
}
$verbin = intval(str_replace(".", "", $re[1]));
events("Found : v{$verbin} /meta-updates/releases/artica-{$re[1]}.tgz", __FUNCTION__, __FILE__, __LINE__);
$ARRAY[$verbin] = "/meta-updates/releases/artica-{$re[1]}.tgz";
}
if ($MetaClientAutoUpdate == 1) {
$nightly = "yes";
}
if ($nightly == "yes") {
$curl = $meta->buildCurl("/meta-updates/nightlys/");
if (!$curl->GetFile("{$tmpdir}/nightlys.txt")) {
artica_update_event(0, "Failed Downloading /meta-updates/nightlys/", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed Downloading /meta-updates/nightlys/", @implode("\n", $curl->errors), __FILE__, __LINE__);
} else {
$data = @file_get_contents("{$tmpdir}/nightlys.txt");
$f = explode("\n", $data);
@unlink("{$tmpdir}/nightlys.txt");
while (list($index, $ligne) = each($f)) {
if (!preg_match("#href.*?artica-([0-9\\.]+)\\.tgz#", $ligne, $re)) {
if ($GLOBALS["VERBOSE"]) {
echo "Not Found {$ligne}\n";
}
continue;
}
$verbin = intval(str_replace(".", "", $re[1]));
events("Found : v{$verbin} /meta-updates/nightlys/artica-{$re[1]}.tgz", __FUNCTION__, __FILE__, __LINE__);
$ARRAY[$verbin] = "/meta-updates/nightlys/artica-{$re[1]}.tgz";
}
}
}
krsort($ARRAY);
while (list($index, $ligne) = each($ARRAY)) {
if ($GLOBALS["VERBOSE"]) {
echo "Found v.{$index} / {$ligne}\n";
}
$TA[] = $index;
$TZ[] = $ligne;
}
$LASTVER = $TA[0];
$LASTFILE = $TZ[0];
$MYVERSION_TEXT = trim(@file_get_contents("/usr/share/artica-postfix/VERSION"));
$MYVERSION = intval(str_replace(".", "", $MYVERSION_TEXT));
events("Last version: {$LASTVER} -> {$LASTFILE} against {$MYVERSION}", __FUNCTION__, __FILE__, __LINE__);
if ($MYVERSION > $LASTVER) {
events("Most updated, aborting", __FUNCTION__, __FILE__, __LINE__);
if ($GLOBALS["VERBOSE"]) {
echo "Most updated, aborting\n";
}
return;
}
if ($MYVERSION == $LASTVER) {
events("Most updated, aborting", __FUNCTION__, __FILE__, __LINE__);
if ($GLOBALS["VERBOSE"]) {
echo "Most updated, aborting\n";
}
return;
}
$curl = $meta->buildCurl($LASTFILE);
$tmpfile = "{$tmpdir}/" . basename($LASTFILE);
if (!$curl->GetFile($tmpfile)) {
events("Failed Downloading {$LASTFILE} {$curl->errors}", __FUNCTION__, __FILE__, __LINE__);
artica_update_event(0, "Failed Downloading {$LASTFILE}", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed Downloading {$LASTFILE}", @implode("\n", $curl->errors), __FILE__, __LINE__);
@unlink($tmpfile);
return;
}
if (!$unix->TARGZ_TEST_CONTAINER($tmpfile)) {
artica_update_event(0, "Failed {$tmpfile} corrupted package", @implode("\n", $curl->errors), __FILE__, __LINE__);
meta_admin_mysql(0, "Failed {$tmpfile} corrupted package", @implode("\n", $curl->errors), __FILE__, __LINE__);
@unlink($tmpfile);
return false;
}
if ($GLOBALS["VERBOSE"]) {
echo "Extracting {$tmpfile}\n";
}
$tar = $unix->find_program("tar");
shell_exec("{$tar} xf {$tmpfile} -C /usr/share/");
@unlink($tmpfile);
$MYVERSION_TEXT = trim(@file_get_contents("/usr/share/artica-postfix/VERSION"));
$php = $unix->LOCATE_PHP5_BIN();
shell_exec("{$php} /usr/share/artica-postfix/exec.nightly.php --restart-services >/dev/null 2>&1");
artica_update_event(2, "Success update Artica to {$MYVERSION_TEXT}", null, __FILE__, __LINE__);
meta_admin_mysql(2, "Success update Artica to {$MYVERSION_TEXT}", null, __FILE__, __LINE__);
}
示例7: install_package
function install_package($filename, $expected = null)
{
$unix = new unix();
$sock = new sockets();
$php = $unix->LOCATE_PHP5_BIN();
$nohup = $unix->find_program("nohup");
$rm = $unix->find_program("rm");
$squidbin = $unix->LOCATE_SQUID_BIN();
$RebootAfterArticaUpgrade = $sock->GET_INFO("RebootAfterArticaUpgrade");
if (!is_numeric($RebootAfterArticaUpgrade)) {
$RebootAfterArticaUpgrade = 0;
}
events("Starting......: " . date("H:i:s") . " install_package() Extracting package {$filename}, please wait... ");
echo "Starting......: " . date("H:i:s") . " install_package() Extracting package {$filename}, please wait... \n";
$tarbin = $unix->find_program("tar");
$killall = $unix->find_program("killall");
echo "Starting......: " . date("H:i:s") . " tar: {$tarbin}\n";
echo "Starting......: " . date("H:i:s") . " killall: {$killall}\n";
build_progress_manu("Testing Package", 50);
events("Starting......: " . date("H:i:s") . " install_package() Testing Package");
echo "Starting......: " . date("H:i:s") . " Testing Package " . basename($filename) . "\n";
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
ini_set('error_prepend_string', " WARNING!!:");
ini_set('error_append_string', "\n");
echo "Starting......: " . date("H:i:s") . " Testing Package Please wait....\n";
if (!$unix->TARGZ_TEST_CONTAINER($filename, false, true)) {
echo "Starting......: " . date("H:i:s") . " Testing Package " . basename($filename) . " failed\n";
_artica_update_event(0, "Compressed package seems corrupted", null, __FILE__, __LINE__);
events("Fatal, Compressed package seems corrupted");
events($GLOBALS["TARGZ_TEST_CONTAINER_ERROR"]);
@unlink($filename);
build_progress_manu("Corrupted!", 110);
return false;
}
echo "Starting......: " . date("H:i:s") . " Purge directories\n";
events("Starting......: " . date("H:i:s") . " Purge directories...");
build_progress_manu("Purge directories", 55);
if (is_dir("/usr/share/artica-postfix/ressources/conf/upload")) {
system("{$rm} -f /usr/share/artica-postfix/ressources/conf/upload/*");
}
if (is_dir("/usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded")) {
system("{$rm} -f /usr/share/artica-postfix/ressources/conf/meta/hosts/uploaded/*");
}
events("Starting......: " . date("H:i:s") . " Extracting...");
exec("{$tarbin} xpf {$filename} -C /usr/share/ 2>&1", $results);
if (is_file($squidbin)) {
$squidfiles = $unix->SquidPHPFiles();
while (list($fileSquid, $None123) = each($squidfiles)) {
@chgrp("/usr/share/artica-postfix/{$fileSquid}", "squid");
@chown("/usr/share/artica-postfix/{$fileSquid}", "squid");
@chmod("/usr/share/artica-postfix/{$fileSquid}", 0755);
}
}
if (is_file("{$killall}")) {
shell_exec("{$killall} artica-install >/dev/null 2>&1");
}
@unlink($filename);
shell_exec("{$nohup} {$php} " . dirname(__FILE__) . "/exec.checkfolder-permissions.php --force >/dev/null 2>&1 &");
$MyCurrentVersion = GetCurrentVersionString();
if ($expected != null) {
if ($MyCurrentVersion != $expected) {
_artica_update_event(1, "install_package(): Expected version:{$expected} does not match {$MyCurrentVersion}", $results, __FILE__, __LINE__);
return;
}
}
_artica_update_event(2, "install_package(): Success updating to a new version v{$MyCurrentVersion}", $results, __FILE__, __LINE__);
if ($RebootAfterArticaUpgrade == 1) {
build_progress_manu("{rebooting}", 90);
_artica_update_event(1, "install_package() Reboot the server in 10s...", null, __FILE__, __LINE__);
events("Reboot the server in 10s...");
system_admin_events("Warning: Reboot the server in 10s...", __FUNCTION__, __FILE__, __LINE__, "artica-update");
$shutdown = $unix->find_program("shutdown");
shell_exec("shutdown -r -t 10");
sleep(5);
build_progress_manu("{done}", 100);
return true;
}
_artica_update_event(2, "install_package(): restart dedicated services...", null, __FILE__, __LINE__);
system_admin_events("Warning: Restart Artica dedicated services after an upgrade...", __FUNCTION__, __FILE__, __LINE__, "artica-update");
system("{$php} " . __FILE__ . " --restart-services");
_artica_update_event(2, "install_package(): finish", null, __FILE__, __LINE__);
build_progress_manu("{done}", 100);
return true;
}