Current File : /home/inlingua/public_html/decay_sym/root/var/softaculous/apps/apache2/3/update.php |
<?php
function __apache2_pre_update(){
global $W, $iapps, $error, $default_web_server, $globals;
// Create a directory to hold all the conf files
if(!file_exists($globals['var_tmp'].'/apache2_confs_backup')){
mkdir($globals['var_tmp'].'/apache2_confs_backup', 0750, 1);
}
// Create a directory to hold all the /var/webuzo/conf/apache2 files
if(!file_exists($globals['var_tmp'].'/apache2_var_confs_backup')){
mkdir($globals['var_tmp'].'/apache2_var_confs_backup', 0750, 1);
}
if(file_exists(APACHE2_APP.'www/suspended/index.html')){
mkdir($globals['var_tmp'].'/apache2_suspended_template', 0750, 1);
}
// Some globals settings we need to save before update
$data = [];
if(!empty($globals['VARNISH_PORT'])){
$data['WU_PROXY_PORT'] = $globals['WU_PROXY_PORT'];
$data['WU_PROXY_SERVER'] = $globals['WU_PROXY_SERVER'];
$data['VARNISH_PORT'] = $globals['VARNISH_PORT'];
$data['NO_FASTCGI'] = $globals['NO_FASTCGI'];
// Save settings in /usr/local/webuzo/tmp/apache2_varnish_settings
writedata($globals['var_tmp'].'/apache2_varnish_settings', $data);
}
// Copy the actual conf files to new location
vexec('cp -r '.APACHE2_CONFD.'* '.$globals['var_tmp'].'/apache2_confs_backup/');
vexec('cp -r '.APACHE2_APP.'www/suspended/* '.$globals['var_tmp'].'/apache2_suspended_template/');
if(is_dir($globals['var_conf'].'/apache2')){
vexec('cp -r '.$globals['var_conf'].'/apache2/* '.$globals['var_tmp'].'/apache2_var_confs_backup/');
}
}
function __apache2_post_update(){
global $W, $iapps, $error, $default_web_server, $globals;
// Check for default php
$distro = $globals['WU_DISTRO'];
if($distro != 'ubuntu'){
@symlink('/usr/local/apps/lib/libssl.so.1.1', '/usr/lib64/libssl.so.1.1');
@symlink('/usr/local/apps/lib/libcrypto.so.1.1', '/usr/lib64/libcrypto.so.1.1');
}
if(file_exists($globals['var_tmp'].'/apache2_confs_backup')){
// Copy the conf file to actual location
vexec('yes | cp -r '.$globals['var_tmp'].'/apache2_confs_backup/* '.APACHE2_CONFD);
}
if(file_exists($globals['var_tmp'].'/apache2_var_confs_backup')){
// Copy the /var/webuzo/conf/apache2 file to actual location
vexec('yes | cp -r '.$globals['var_tmp'].'/apache2_var_confs_backup/* '.$globals['var_conf'].'/apache2/');
vexec('chown -R webuzo:webuzo '.$globals['var_conf'].'/apache2/');
sleep(2);
}
// Restore suspended templates
if(file_exists($globals['var_tmp'].'/apache2_suspended_template')){
vexec('yes | cp -r '.$globals['var_tmp'].'/apache2_suspended_template/* '.APACHE2_APP.'www/suspended/');
}
// Varnish settings
$old_varnish_settings = [];
if(file_exists($globals['var_tmp'].'/apache2_varnish_settings')){
$old_varnish_settings = loaddata($globals['var_tmp'].'/apache2_varnish_settings');
saveglobals($old_varnish_settings, 1);
task_log_echo('Varnish Enabled');
}
//Rebuild ModSec
apache2_modsec_rebuild();
// Delete the directory once the files are copied
vexec('rm -rf '.$globals['var_tmp'].'/apache2_confs_backup');
vexec('rm -rf '.$globals['var_tmp'].'/apache2_var_confs_backup');
vexec('rm -rf '.$globals['var_tmp'].'/apache2_varnish_settings');
apache2_vh_rebuild();
// If varnish enabled then restart
if(!empty($globals['VARNISH_PORT'])){
// Kill the process running on 80
kill_by_port(80);
vexec('systemctl restart varnish.service');
}
//we need to call this since apache2_conf_rebuild won't be called in installer during update
apache2_conf_rebuild();
}