コード例 #1
0
ファイル: SteamServer.php プロジェクト: Onneil/dedipanel
 /**
  * @param string $action
  */
 public function execPluginScript(\Twig_Environment $twig, Plugin $plugin, $action)
 {
     if ($action != 'install' && $action != 'uninstall' && $action != 'activate' && $action != 'deactivate') {
         throw new \BadMethodCallException('Only actions available for SteamServers plugin scripts are : install, uninstall, activate and deactivate.');
     }
     $conn = $this->getMachine()->getConnection();
     // En cas d'installation, vérification des dépendances du plugin
     if ($action == 'install') {
         $packetDependencies = $plugin->getPacketDependencies();
         if (!empty($packetDependencies)) {
             $missingPackets = array();
             foreach ($packetDependencies as $dep) {
                 if (!$conn->isInstalled($dep)) {
                     $missingPackets[] = $dep;
                 }
             }
             if (!empty($missingPackets)) {
                 throw new MissingPacketException($missingPackets);
             }
         }
     }
     $dir = $this->getAbsoluteGameContentDir();
     $scriptName = $plugin->getScriptName();
     $scriptPath = $dir . $scriptName . '.sh';
     $pluginScript = $twig->render('DPSteamServerBundle:sh:Plugin/' . $scriptName . '.sh.twig', array('gameDir' => $dir));
     $conn->upload($scriptPath, $pluginScript);
     $screenName = $this->getPluginInstallScreenName($scriptName);
     $screenCmd = 'screen -dmS ' . $screenName . ' ' . $scriptPath . ' ' . $action;
     if ($action == 'install') {
         $screenCmd .= ' "' . $plugin->getDownloadUrl() . '"';
     }
     $conn->exec($screenCmd);
 }
コード例 #2
0
ファイル: MinecraftServer.php プロジェクト: Onneil/dedipanel
 public function execPluginScript(\Twig_Environment $twig, Plugin $plugin, $action)
 {
     if ($action != 'install' && $action != 'uninstall') {
         throw new BadMethodCallException('Only actions available for MinecraftServers plugin script are : install and uninstall.');
     }
     $conn = $this->getMachine()->getConnection();
     $dir = $this->getAbsoluteDir();
     $scriptPath = $dir . 'plugin.sh';
     $pluginScript = $twig->render('DPMinecraftServerBundle:sh:plugin.sh.twig', array('gameDir' => $dir . 'plugins'));
     $conn->upload($scriptPath, $pluginScript);
     $screenName = $this->getPluginInstallScreenName();
     $screenCmd = 'screen -dmS ' . $screenName . ' ' . $scriptPath . ' ' . $action;
     if ($action == 'install') {
         $screenCmd .= ' "' . $plugin->getDownloadUrl() . '"';
     }
     $conn->exec($screenCmd);
 }
コード例 #3
0
ファイル: Game.php プロジェクト: Onneil/dedipanel
 /**
  * Add plugins
  *
  * @param  $plugin \Doctrine\Common\Collections\ArrayCollection
  */
 public function addPlugin(\DP\Core\GameBundle\Entity\Plugin $plugin)
 {
     $this->plugins[] = $plugin;
     if (!$plugin->getGames()->contains($this)) {
         $plugin->addGame($this);
     }
 }