Beispiel #1
0
 /**
  *
  */
 public function tool2BinAction()
 {
     $lsOrigem = BIN_DIR . DS . "cmstool.php";
     $lsLink = BASE_DIR . DS . "bin" . DS . "cmstool";
     System::simblink($lsOrigem, $lsLink);
     $loSrv = new SrvController();
     $loSrv->tool2BinAction();
 }
Beispiel #2
0
 /**
  * 
  */
 public function tool2BinAction()
 {
     $lsOrigem = BIN_DIR . DS . "srvtool.php";
     $lsLink = BASE_DIR . DS . "bin" . DS . "srvtool";
     System::simblink($lsOrigem, $lsLink);
 }
Beispiel #3
0
 /**
  * 
  */
 public function virtualHostDevAction()
 {
     if ($_SERVER["USER"] == "root") {
         $laApacheConf = $this->getApacheConf();
         if (is_array($laApacheConf)) {
             $lsApacheGrp = $laApacheConf['Group'];
             $lsDocRoot = $laApacheConf['DocumentRoot'] . DS;
             $lsServerRoot = $laApacheConf['ServerRoot'] . DS;
         } else {
             $lsApacheGrp = "www-data";
             $lsDocRoot = DS . "var" . DS . "www" . DS;
             $lsServerRoot = DS . "etc" . DS . "apache2" . DS;
         }
         $lsApacheGroup = $this->getRequestArg('apachegrp', $lsApacheGrp);
         echo "CHGPR project folder\n";
         $laReturn = System::execute("chgrp {$lsApacheGroup} " . BASE_DIR . " -R");
         Debug::debug($laReturn);
         $lsDocRoot = $this->getRequestArg('docroot', $lsDocRoot, true);
         $laAppDirName = explode(DS, BASE_DIR);
         $lsAppDirName = array_pop($laAppDirName);
         if (!file_exists($lsDocRoot . DS . $lsAppDirName) || System::confirm("The link {$lsDocRoot}{$lsAppDirName} already exists! Overwrite?")) {
             echo "Create project link to document root: " . BASE_DIR . "  to {$lsDocRoot}\n";
             System::simblink(BASE_DIR, $lsDocRoot);
         }
         if (System::confirm("Create Apache virtual host?")) {
             $lsClientFolder = $this->getRequestArg('folder', $this->_sClientFolder, true);
             if (empty($this->_sClientDomain)) {
                 $this->_sClientDomain = "local.{$lsClientFolder}";
             }
             $lsDomain = $this->getRequestArg('domain', $this->_sClientDomain, true);
             $lsPort = $this->getRequestArg('httpport', '80', true);
             $lsHosts = $this->getRequestArg('hosts', DS . "etc" . DS . "hosts", true);
             $lsLocalhost = $this->getRequestArg('localhost', "127.0.0.1", true);
             $lsApacheDir = $this->getRequestArg('apachedir', $lsServerRoot);
             if (file_exists($lsHosts)) {
                 echo "Backuping {$lsHosts} to {$lsHosts}.bkp\n";
                 $laReturn = System::execute("cp {$lsHosts} {$lsHosts}.bkp");
                 Debug::debug($laReturn);
                 echo "Seting '{$lsLocalhost}\t{$lsDomain}' to {$lsHosts}\n";
                 $laReturn = System::execute("echo {$lsLocalhost}\t{$lsDomain} >> {$lsHosts}");
                 Debug::debug($laReturn);
             } else {
                 System::echoWarning("The {$lsHosts} does not exists!");
             }
             if ($this->_sController == 'Cms') {
                 $lsPublicFolder = 'public';
             } elseif ($this->_sController == 'Srv') {
                 $lsPublicFolder = 'srv-public';
             }
             $lsDocumentRoot = $lsDocRoot . $lsAppDirName . DS . 'client' . DS . $lsClientFolder . DS . $lsPublicFolder;
             $lsSitesAvailablePath = $lsApacheDir . 'sites-available' . DS . "{$lsDomain}.conf";
             if (!file_exists($lsSitesAvailablePath) || System::confirm("The vhost {$lsDomain}.conf already exists! Overwrite?")) {
                 echo "Creating vhost: {$lsSitesAvailablePath}\n";
                 $lsVirtualHost = $this->vHost($lsDocumentRoot, $lsDomain, $lsPort);
                 Debug::debug($lsVirtualHost);
                 $laReturn = System::saveFile($lsSitesAvailablePath, trim($lsVirtualHost));
                 Debug::debug($laReturn);
             }
             echo "Enable vhost {$lsDomain}\n";
             $laReturn = System::execute("a2ensite {$lsDomain}");
             Debug::debug($laReturn);
             if (System::confirm("Reload Apache2?")) {
                 echo "Apache reload\n";
                 $laReturn = System::execute(DS . "etc" . DS . "init.d" . DS . "apache2 reload");
                 Debug::debug($laReturn);
             }
         }
     } else {
         System::echoError("You need root access to run this action! Please try run this action using sudo.");
     }
 }