search plugin restart XAseco

Discuss everything about Xymph's Aseco flavoured server control scripts for TM Forever / classic TMN and for TM² Canyon.

Moderators: Xymph, TM-Patrol

Post Reply
User avatar
shoei
wheelbarrow operator
wheelbarrow operator
Posts: 24
Joined: 18 Nov 2010 06:43
Owned TM-games: tmuf

search plugin restart XAseco

Post by shoei » 14 Feb 2011 18:14

hello all,
I want a plugin to restart XAseco since the game because I have a server with FTP access to the changes but I have no button to initiate the restart.

is there a plugin under linux??
Image
Image

nocturne
solid chaser
solid chaser
Posts: 1390
Joined: 08 Jun 2007 18:48
Owned TM-games: all
Contact:

Re: search plugin restart XAseco

Post by nocturne » 15 Feb 2011 01:37

Wait... so you have no console access? How do you start the server..?
Chief Janitorial Supervisor of the Let'sRock! TM community : www.LetsRock-TM.com

User avatar
shoei
wheelbarrow operator
wheelbarrow operator
Posts: 24
Joined: 18 Nov 2010 06:43
Owned TM-games: tmuf

Re: search plugin restart XAseco

Post by shoei » 15 Feb 2011 21:17

I use the plugin.xrestart.php on one of my servers, it works with the command / xrestart and recharges XAseco since the cat in the game
but it only works for windows.

>>> viewtopic.php?t=23186 <<<

I seek a solution already existing Linux??

or if somebody could change to plugin for linux?? please, thank you
Image
Image

TheGreenYoshi
cyclist
cyclist
Posts: 44
Joined: 25 Jan 2011 17:11
Owned TM-games: TMUF, TMNF
Manialink(s): awesome, polls

Re: search plugin restart XAseco

Post by TheGreenYoshi » 15 Feb 2011 22:21

Just start up a 2nd xaseco process, wait till the welcome message comes, then close the other one.
I'm not an expert with linux, maybe you know the right functions to do this. The above is more psuedo-like.

craigb456
tricycle manager
tricycle manager
Posts: 27
Joined: 23 Sep 2009 07:00
Owned TM-games: TMU

Re: search plugin restart XAseco

Post by craigb456 » 15 Feb 2011 22:46

this is what I use it just restarts xaseco on crash or shutdown command

XAseco crash rebooter
viewtopic.php?f=127&t=20595

User avatar
shoei
wheelbarrow operator
wheelbarrow operator
Posts: 24
Joined: 18 Nov 2010 06:43
Owned TM-games: tmuf

Re: search plugin restart XAseco

Post by shoei » 17 Feb 2011 02:28

thank you very much, it seems that (reboot crash XAseco) is the solution I want.

viewtopic.php?t=22911 I found after much research.

I'll try both solutions.

I'll post a message to inform you of my choice

thank you again
Image
Image

User avatar
norico
wheelbarrow operator
wheelbarrow operator
Posts: 23
Joined: 24 Nov 2008 19:35
Owned TM-games: TM(U)/ TM²

Re: search plugin restart XAseco

Post by norico » 10 Mar 2011 18:58

RTMF !

User avatar
Merlin
road tourist
road tourist
Posts: 85
Joined: 21 Jul 2007 23:00
Owned TM-games: TMO, TMUF, TMNF

Re: search plugin restart XAseco

Post by Merlin » 10 Mar 2011 19:29

Developed a script for my Server some time ago...

Might be useful for Unix-users ^^

Linuxscript: Checking status of Dedicated Server and Plugin

The meaning of this little script is: Checking status of Dedciated Server and Plugin -> If they´re not running: Start them!

The script is checking presence of two processes in memory: Dedicated Server and Plugin.

1. If Plugin is running and the Dedicated Server, too: Everything is fine - there is nothing to do! :)
2. If Plugin is running but the Dedicated Server not: Kill running Plugin and start the Dedicated Server
3. If Dedciated Server is running but the Plugin not: Start the Plugin

Code: Select all

#
# Simple script +checklive.sh+ to check status of Deciated Server and Plugin
# If status reports: not running -> Dedciated and Plugin will be started.
#
# Insert following line in crontab to run this script every 5 minutes:
#
# */5 * * * * /path/to/script/checklive.sh
# 
# (c) by Merlin of TMU-XRated in 2010
#

#
# Define Varibles
# 'php5' is usually for the Plugin - Try command +ps -ef | grep php+ to find out.
#
# 'TrackmaniaServer' ist normally the name of the executable binary of the Dedicated Server
#
SERVICEA='php5'
SERVICEB='TrackmaniaServer'
 
#
# Checking if Plugin ( Varible SERVICEA ) is running..
# If Plugin is running -> check if Dedicated Server ( Variable SERVICEB ) is running, too
# If Dedicated Server is not running but the Plugin is -> Kill the Plugin and start the Dedicated Server
#
if ps ax | grep -v grep | grep $SERVICEA > /dev/null
then
	if ps ax | grep -v grep | grep $SERVICEB > /dev/null
	then
		echo "Plugin and Dedicated Server are running, everthing is fine"
		exit;
	else
		echo "Plugin is running but Dedicated Server is not!"
		echo "Killing the Plugin and starting Dedicated Server"
		killall -9 $SERVICEA
		cd /path/to/tmufserver
		/path/to/tmufserver/DedicatedServer.sh;
		exit;
	fi
exit;
 
#
# First inquiry reported that Plugin is not running...
# Check if Dedicated Server is running, if Dedicated Server is running ->  Plugin will be started
# If the Dedicated Server is not runinng -> Dedicated Server will be started
#
else
 
	if ps ax | grep -v grep  | grep $SERVICEB > /dev/null
	then
		echo "Dedicated Server is running."
		echo "Plugin is not running, will be started now"
		cd /path/to/xaseco
		/path/to/xaseco/aseco.sh;
		exit;
	else
		echo "Dedicated Server is not running"
		echo "Starting the Dedicated Server now"
		cd /path/to/tmufserver
		/path/to/tmufserver/DedicatedServer.sh;
		exit;
	fi
fi
Linux: How to call the script in Crontab

To call this script every 5 Minutes via crontab:

1. Open a terminal
2. type the following:

Code: Select all

crontab -e
3. Insert following line:

*/5 * * * * /path/to/script/checklive.sh

Remark: You should not start the Plugin immediately after the Dedicated Server. The Dedicated Server needs some time to start up. So... whait a few minutes to start the Plugin! 5 Minutes should be fine ^^

4. Save and quit
5. Be happy ;O)

Possible scenarios if you call checklive.sh every 5 Minutes

1. The Plugin has crashed - Dedicated Server is running.
In this case the script will be called after 5 Minutes -> checking status -> recognises "No Plugin running" -> start it -> Everything is fine ( After 5 minutes ) !

2. The Dedicated Server is crashed, the Plugin remains in memory.
After 5 minutes the script is checking status -> recognises "There is no Dedicated Server but Plugin is running" -> Script is killing the running Plugin -> is starting the Dedicated Server - Finish (for this time) -> 5 minutes later is called again from crontab and is checking status -> recognises "No running Plugin" -> start the plugin -> Everthing is fine! ( After 10 minutes )

3. The Dedicated Server and the Plugin are crashed
After 5 minutes the script is checking status -> recognises "There is no Dedicated Server and Plugin" -> Script is starting the Dedicated Server - Finish (for this time) -> 5 minutes later is called again from crontab and is checking status -> recognises "No running Plugin" -> start the plugin -> Everthing is fine! ( After 10 minutes )
Finally

If you run this every 5 Minutes: You have nothing to do after a crash of Dedicated Server or Plugin. Everthing is "selfhealing" ;O)

Source: http: www.wiki.tmu-xrated.de

User avatar
shoei
wheelbarrow operator
wheelbarrow operator
Posts: 24
Joined: 18 Nov 2010 06:43
Owned TM-games: tmuf

Re: search plugin restart XAseco

Post by shoei » 20 Mar 2011 16:49

thank you very much merlin

scipt this area has really great

I'll forward it to my web host so that the installation on my server

so I'll assume the shutdown command to the server and the XAseco fufi menu to launch the script when 5 min elapsed will

really great that manages the server and XAseco

thank you again
Image
Image

aca
pedestrian
pedestrian
Posts: 5
Joined: 22 Jun 2012 13:10
Owned TM-games: TM²

Re: search plugin restart XAseco

Post by aca » 28 Jun 2012 13:38

Searching for a restart-script for linux I only found Milenco Mulder'S xrestart-plugin for windows. I adapted it for linux and tested it some servers - works well for me.

If you want to use it:
1. place the following code into a file called plugin.xrestart.php
2. place the php-file in the xaseco2/plugins-folder
3. add <plugin>plugin.xrestart.php</plugin> in the plugins.xml

Code: Select all

<?php

/**
 * Xrestart plugin.
 * By Milenco Mulder on October 4nd, 2009
 *
 * adaptded by aca for linux use 2012-06-27
 *
 * /xrestart Restarts XASECO interface.
 * /xrestart all Restarts both server and XASECO.
 * 
 * Credits go mostly to Xymph. I've (re)used some of his code.
 *
 * Dependencies: none
 */ 
 

Aseco::addChatCommand('xrestart', 'Restarts XASECO interface (and server, when \"all\" parameter is given)');

function chat_xrestart($aseco, $command) {

	/**
	 * CHANGE THE SETTINGS BELOW IF YOU WISH
	 */
	 
	 //MUST CHANGE BELOW

	 //absolute path to XAseco2.sh
	 $xr_xaseco_path = '~/myDir/xaseco2/XAseco2.sh';
 	 
	 //absolute path to RunSrv.sh
	 $xr_dedi_path = '~/myDir/myDedi/RunSrv.sh';


	 //MUST CHANGE ABOVE	 

	 //Change whether MasterAdmins can restart anything.
	 $xr_ma_x = true; //Restart XASECO
	 $xr_ma_all = true; //Restart server and XASECO
	 
	 //Change whether Admins can restart anything.
	 $xr_a_x = true; //Restart XASECO
	 $xr_a_all = false; //Restart server and XASECO
	 
	 //Change whether Operators can restart anything.
	 $xr_op_x = false; //Restart XASECO
	 $xr_op_all = false; //Restart server and XASECO	 
	 
	 //Change the return line when no parameter is given (restart only XASECO).
	 // {1} = Requester name.
	 // {2} = Server name.
	 $xr_res_x_msg = "{#server}>> {#highlite}{1}{#error} has restarted XASECO on this server ({#highlite}{2}{#error})!";
	 
	 //Change the return line when "all" parameter is given (restart both server and XASECO).
	 // {1} = Requester name.
	 // {2} = Server name.
	 $xr_res_all_msg = "{#server}>> {#highlite}{1}{#error} has restarted this server ({#highlite}{2}{#error})!";

	 //Change the return line when wrong parameter is given (error).
	 // {1} = Requester name.
	 $xr_error = "{#server}> {#error}Wrong parameter! Use \"{#highlite}/xrestart{#error}\" or \"{#highlite}/xrestart all{#error}\"!";
	 
	 //Change the return line when user has no right to execute the command (error).
	 //Note: Comment out to disable error to user (return nothing)
	 // {1} = Requester name.
	 $xr_user_error = "{#server}> {#error}You do not have the appropriate permission to use this command!";

	 //Show permissions error to normal users (if set to false, only Operators, Admins and MasterAdmins will see error message)
	 $xr_user_show = false;

	/**
	 * CHANGE THE SETTINGS ABOVE IF YOU WISH
	 * DO NOT CHANGE ANYTHING BELOW THIS
	 */

	$player = $command['author'];
	$login = $player->login;
	
	//Nickname of requester.
	$xr_requester =  stripColors($player->nickname);
	
	//Servername
	$xr_servername = stripColors($aseco->server->name);
	
	//Determine whether player has rights to restart anything.
	if ($aseco->isMasterAdmin($player)) {
		$xr_res_x = $xr_ma_x;
		$xr_res_all = $xr_ma_all;
		$xr_user = false;
	} else if ($aseco->isAdmin($player)) {
		$xr_res_x = $xr_a_x;
		$xr_res_all = $xr_a_all;
		$xr_user = false;
	} else if ($aseco->isOperator($player)) {
		$xr_res_x = $xr_op_x;
		$xr_res_all = $xr_op_all;
		$xr_user = false;
	} else {
		//Disable right for user;
		$xr_res_x = false;
		$xr_res_all = false;
		$xr_user = true;
	}
	
	// split params into array
	$arglist = explode(' ', strtolower(preg_replace('/ +/', ' ', $command['params'])));
	
	//Restart XASECO
	if ($arglist[0] == null) {
	
		//Requester has permission
		if ($xr_res_x) {
		
			//Split XASECO filenames and directories from paths
			if (isset($xr_xaseco_path)) {
				$xr_xaseco_path_dir = dirname($xr_xaseco_path);
				$xr_xaseco_path_file = basename($xr_xaseco_path);
			} else {
				$xr_xaseco_path_dir = substr(__DIR__,0,strrpos(__DIR__,'\\'));
				//$xr_xaseco_path_file = "Aseco.bat";
				$xr_xaseco_path_file = "XAseco2.sh";
			}

			//Display message to clients
			$message = formatText($xr_res_x_msg,
								  $xr_requester,
								  $xr_servername);
			$message = $aseco->formatColors($message);
			$aseco->client->query('ChatSendServerMessage', $message);
			
			//Display message in console
			$aseco->console('{2} restarted XASECO!', $logtitle, $login);

			//execution code for shell
			$xr_exec_code = 'sleep 2; cd '.$xr_xaseco_path_dir.' ; ./'.$xr_xaseco_path_file;


			//Start new instance of XASECO			
			exec($xr_exec_code);			
			//Shuts down old instance of XASECO
			die();

			
		//Requester has no permission to restart XASECO.
		} else if (!$xr_user || ($xr_user && $xr_user_show)) {
			//Send error message
			$message = formatText($xr_user_error,
								  $xr_requester);
			$message = $aseco->formatColors($message);
			$aseco->client->query('ChatSendServerMessageToLogin', $message, $login);			
		}
	
	} 
	//Restart server
	else if ($arglist[0] == "all") {

		//Requester has permission
		if ($xr_res_all) {
		
			//Check wether $xr_dedi_path is set
			if (!isset($xr_dedi_path)) {
				$aseco->console('{2} tried to restart both XASECO and server, but $xr_dedi_path has not been set!', $logtitle, $login);
				return;
			}
			//Split XASECO filenames and directories from paths
			if (isset($xr_xaseco_path)) {
				$xr_xaseco_path_dir = dirname($xr_xaseco_path);
				$xr_xaseco_path_file = basename($xr_xaseco_path);
			} else {
				$xr_xaseco_path_dir = substr(__DIR__,0,strrpos(__DIR__,'\\'));
				//$xr_xaseco_path_file = "Aseco.bat";
				$xr_xaseco_path_file = "XAseco2.sh";
			}
			//Split dedicated server filenames and directories from paths
			$xr_dedi_path_dir = dirname($xr_dedi_path);
			$xr_dedi_path_file = basename($xr_dedi_path);
			
			//Display message to clients
			$message = formatText($xr_res_all_msg,
								  $xr_requester,
								  $xr_servername);
			$message = $aseco->formatColors($message);
			$aseco->client->query('ChatSendServerMessage', $message);
			
			//Display message in console
			$aseco->console('{2} restarted XASECO and server!', $logtitle, $login);

			
			
			
			
			//execution code for shell

			$xr_exec_code = 'sleep 5; cd '.$xr_dedi_path_dir.' ; ./'.$xr_dedi_path_file.'; cd '.$xr_xaseco_path_dir.' ; ./'.$xr_xaseco_path_file;

			//Shuts down old instance of SERVER 
			$rtn = $aseco->client->query('StopServer');
			
			//Start new instances			
			exec($xr_exec_code);
			

			if (!$rtn) {
				trigger_error('[' . $aseco->client->getErrorCode() . '] ' . $aseco->client->getErrorMessage(), E_USER_WARNING);
				die();
			} else {
				// test for /noautoquit
				sleep(2);
				$autoquit = new IXR_ClientMulticall_Gbx();
				if ($autoquit->InitWithIp($aseco->server->ip, $aseco->server->port))
					$aseco->client->query('QuitGame');

				trigger_error('Restart ' . $aseco->server->getGame() . ' server & XASECO!', E_USER_ERROR);
				die();
			}
			
		//Requester has no permission to restart server.
		} else if (!$xr_user || ($xr_user && $xr_user_show)) {
			//Send error message
			$message = formatText($xr_user_error,
								  $xr_requester);
			$message = $aseco->formatColors($message);
			$aseco->client->query('ChatSendServerMessageToLogin', $message, $login);						
		}
		
	//Wrong parameter
	} else if (!$xr_user || ($xr_user && $xr_user_show)) {
		//Send error message
		$message = formatText($xr_error,
				$xr_requester);
		$message = $aseco->formatColors($message);
		$aseco->client->query('ChatSendServerMessageToLogin', $message, $login);
	}
	
}  // chat_xrestart
?>

Post Reply