extension.php

This commit is contained in:
yuri
2015-08-10 15:37:32 +03:00
parent 3c70f28dc0
commit 8d79524c62
2 changed files with 65 additions and 11 deletions
+12 -11
View File
@@ -8,23 +8,23 @@ if (substr($sapiName, 0, 3) != 'cli') {
include "bootstrap.php";
$packageName = isset($_SERVER['argv'][1]) ? trim($_SERVER['argv'][1]) : '';
$arg = isset($_SERVER['argv'][1]) ? trim($_SERVER['argv'][1]) : '';
if ($packageName == 'version' || $packageName == '-v') {
if ($arg == 'version' || $arg == '-v') {
$app = new \Espo\Core\Application();
die("Current version is " . $app->getContainer()->get('config')->get('version') . ".\n");
}
if (empty($packageName)) {
die("Please specify an upgraded package.\n");
if (empty($arg)) {
die("Specify an upgrade package file.\n");
}
if (!file_exists($packageName)) {
die("Package does not exist. Please check the file path.\n");
if (!file_exists($arg)) {
die("Package file does not exist.\n");
}
$pathInfo = pathinfo($packageName);
if (!isset($pathInfo['extension']) || $pathInfo['extension'] != 'zip' || !is_file($packageName)) {
$pathInfo = pathinfo($arg);
if (!isset($pathInfo['extension']) || $pathInfo['extension'] !== 'zip' || !is_file($arg)) {
die("Unsupported package.\n");
}
@@ -38,10 +38,11 @@ $app->getContainer()->setUser($user);
$upgradeManager = new \Espo\Core\UpgradeManager($app->getContainer());
echo "Start upgrade process. Current version is " . $config->get('version') . "\n";
echo "Current version is " . $config->get('version') . "\n";
echo "Start upgrade process...\n";
try {
$fileData = file_get_contents($packageName);
$fileData = file_get_contents($arg);
$fileData = 'data:application/zip;base64,' . base64_encode($fileData);
$upgradeId = $upgradeManager->upload($fileData);
@@ -55,4 +56,4 @@ try {
$app->runRebuild();
} catch (\Exception $e) {}
echo "Upgrade is complete. New version is " . $config->get('version') . ". \n";
echo "Upgrade is completed. New version is " . $config->get('version') . ". \n";