public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->exec('/usr/bin/sudo /usr/bin/yum clean all');
     }
 }
Exemplo n.º 2
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->signalEvent('nethserver-squidguard-downloadlists &');
     }
 }
Exemplo n.º 3
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         if ($this->parameters['Action'] === 'poweroff') {
             $cmd = '/sbin/poweroff';
         } else {
             $cmd = '/sbin/reboot';
         }
         $this->process = $this->getPlatform()->exec('/usr/bin/sudo ${1}', array($cmd));
         sleep(1);
     } elseif ($this->getRequest()->hasParameter('wait')) {
         // parse /sbin/runlevel output to get the current runlevel value:
         $this->process = $this->getPlatform()->exec('/sbin/runlevel');
         $runlevel = \Nethgui\array_end(explode(' ', $this->process->getOutput()));
         NETHGUI_DEBUG && $this->getLog()->notice('RUNLEVEL ' . $runlevel . ' ' . join(', ', $this->getRequest()->getParameterNames()));
         // runlevel validation:
         if ($runlevel === '0' || $runlevel === '6') {
             NETHGUI_DEBUG && $this->getLog()->notice('Sleeping 10 seconds..');
             sleep(10);
         } else {
             // wait argument is allowed only on reboot and halt runlevels!
             sleep(2);
             throw new \Nethgui\Exception\HttpException('Forbidden', 403, 1355301177);
         }
     }
 }
Exemplo n.º 4
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->exec('/usr/bin/sudo /usr/libexec/nethserver/pkgaction --update \\*', array(), TRUE);
     }
 }
Exemplo n.º 5
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->getDatabase('configuration')->setProp('nsdc', array('status' => 'enabled'));
         $this->getPlatform()->signalEvent('nethserver-dc-save &');
     }
 }
Exemplo n.º 6
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->hasParameter('Clear_cache')) {
         // Signal nethserver-squid-clear-cache
         $this->getPlatform()->signalEvent('nethserver-squid-clear-cache &');
     }
 }
Exemplo n.º 7
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         // Signal nethserver-duc-save event
         $this->getPlatform()->signalEvent('nethserver-duc-save &');
     }
 }
 public function process()
 {
     parent::process();
     if (!$this->getRequest()->isMutation()) {
         return;
     } else {
         $this->getPlatform()->exec('/usr/bin/sudo /sbin/e-smith/backup-config');
     }
 }
Exemplo n.º 9
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->hasParameter('skip')) {
         $sessDb = $this->getPlatform()->getDatabase('SESSION');
         $sessDb->deleteKey(get_class($this->getParent()));
         $sessDb->setType(get_class($this->getParent()), array());
     }
 }
Exemplo n.º 10
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         if ($this->parameters['Action'] === 'poweroff') {
             $this->getPlatform()->signalEvent('system-shutdown@post-response', array('poweroff'));
         } else {
             $this->getPlatform()->signalEvent('system-shutdown@post-response', array('reboot'));
         }
     }
 }
Exemplo n.º 11
0
 public function process()
 {
     parent::process();
     if (!$this->getRequest()->isMutation()) {
         return;
     }
     /*Launch LetsEncrypt helper command*/
     $p = $this->getPlatform()->exec("/usr/bin/sudo /usr/libexec/nethserver/letsencrypt-certs -f");
     $this->exitCode = $p->getExitCode();
     $this->output = $p->getOutput(true);
     $this->getPlatform()->signalEvent('certificate-update &');
 }
Exemplo n.º 12
0
 public function process()
 {
     parent::process();
     if (!$this->getRequest()->isMutation()) {
         return;
     }
     $domain = \Nethgui\array_end(\explode('.', \gethostname(), 2));
     $ph = popen('/usr/bin/sudo /usr/sbin/realm join ' . $domain, 'w');
     fwrite($ph, $this->parameters['password'] . "\n");
     $err = pclose($ph);
     if ($err === 0) {
         $this->getPlatform()->getDatabase('configuration')->setProp('sssd', array('status' => 'enabled'));
         $this->getPlatform()->signalEvent('nethserver-sssd-save');
     } else {
         $this->joinError = TRUE;
         $this->getLog()->error("[ERROR] exit code from realm join operation is {$err}");
     }
 }
Exemplo n.º 13
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $args = array();
         $installComponents = is_array($this->parameters['components']) ? $this->parameters['components'] : array();
         $removeComponents = array_diff($this->getAvailableComponents(), $installComponents);
         if (count($installComponents) > 0) {
             $args[] = '--install';
             $args[] = implode(',', $installComponents);
         }
         if (count($removeComponents) > 0) {
             $args[] = '--remove';
             $args[] = implode(',', $removeComponents);
         }
         if (count($args) > 0) {
             $this->getPlatform()->exec('/usr/bin/sudo /usr/libexec/nethserver/pkgaction ${@}', $args, TRUE);
         }
     }
 }
Exemplo n.º 14
0
 public function process()
 {
     parent::process();
     if (!$this->getRequest()->isMutation()) {
         return;
     }
     $changes = 0;
     $db = $this->getPlatform()->getDatabase('networks');
     foreach ($this->getRequest()->getParameter('interfaces') as $key => $vals) {
         $cur = $db->getProp($key, 'FwObjectNat');
         if ($cur === $vals['FwObjectNat']) {
             continue;
         }
         $db->setProp($key, array('FwObjectNat' => $vals['FwObjectNat']));
         $changes++;
     }
     if ($changes) {
         $this->getPlatform()->signalEvent('nethserver-firewall-base-save');
     }
 }
Exemplo n.º 15
0
 public function process()
 {
     parent::process();
     if (!$this->getRequest()->isMutation()) {
         return;
     }
     $ndb = $this->getPlatform()->getDatabase('networks');
     $modified = FALSE;
     foreach ($this->parameters['cards'] as $name => $setting) {
         if (isset($setting['interface']) && $setting['interface'] !== '') {
             $ndb->setProp($setting['interface'], array('hwaddr' => $setting['hwaddr']));
             if ($name !== $setting['interface']) {
                 $ndb->deleteKey($name);
             }
             $modified = TRUE;
         }
     }
     if ($modified) {
         $this->getPlatform()->signalEvent('interface-update &');
     }
 }
Exemplo n.º 16
0
 public function process()
 {
     parent::process();
     $this->provider = $this->getPlatform()->getDatabase('configuration')->getProp('sssd', 'Provider');
     if ($this->getRequest()->isValidated()) {
         if ($this->provider === 'ad') {
             $workgroup = trim($this->getPlatform()->exec('testparm -s -d 0 --parameter-name=workgroup 2>/dev/null')->getOutput());
             $this->details .= "NetBIOS domain name: {$workgroup}\n";
             $this->details .= $this->getPlatform()->exec('/usr/bin/sudo /usr/bin/net ads info 2>&1')->getOutput() . "\n\n";
             $this->details .= $this->getPlatform()->exec('/usr/bin/sudo /usr/bin/net ads testjoin 2>&1')->getOutput() . "\n";
             $netbiosname = substr($this->getPlatform()->getDatabase('configuration')->getType('SystemName'), 0, 15) . '$';
             $searchCmd = $this->getPlatform()->exec("/usr/bin/sudo net ads search -P '(&(sAMAccountName={$netbiosname})(objectCategory=computer))' name sAMAccountName distinguishedName servicePrincipalName objectSid dNSHostName pwdLastSet lastLogon whenCreated whenChanged accountExpires 2>&1");
             if ($searchCmd->getExitCode() === 0) {
                 $this->details .= implode("\n", array_slice($searchCmd->getOutputArray(), 3));
             } else {
                 $this->details .= $searchCmd->getOutput();
             }
         } elseif ($this->provider === 'ldap') {
             $this->details = 'LDAP URI: ' . $this->getPlatform()->getDatabase('configuration')->getProp('sssd', 'LdapURI');
         }
     }
 }
Exemplo n.º 17
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $tempname = $this->getPhpWrapper()->tempnam(FALSE, 'ng-');
         $fh = $this->getPhpWrapper()->fopen($tempname, 'w');
         if ($fh === FALSE) {
             throw new \Nethgui\Exception\HttpException(sprintf("%s: could not open a temporary file", __CLASS__), 500, 1420718703);
         }
         $steps = $this->getPlatform()->getDatabase('SESSION')->getType(get_class($this->getParent()));
         foreach ($steps as $job) {
             $this->getPhpWrapper()->fwrite($fh, implode("\n", $job['events']) . "\n");
         }
         $this->getPhpWrapper()->fclose($fh);
         $this->getPlatform()->exec('/usr/bin/sudo -n /usr/libexec/nethserver/sigev-batch ${@}', array($tempname), TRUE);
         $confDb = $this->getPlatform()->getDatabase('configuration');
         // Disable the forced redirection to FirstConfigWiz:
         if ($confDb->getProp('httpd-admin', 'ForcedLoginModule')) {
             $confDb->setProp('httpd-admin', array('ForcedLoginModule' => ''));
         }
         //$this->session->logout();
     }
 }
Exemplo n.º 18
0
 public function process()
 {
     $this->output = $this->getPlatform()->exec('/usr/bin/sudo /usr/libexec/nethserver/shorewall-check')->getOutput();
     parent::process();
 }
Exemplo n.º 19
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         $this->getPlatform()->signalEvent('certificate-update &');
     }
 }
Exemplo n.º 20
0
 public function process()
 {
     parent::process();
     if ($this->getRequest()->isMutation()) {
         foreach ($this->getDataSource() as $record) {
             $record->save();
         }
         $changes = $this->tableAdapter->save();
         if ($changes) {
             $this->getPlatform()->signalEvent('nethserver-dnsmasq-save');
         }
     }
 }
 public function process()
 {
     if ($this->getRequest()->isMutation() && $this->getRequest()->hasParameter('Submit')) {
         parent::process();
     }
 }