Commit 4b88c2b9 authored by wyrie's avatar wyrie
Browse files

Server: Gentoo updates

- Changed os updates from world to security advisories
- Added support for remote os update
- Added bind compatibility code
- Fixed bugs in cron compatibility
parent d090dbfe
......@@ -921,20 +921,17 @@ class monitor_core_module {
* Then test the upgrade.
* if there is any output, then there is a needed update
*/
$emergeData = shell_exec('emerge -puDNt --color n --nospinner --quiet world');
$emergeData = shell_exec('glsa-check -t affected');
if ($emergeData == '') {
/* There is nothing to update! */
$state = 'ok';
$data['output'] = 'No unapplied GLSA\'s found on the system.';
}
else {
/* There is something to update! */
$state = 'warning';
$state = 'info';
$data['output'] = shell_exec('glsa-check -pv --nocolor affected 2>/dev/null');
}
/*
* Fetch the output
*/
$data['output'] = shell_exec('emerge -pvuDNt --color n --nospinner world');
}
else {
/*
......
......@@ -27,7 +27,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class remoteaction_core_module {
class remoteaction_core_module extends modules_base {
var $module_name = 'remoteaction_core_module';
var $class_name = 'remoteaction_core_module';
/* No actions at this time. maybe later... */
......@@ -132,9 +132,15 @@ class remoteaction_core_module {
/*
* Do the update
*/
exec("aptitude update");
exec("aptitude upgrade -y");
//TODO : change this when distribution information has been integrated into server record
if(file_exists('/etc/gentoo-release')) {
exec("glsa-check -f --nocolor affected");
}
else {
exec("aptitude update");
exec("aptitude upgrade -y");
}
/*
* All well done!
*/
......
......@@ -105,8 +105,14 @@ class bind_plugin {
$records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'");
$tpl->setLoop('zones',$records);
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
//TODO : change this when distribution information has been integrated into server record
if (file_exists('/etc/gentoo-release')) {
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri/'.substr($zone['origin'],0,-1));
}
else {
$filename = escapeshellcmd($dns_config['bind_zonefiles_dir'].'/pri.'.substr($zone['origin'],0,-1));
}
$app->log("Writing BIND domain file: ".$filename,LOGLEVEL_DEBUG);
file_put_contents($filename,$tpl->grab());
chown($filename, escapeshellcmd($dns_config['bind_user']));
......@@ -124,7 +130,14 @@ class bind_plugin {
//* Delete old domain file, if domain name has been changed
if($data['old']['origin'] != $data['new']['origin']) {
$filename = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
//TODO : change this when distribution information has been integrated into server record
if (file_exists('/etc/gentoo-release')) {
$filename = $dns_config['bind_zonefiles_dir'].'/pri/'.substr($data['old']['origin'],0,-1);
}
else {
$filename = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
}
if(is_file($filename)) unset($filename);
}
......@@ -144,7 +157,14 @@ class bind_plugin {
$this->write_named_conf($data,$dns_config);
//* Delete the domain file
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
//TODO : change this when distribution information has been integrated into server record
if (file_exists('/etc/gentoo-release')) {
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri/'.substr($data['old']['origin'],0,-1);
}
else {
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/pri.'.substr($data['old']['origin'],0,-1);
}
if(is_file($zone_file_name)) unlink($zone_file_name);
$app->log("Deleting BIND domain file: ".$zone_file_name,LOGLEVEL_DEBUG);
......@@ -177,7 +197,14 @@ class bind_plugin {
//* Delete old domain file, if domain name has been changed
if($data['old']['origin'] != $data['new']['origin']) {
$filename = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
//TODO : change this when distribution information has been integrated into server record
if (file_exists('/etc/gentoo-release')) {
$filename = $dns_config['bind_zonefiles_dir'].'/sec/'.substr($data['old']['origin'],0,-1);
}
else {
$filename = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
}
if(is_file($filename)) unset($filename);
}
......@@ -198,7 +225,14 @@ class bind_plugin {
$this->write_named_conf($data,$dns_config);
//* Delete the domain file
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
//TODO : change this when distribution information has been integrated into server record
if (file_exists('/etc/gentoo-release')) {
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/sec/'.substr($data['old']['origin'],0,-1);
}
else {
$zone_file_name = $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($data['old']['origin'],0,-1);
}
if(is_file($zone_file_name)) unlink($zone_file_name);
$app->log("Deleting BIND domain file for secondary zone: ".$zone_file_name,LOGLEVEL_DEBUG);
......@@ -260,6 +294,17 @@ class bind_plugin {
} else {
$exclude_zone = '';
}
//TODO : change this when distribution information has been integrated into server record
if (file_exists('/etc/gentoo-release')) {
$pri_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/pri/';
$sec_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/sec/';
}
else {
$pri_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/pri.';
$sec_zonefiles_path = $dns_config['bind_zonefiles_dir'].'/slave/sec.';
}
//* Loop trough zones
foreach($tmps as $tmp) {
......@@ -274,7 +319,7 @@ class bind_plugin {
if($tmp['origin'] != $exclude_zone) {
$zones[] = array( 'zone' => substr($tmp['origin'],0,-1),
'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/pri.'.substr($tmp['origin'],0,-1),
'zonefile_path' => $pri_zonefiles_path.substr($tmp['origin'],0,-1),
'options' => $options
);
}
......@@ -299,7 +344,7 @@ class bind_plugin {
$zones_sec[] = array( 'zone' => substr($tmp['origin'],0,-1),
'zonefile_path' => $dns_config['bind_zonefiles_dir'].'/slave/sec.'.substr($tmp['origin'],0,-1),
'zonefile_path' => $sec_zonefiles_path.substr($tmp['origin'],0,-1),
'options' => $options
);
......
......@@ -133,6 +133,14 @@ class cron_plugin {
exec("setquota -T -u $username 604800 604800 -a &> /dev/null");
}
//TODO : change this when distribution information has been integrated into server record
//* Gentoo requires a user to be part of the crontab group.
if (file_exists('/etc/gentoo-release')) {
if (strpos($app->system->get_user_groups($username), 'crontab') === false) {
$app->system->add_user_to_group('crontab', $username);
}
}
// make temp directory writable for the apache and website users
chmod(escapeshellcmd($parent_domain["document_root"].'/tmp'), 0777);
......@@ -214,6 +222,12 @@ class cron_plugin {
}
$cron_file = escapeshellcmd($cron_config["crontab_dir"].'/ispc_'.$this->parent_domain["system_user"]);
//TODO : change this when distribution information has been integrated into server record
//* Gentoo vixie-cron requires files to end with .cron in the cron.d directory
if (file_exists('/etc/gentoo-release')) {
$cron_file .= '.cron';
}
if($cmd_count > 0) {
file_put_contents($cron_file, $cron_content);
$app->log("Wrote Cron file $cron_file with content:\n$cron_content",LOGLEVEL_DEBUG);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment