예제 #1
0
 /**
  * Handles DaemonSystem requests
  *
  * @param string $Input
  * @return mixed
  */
 public static function Start($Input)
 {
     System_Daemon::debug('Starting "DaemonSystem::Start" subprocess.');
     $data = explode(" ", $Input);
     switch ($data[0]) {
         case 'cron':
             System_Daemon::debug('Starting "cron" subprocess.');
             $retVal = self::handleCronjobsForAllUsers();
             if ($retVal !== true) {
                 System_Daemon::warning('Failed to handle Cronjobs');
                 System_Daemon::debug('Finished "cron" subprocess.');
                 return false;
             }
             System_Daemon::debug('Finished "cron" subprocess.');
             break;
         case 'direxists':
             System_Daemon::debug('Starting "direxists" subprocess.');
             if (is_dir($data[1])) {
                 System_Daemon::debug('Directory ' . $data[1] . ' exists');
                 System_Daemon::debug('Finished "direxists" subprocess.');
                 return true;
             } else {
                 System_Daemon::debug('Directory ' . $data[1] . ' does not exist');
                 System_Daemon::debug('Finished "direxists" subprocess.');
                 return false;
             }
             break;
         case 'fileexists':
             System_Daemon::debug('Starting "fileexists" subprocess.');
             if (is_file($data[1])) {
                 System_Daemon::debug('File ' . $data[1] . ' exists');
                 System_Daemon::debug('Finished "fileexists" subprocess.');
                 return true;
             } else {
                 System_Daemon::debug('File ' . $data[1] . ' does not exist');
                 System_Daemon::debug('Finished "fileexists" subprocess.');
                 return false;
             }
             break;
         case 'isexecutable':
             System_Daemon::debug('Starting "isexecutable" subprocess.');
             $internalCMD = explode(',', DaemonConfig::$cmd->SHELL_INTERNAL_CMDS);
             System_Daemon::debug(DaemonConfig::$cmd->SHELL_INTERNAL_CMDS);
             if (in_array($data[1], $internalCMD)) {
                 System_Daemon::debug('Command ' . $data[1] . ' is an internal command');
                 System_Daemon::debug('Finished "isexecutable" subprocess.');
                 return true;
             }
             if (self::Start('fileexists ' . $data[1])) {
                 if (is_executable($data[1])) {
                     System_Daemon::debug('File ' . $data[1] . ' is executable');
                     System_Daemon::debug('Finished "isexecutable" subprocess.');
                     return true;
                 } else {
                     System_Daemon::debug('File ' . $data[1] . ' is not executable');
                     System_Daemon::debug('Finished "isexecutable" subprocess.');
                     return false;
                 }
             } else {
                 System_Daemon::debug('Finished "isexecutable" subprocess.');
                 return false;
             }
             break;
         case 'rebuildConfig':
             System_Daemon::debug('Starting "rebuildConfig" subprocess.');
             $rebuildConfig = DaemonConfigCommon::rebuildConfig($data[1]);
             if ($rebuildConfig !== true) {
                 return $rebuildConfig;
             }
             System_Daemon::debug('Finished "rebuildConfig" subprocess.');
             break;
         case 'setPermissions':
             System_Daemon::debug('Starting "setPermissions" subprocess.');
             DaemonCommon::systemSetSystemPermissions();
             DaemonCommon::systemSetGUIPermissions();
             System_Daemon::debug('Finished "setPermissions" subprocess.');
             break;
         case 'updateIana':
             System_Daemon::debug('Starting "updateIana" subprocess.');
             self::updateIanaXML();
             DaemonCommon::systemSetFolderPermissions(EasyConfig_PATH . 'Iana_TLD.xml', 'root', 'root', '644');
             System_Daemon::debug('Finished "updateIana" subprocess.');
             break;
         case 'updateSystem':
             System_Daemon::debug('Starting "updateSystem" subprocess.');
             if (self::verifySystemUpdate()) {
                 self::handleSystemUpdate();
             }
             System_Daemon::debug('Finished "updateSystem" subprocess.');
             break;
         case 'userexists':
             System_Daemon::debug('Starting "userexists" subprocess.');
             exec(DaemonConfig::$cmd->CMD_ID . ' -u ' . $data['1'] . ' 2>&1', $result, $error);
             if ($error != 0) {
                 System_Daemon::debug('User ' . $data['1'] . ' does not exist');
                 unset($result);
                 return false;
             }
             System_Daemon::debug('Finished "userexists" subprocess.');
             break;
         default:
             System_Daemon::warning("Don't know what to do with " . $data[0]);
             return false;
     }
     System_Daemon::debug('Finished "DaemonSystem::Start" subprocess.');
     return true;
 }
예제 #2
0
 /**
  *
  * @param array $domainData
  * @return boolean
  */
 protected static function directoriesCreateHtdocs($domainData)
 {
     $htdocsDir = DaemonConfig::$distro->APACHE_WWW_DIR . "/" . $domainData['domain_name'];
     if (isset($domainData['mount'])) {
         $htdocsDir .= "/" . $domainData['mount'];
     }
     $htdocsDir .= "/htdocs";
     $sysGroup = DaemonConfig::$cfg->APACHE_SUEXEC_USER_PREF . $domainData['domain_gid'];
     $sysUser = DaemonConfig::$cfg->APACHE_SUEXEC_USER_PREF . $domainData['domain_uid'];
     if (!DaemonCommon::systemCreateDirectory($htdocsDir, $sysUser, $sysGroup) || !DaemonCommon::systemCreateDirectory($htdocsDir . "/images", $sysUser, $sysGroup)) {
         return "Cannot create " . $htdocsDir . ' or ' . $htdocsDir . "/images";
     }
     $tpl_param = array("THEME_CHARSET" => "UTF-8", "DOMAIN_NAME" => $domainData['domain_name'], "BASE_SERVER_VHOST_PREFIX" => DaemonConfig::$cfg->BASE_SERVER_VHOST_PREFIX, "BASE_SERVER_VHOST" => DaemonConfig::$cfg->BASE_SERVER_VHOST);
     $tpl = DaemonCommon::getTemplate($tpl_param);
     $config = $tpl->fetch("apache/parts/default_index.tpl");
     $tpl = NULL;
     unset($tpl);
     $htmlFile = $htdocsDir . "/index.html";
     if (!DaemonCommon::systemWriteContentToFile($htmlFile, $config, $sysUser, $sysGroup, 0644) || !copy(DaemonConfig::$cfg->ROOT_DIR . "/gui/domain_default_page/easyscp.css", $htdocsDir . "/easyscp.css") || !DaemonCommon::systemSetFolderPermissions($htdocsDir . "/easyscp.css", $sysUser, $sysGroup, 0775)) {
         return "Cannot write to " . $htdocsDir;
     }
     //copy images
     $sourceDir = dir(DaemonConfig::$cfg->ROOT_DIR . "/gui/domain_default_page/images");
     while (false !== ($entry = $sourceDir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         if ("{$htdocsDir}/images/{$entry}" !== DaemonConfig::$cfg->ROOT_DIR . "/gui/domain_default_page/images/{$entry}") {
             if (!copy(DaemonConfig::$cfg->ROOT_DIR . "/gui/domain_default_page/images/{$entry}", "{$htdocsDir}/images/{$entry}")) {
                 return "Cannot copy to " . $htdocsDir . '/images/';
             }
         }
     }
     return true;
 }