Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

how to upgrade cms ms


define('CUSTOMER_FOLDER', '/var/www/vhosts/');
define('WEB_FOLDER', 'httpdocs/websitedesign');
if (PHP_SAPI != "cli") exit;
if ($argc != 2){
    echo 'this command needs 1 argument'."\n";
    exit;
}
if (!file_exists(CUSTOMER_FOLDER.$argv[1].'/'.WEB_FOLDER.'/version.php')){
    echo CUSTOMER_FOLDER.$argv[1].'/'.WEB_FOLDER.'/version.php'."\n";
    echo 'Check the folder name'."\n";
    exit;
}
$sitename = $argv[1];
$path = CUSTOMER_FOLDER.$sitename.'/';
$owner = 'thehost5';
$group = 'psacln';
chdir('/var/www/vhosts/'.$sitename.'/');
if (!file_exists($path.'backup')){
    mkdir($path.'backup');
} else {
    echo 'backup folder exists'."\n";
}
exec('tar cvzf backup/'.WEB_FOLDER.'.tar.gz '.WEB_FOLDER);
include($path.WEB_FOLDER.'/config.php');
exec('mysqldump -u '.$config['db_username'].' -p'.$config['db_password'].' '.$config['db_name'].' > backup/db.sql');
exec('tar cvzf backup/db.tar.gz backup/db.sql');
unlink($path.'backup/db.sql');
chdir(WEB_FOLDER);
exec('tar xvzf /root/CMS.1-9-4-2.tar.gz');
exec('chown -R '.$owner['name'].'.'.$group['name'].' *');
exec('chown -R '.$owner['name'].'.'.$group['name'].' ../backup');
exec('chmod -R 777 tmp config.php');
exec('chmod -R 777 uploads/ modules/');
Advertisements

Comments are closed.

%d bloggers like this: