install/lib/installer_base.lib.php | ●●●●● patch | view | raw | blame | history | |
install/sql/ispconfig3.sql | ●●●●● patch | view | raw | blame | history | |
interface/web/admin/software_package_list.php | ●●●●● patch | view | raw | blame | history | |
server/plugins-available/apps_vhost_plugin.inc.php | ●●●●● patch | view | raw | blame | history | |
server/plugins-available/software_update_plugin.inc.php | ●●●●● patch | view | raw | blame | history |
install/lib/installer_base.lib.php
@@ -1076,9 +1076,9 @@ //* Create the ispconfig apps vhost user and group $apps_vhost_user = $conf['web']['apps_vhost_user']; $apps_vhost_group = $conf['web']['apps_vhost_group']; $install_dir = $conf['web']['website_basedir'].'/apps'; $apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']); $apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']); $install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps'); $command = 'groupadd '.$apps_vhost_user; if(!is_group($apps_vhost_group)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); @@ -1090,7 +1090,8 @@ $command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group; caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); exec('mkdir -p '.escapeshellcmd($conf['web']['website_basedir'].'/apps')); exec('mkdir -p '.$install_dir); exec("chown $apps_vhost_user:$apps_vhost_group $install_dir"); //* Copy the apps vhost file $vhost_conf_dir = $conf['apache']['vhost_conf_dir']; install/sql/ispconfig3.sql
@@ -699,6 +699,7 @@ `package_title` varchar(64) NOT NULL, `package_description` text, `package_version` varchar(8) default NULL, `package_type` enum('ispconfig','app','web') NOT NULL default 'app', PRIMARY KEY (`package_id`), UNIQUE KEY `package_name` (`package_name`) ) ENGINE=MyISAM AUTO_INCREMENT=1; @@ -757,7 +758,7 @@ `software_update_id` int(11) unsigned NOT NULL default '0', `package_name` varchar(64) NOT NULL, `server_id` int(11) unsigned NOT NULL, `status` enum('none','installing','installed','deleting','deleted') NOT NULL default 'none', `status` enum('none','installing','installed','deleting','deleted','failed') NOT NULL default 'none', PRIMARY KEY (`software_update_inst_id`), UNIQUE KEY `software_update_id` (`software_update_id`,`package_name`,`server_id`) ) ENGINE=MyISAM AUTO_INCREMENT=1; interface/web/admin/software_package_list.php
@@ -55,8 +55,9 @@ $package_title = $app->db->quote($p['title']); $package_description = $app->db->quote($p['description']); $software_repo_id = intval($repo['software_repo_id']); $package_type = $app->db->quote($p['type']); $sql = "INSERT INTO software_package (software_repo_id, package_name, package_title, package_description) VALUES ($software_repo_id, '$package_name', '$package_title', '$package_description')"; $sql = "INSERT INTO software_package (software_repo_id, package_name, package_title, package_description,package_type) VALUES ($software_repo_id, '$package_name', '$package_title', '$package_description','$package_type')"; $app->db->query($sql); $packages_added++; } server/plugins-available/apps_vhost_plugin.inc.php
@@ -82,6 +82,9 @@ $vhost_conf_enabled_dir = $web_config['vhost_conf_enabled_dir']; $apps_vhost_servername = ($web_config['apps_vhost_servername'] == '')?'':'ServerName '.$web_config['apps_vhost_servername']; $web_config['apps_vhost_port'] = (empty($web_config['apps_vhost_port']))?8081:$web_config['apps_vhost_port']; $web_config['apps_vhost_ip'] = (empty($web_config['apps_vhost_ip']))?'_default_':$web_config['apps_vhost_ip']; $content = str_replace('{apps_vhost_ip}', $web_config['apps_vhost_ip'], $content); $content = str_replace('{apps_vhost_port}', $web_config['apps_vhost_port'], $content); $content = str_replace('{apps_vhost_dir}', $web_config['website_basedir'].'/apps', $content); server/plugins-available/software_update_plugin.inc.php
@@ -72,26 +72,45 @@ function process($event_name,$data) { global $app, $conf; if(!$conf['software_updates_enabled'] == true) { $app->log('Software Updates not enabled on this server. To enable updates, set $conf["software_updates_enabled"] = true; in config.inc.php',LOGLEVEL_ERROR); //* Get the info of the package: $software_update_id = intval($data["new"]["software_update_id"]); $software_update = $app->db->queryOneRecord("SELECT * FROM software_update WHERE software_update_id = '$software_update_id'"); $software_package = $app->db->queryOneRecord("SELECT * FROM software_package WHERE package_name = '".$app->db->quote($software_update['package_name'])."'"); if($software_package['package_type'] == 'ispconfig' && !$conf['software_updates_enabled'] == true) { $app->log('Software Updates not enabled on this server. To enable updates, set $conf["software_updates_enabled"] = true; in config.inc.php',LOGLEVEL_WARN); $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); return false; } //* Get the info of the package: $software_update_id = intval($data["new"]["software_update_id"]); $software_update = $app->db->queryOneRecord("SELECT * FROM software_update WHERE software_update_id = '$software_update_id'"); $installuser = ''; if($software_package['package_type'] == 'ispconfig') { $installuser = ''; } elseif ($software_package['package_type'] == 'app') { $installuser = 'ispapps'; } else { $app->log('package_type not supported',LOGLEVEL_WARN); $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); return false; } $temp_dir = '/tmp/'.md5 (uniqid (rand())); $app->log("The temp dir is $temp_dir",LOGLEVEL_DEBUG); mkdir($temp_dir); if($installuser != '') exec('chown '.$installuser.' '.$temp_dir); if(!is_dir($temp_dir)) { $app->log("Unable to create temp directory.",LOGLEVEL_ERROR); $app->log("Unable to create temp directory.",LOGLEVEL_WARN); $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); return false; } exec("cd $temp_dir && wget ".$software_update["update_url"]); $cmd = "cd $temp_dir && wget ".$software_update["update_url"]; if($installuser == '') { exec($cmd); } else { exec("su -c ".escapeshellarg($cmd)." $installuser"); } $app->log("Downloading the update file from: ".$software_update["update_url"],LOGLEVEL_DEBUG); $url_parts = parse_url($software_update["update_url"]); @@ -102,7 +121,7 @@ //* Checking the md5sum if(md5_file($temp_dir.'/'.$update_filename) != $software_update["update_md5"]) { $app->log("The md5 sum of the downloaded file is incorrect. Update aborted.",LOGLEVEL_ERROR); $app->log("The md5 sum of the downloaded file is incorrect. Update aborted.",LOGLEVEL_WARN); exec("rm -rf $temp_dir"); $app->log("Deleting the temp directory $temp_dir",LOGLEVEL_DEBUG); $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); @@ -113,13 +132,23 @@ //* unpacking the update exec("cd $temp_dir && unzip $update_filename"); $cmd = "cd $temp_dir && unzip $update_filename"; if($installuser == '') { exec($cmd); } else { exec("su -c ".escapeshellarg($cmd)." $installuser"); } if(is_file($temp_dir.'/setup.sh')) { // Execute the setup script exec('chmod +x '.$temp_dir.'/setup.sh'); $app->log("Executing setup.sh file in directory $temp_dir",LOGLEVEL_DEBUG); exec('cd '.$temp_dir.' && ./setup.sh > package_install.log'); $cmd = 'cd '.$temp_dir.' && ./setup.sh > package_install.log'; if($installuser == '') { exec($cmd); } else { exec("su -c ".escapeshellarg($cmd)." $installuser"); } $log_data = @file_get_contents("{$temp_dir}/package_install.log"); if(preg_match("'.*\[OK\]\s*$'is", $log_data)) { @@ -127,7 +156,7 @@ $app->log($log_data,LOGLEVEL_DEBUG); $this->set_install_status($data["new"]["software_update_inst_id"], "installed"); } else { $app->log("Installation failed:\n\n" . $log_data,LOGLEVEL_ERROR); $app->log("Installation failed:\n\n" . $log_data,LOGLEVEL_WARN); $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); } } else { @@ -135,7 +164,7 @@ $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); } } else { $app->log("Download of the update file failed",LOGLEVEL_ERROR); $app->log("Download of the update file failed",LOGLEVEL_WARN); $this->set_install_status($data["new"]["software_update_inst_id"], "failed"); }