- Joined
- Dec 11, 2007
- Messages
- 3,666
- Solutions
- 1
- Reaction score
- 125
- Location
- Warsaw, Poland
- GitHub
- tayandenga
- Twitch
- tayandenga
Basing on this: http://otland.net/f118/panel-ots-start-restart-stop-25400/
I've created an option-configurable WWW control panel for TheForgottenServer 0.3 at Debian (including forks as Ubuntu).
To run it properly you need to enable in your PHP configuration function called "shell_exec" and have installed commands "sudo" and "screen".
Here it goes...
Login to your server and switch to root user (directly via su, or sudo su)
Now follow the bolded commands:
pico /etc/init.d/theforgottenserver and paste this:
Press F2 and save the file.
visudo and add at end:
Press F2 and save the file.
Switch to your www directory (cd /var/www?) and create a directory called "control" (mkdir control).
pico index.php and paste:
Replace path in the $path to path, where you have theforgottenserver executable.
Press F2 and save the file.
Now you have to add there a password protection...
pico .htaccess and paste:
(Replace the underlined text with your path)
Press F2 and save the file.
Yet to generate the .htpasswd file...
htpasswd -cm .htpasswd user
(Replace the underlined text with your user)
and type your password (it won't be displayed, gonna be saved as MD5 hash in the .htpasswd).
If you want to add new users type: htpasswd -m .htpasswd user (wihout 'c' parameter).
At the end, you have to allow the theforgottenserver executable execution rights, so changed to directory where you have your server and: chmod +x theforgottenserver
You may perform some action now- enter the panel via http://link/control, type user & password and try it out.
I've created an option-configurable WWW control panel for TheForgottenServer 0.3 at Debian (including forks as Ubuntu).
To run it properly you need to enable in your PHP configuration function called "shell_exec" and have installed commands "sudo" and "screen".
Here it goes...
Login to your server and switch to root user (directly via su, or sudo su)
Now follow the bolded commands:
pico /etc/init.d/theforgottenserver and paste this:
Code:
#!/bin/sh
#
# Startup and signals management script for TheForgottenServer
#
case "$1" in
start)
echo -n "Starting theforgottenserver: "
cd $2 && screen -AdmS ./theforgottenserver
echo "done."
;;
stop)
echo -n "Shutting down theforgottenserver: "
killall -TERM theforgottenserver
echo "done."
;;
kill)
echo -n "Killing theforgottenserver: "
killall -KILL theforgottenserver
echo "done."
;;
quit)
echo -n "Quitting theforgottenserver: "
killall -QUIT theforgottenserver
echo "done."
;;
restart)
$0 stop
$0 start
;;
reload)
echo -n "Reloading theforgottenserver: "
killall -CONT theforgottenserver
echo "done."
;;
save)
echo -n "Saving theforgottenserver data: "
killall -HUP theforgottenserver
echo "done."
;;
clean)
echo -n "Cleaning theforgottenserver map: "
killall -TRAP theforgottenserver
echo "done."
;;
refresh)
echo -n "Refreshing theforgottenserver map: "
killall -CHLD theforgottenserver
echo "done."
;;
close)
echo -n "Setting theforgottenserver gamestate to closed: "
killall -USR1 theforgottenserver
echo "done."
;;
open)
echo -n "Setting theforgottenserver gamestate to normal: "
killall -USR2 theforgottenserver
echo "done."
;;
*)
echo "Usage: $0 {start path|stop|kill|quit|restart|reload|save|clean|refresh|close|open}"
exit 1
esac
exit 0
visudo and add at end:
Code:
www-data ALL= NOPASSWD: ALL
Switch to your www directory (cd /var/www?) and create a directory called "control" (mkdir control).
pico index.php and paste:
PHP:
<?php
$path = "/home/tfs";
$options = array("start" => true, "stop" => true, "kill" => true, "quit" => false, "restart" => true, "reload" => true, "save" => true, "clean" => true, "refresh" => false, "close" => true, "open" => true);
echo "<html>
<head>
<meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\">
<title>TheForgottenServer WWW Control</title>
</head>
<body style=\"color: rgb(0, 0, 0); background-color: rgb(204, 204, 255);\" alink=\"#000099\" link=\"#000099\" vlink=\"#990099\">\n";
if(isset($_GET['do']) && in_array($_GET['do'], $options) && $options[$_GET['do']])
{
$output = shell_exec("/usr/bin/sudo /etc/init.d/theforgottenserver ".$_GET['do'].($_GET['do'] == "start" ? " ".$path : ""));
echo nl2br($output)."\n<br />\n<a href=\"".$_SERVER['HTTP_REFERER']."\">» Back</a>\n";
}
else
{
echo "\t\tAvailable options:<br />\n";
foreach($options as $option => $enabled)
{
if($enabled)
echo "\t\t<br />\n\t\t» <a href=\"".$_SERVER['PHP_SELF']."?do=".$option."\">".ucfirst($option)."</a>\n";
}
}
echo "\t</body>
</html>";
?>
Press F2 and save the file.
Now you have to add there a password protection...
pico .htaccess and paste:
Code:
AuthUserFile [u]/var/www/control/[/u].htpasswd
AuthGroupFile /dev/null
AuthName "TheForgottenServer WWW Control Panel"
AuthType Basic
<limit GET POST>
require valid-user
</limit>
Press F2 and save the file.
Yet to generate the .htpasswd file...
htpasswd -cm .htpasswd user
(Replace the underlined text with your user)
and type your password (it won't be displayed, gonna be saved as MD5 hash in the .htpasswd).
If you want to add new users type: htpasswd -m .htpasswd user (wihout 'c' parameter).
At the end, you have to allow the theforgottenserver executable execution rights, so changed to directory where you have your server and: chmod +x theforgottenserver
You may perform some action now- enter the panel via http://link/control, type user & password and try it out.
Last edited: