Compare commits

..

No commits in common. "2b1271ec6ed2133c6a1618b8362849825b9d0946" and "7d005f14b9681549dbcdb3453980d4db4038efb2" have entirely different histories.

2 changed files with 6 additions and 83 deletions

View File

@ -1,6 +1,6 @@
<?PHP <?PHP
define("INDEX_DIR", __DIR__);
require __DIR__.'/scripts/class.TerminalMessage.php'; require __DIR__.'/scripts/class.TerminalMessage.php';
require __DIR__.'/scripts/func.downloadFile.php'; require __DIR__.'/scripts/func.downloadFile.php';

View File

@ -23,46 +23,10 @@ class FactorioServer {
*/ */
private $mods; private $mods;
/**
* @var ValveRcon for handling Valve Rcon to server
*/
private $rcon;
/** /**
* @var string Name of the Save to load when starting the server * @var string Name of the Save to load when starting the server
*/ */
private $save_name; private $saveName;
/**
* @var string Path to the Server Directory
*/
private $server_dir = INDEX_DIR . "/factorio";
/**
* @var string Path to the Mods Directory
*/
private $mod_dir = INDEX_DIR . "/factorio/mods";
/**
* @var string Path to the Save-File Directory
*/
private $save_dir = INDEX_DIR . "/factorio/saves";
/**
* @var string Name of the user who owns the files and runs this server
*/
private $user_name = "factorio";
/**
* @var string Name of the user-group who owns the files and runs this server
*/
private $user_group = "factorio";
/**
* @var string Name of the Service in systemd/systemctl
*/
private $service_name = "factorio";
/** /**
* @var callcable Custom function for stopping the server (return bool) * @var callcable Custom function for stopping the server (return bool)
@ -74,16 +38,6 @@ class FactorioServer {
*/ */
private $customStart = null; private $customStart = null;
/**
* @var callable Custom function for restarting the server (return bool)
*/
private $customReStart = null;
/**
* @var callable Custom function for checking the server status (return bool - true means server is running, false means server is not running)
*/
private $customIsRunning = null;
/** /**
* @var array Server Settings * @var array Server Settings
*/ */
@ -97,7 +51,7 @@ class FactorioServer {
/** /**
* @var array Server Admin List * @var array Server Admin List
*/ */
private $admin_list = []; private $adminList = [];
/** /**
@ -183,7 +137,7 @@ class FactorioServer {
return call_user_func($this->customStart); return call_user_func($this->customStart);
} }
$command = "systemctl start ".$this->getServiceName(); $command = "systemctl start factorio-server";
exec($command, $output, $return); exec($command, $output, $return);
return ( $return === 0 ); return ( $return === 0 );
@ -196,11 +150,7 @@ class FactorioServer {
*/ */
public function restart() : bool { public function restart() : bool {
if(is_callable($this->customReStart)) { exec("systemctl restart factorio-server > /dev/null", $output, $return);
return call_user_func($this->customReStart);
}
exec("systemctl restart ".$this->getServiceName()." > /dev/null", $output, $return);
return ( $return === 0 ); return ( $return === 0 );
@ -213,37 +163,10 @@ class FactorioServer {
*/ */
public function isRunning() : bool { public function isRunning() : bool {
if(is_callable($this->customIsRunning)) { exec("systemctl is-active factorio-server", $output, $return);
return call_user_func($this->customIsRunning);
}
exec("systemctl is-active ".$this->getServiceName(), $output, $return);
return ( $return === 0 ); return ( $return === 0 );
} }
/**
* Get the Name of the Service in systemd/systemctl.
* @return string Name of the service
*/
public function getServiceName() : string {
return $this->service_name;
}
/**
* Sets the Name of the Service in systemd/systemctl.
* @param string $serviceName Name of the Service
* @return FactorioServer $this for chaining.
*/
public function setServiceName(string $serviceName) : FactorioServer {
$this->service_name = $serviceName;
return $this;
}
} }