Start maps by script without pwAdmin
Heyho :):
I just want to know, how i can start single maps without using pwAdmin or any of those web access things. I want to make some sh files for every map so that i can control them by coding a timer program. Some of the maps like the Forrest ruins are time limited so they just needed to be started when its time for it :D:
And no i dont want a discussion about changing that times or "they are always on" i just want to know how to manually start and stop maps :):
Re: Start maps by script without pwAdmin
./gs <mapname (as configured in gs.conf)>
ex:
from within /PWServer/gamed (obviously)
./gs gs01 (world map)
./gs arena01 (self explanitory)
./gs bg01 (self explanitory)
./gs is34 (would start the chapel)
./gs is21 (would start celestial world)
./gs is22 (would start demon world)
and so on, and so on
Re: Start maps by script without pwAdmin
Quote:
Originally Posted by
343
./gs <mapname (as configured in gs.conf)>
ex:
from within /PWServer/gamed (obviously)
./gs gs01 (world map)
./gs arena01 (self explanitory)
./gs bg01 (self explanitory)
./gs is34 (would start the chapel)
./gs is21 (would start celestial world)
./gs is22 (would start demon world)
and so on, and so on
Wonderfull :): Thanks. Now i only need to make those scripts and mah timer program :):
Re: Start maps by script without pwAdmin
Quote:
Originally Posted by
Zorno
Wonderfull :): Thanks. Now i only need to make those scripts and mah timer program :):
No you can just use cron to do that...
crontab -e
add
Code:
.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .----- day of week (0 - 7) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * /PWServer/gamed/gs mapname
* * * * * /dont/remember/specific/map/kill/command
and tada, cron handles it
Re: Start maps by script without pwAdmin
Quote:
Originally Posted by
das7002
No you can just use cron to do that...
crontab -e
add
Code:
.---------------- minute (0 - 59)
| .------------- hour (0 - 23)
| | .---------- day of month (1 - 31)
| | | .------- month (1 - 12) OR jan,feb,mar,apr ...
| | | | .----- day of week (0 - 7) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * /PWServer/gamed/gs mapname
* * * * * /dont/remember/specific/map/kill/command
and tada, cron handles it
:blink:
Your mah man :):
This will help me keeping ram free.
Thanks for that :):
Re: Start maps by script without pwAdmin
Re: Start maps by script without pwAdmin
Quote:
Originally Posted by
Romulan
crontab rulez XD
There are many awesome things about Linux/UNIX based os's and yes cron is one of them :ott1:
(Won't tell people about other nifty little things I know about that most I found out about on accident D: )
Re: Start maps by script without pwAdmin
all hail cron =D (i love it, i use it for auto-announce, and to refresh my top players list)
Re: Start maps by script without pwAdmin
I use it to check every 5min if a map is crashed and restart it if necessary.
Re: Start maps by script without pwAdmin
Quote:
Originally Posted by
Romulan
I use it to check every 5min if a map is crashed and restart it if necessary.
Oooh thats a good idea
1. Check if map is crashed
2. Start map if it is crashed
3. Send system broadcast saying sorry about map crash and it will be back on shortly
4. Send email to GMs notifying them of crash
5. (this will take a bit more time) possible im notification using libpurple
I think Ill work on a script that does that
Re: Start maps by script without pwAdmin
check_gs01.sh
Code:
#/bin/bash
if ps ax | grep -v grep | grep 'gs gs01' > /dev/null >> /PWServer/logs/check_gs01.log
then
echo "GameServer: Main World[gs01] is RUNNING."
else
echo "GameServer: Main World[gs01] is DOWN. Restarting Main World..."
cd /PWServer/gamed
./gs gs01
fi
crontab
Code:
*/5 * * * * root /PWServer/check_gs01.sh
Re: Start maps by script without pwAdmin
Quote:
Originally Posted by
das7002
Oooh thats a good idea
1. Check if map is crashed
2. Start map if it is crashed
3. Send system broadcast saying sorry about map crash and it will be back on shortly
4. Send email to GMs notifying them of crash
5. (this will take a bit more time) possible im notification using libpurple
I think Ill work on a script that does that
Yea I mean hell, just in case you were away all together (out taking a jog / whatever) you could even have it send an SMS message to your mobile phone in addition to / or instead of an email or "IM". Then no matter where you are or what you are doing you would know 'wassup' ;)
Re: Start maps by script without pwAdmin
check_gs01.sh
Code:
#/bin/bash
if ps ax | grep -v grep | grep 'gs gs01' > /dev/null >> /PWServer/logs/check_gs01.log
then
echo "GameServer: Main World[gs01] is RUNNING."
else
echo "GameServer: Main World[gs01] is DOWN. Restarting Main World..."
wget http://localhost:8080/broadcast/mcrashbroadcast.jsp?m=Main%20World
wget http://localhost/gmmail/sendgmmail.php?m=Main%20World
cd /PWServer/gamed
./gs gs01
fi
crontab
Code:
*/5 * * * * root /PWServer/check_gs01.sh
mcrashbroadcast.jsp
Code:
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.lang.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
<%@page import="protocol.*"%>
<%@page import="com.goldhuman.auth.*"%>
<%@page import="com.goldhuman.util.*"%>
<%@page import="org.apache.commons.logging.Log"%>
<%@page import="org.apache.commons.logging.LogFactory"%>
<%@page import="java.io.*"%>
<%@page import="java.sql.*"%>
<%
//
// Coded by [B]aSH from Vendetta Gaming Network.
// Modified by das7002 for map crash system anoucements
String msg = request.getParameter("msg");
String mmsg = "Sorry that "+msg+" has crashed, it has been restarted and will be available again soon";
try {
protocol.DeliveryDB.broadcast((byte)9,-1,mmsg);
}
catch (Exception e)
{
out.println("<font color=red>Error Attempting to Broadcast Message!</font>");
}
%>
<%
out.println("<font color=green>Successfully Sent Broadcast Message!</font>");
%>
sendgmmail.php
PHP Code:
<?php
//config
//Use a ; after each email for the mail to be sent properly
$gms = "email1@host1.com;email2@host2.com;email3@host1.com";
//endconfig
$map = $_GET['m'];
$gms = explode(";", $gms);
$time = date('D, M, Y g:i:s');
foreach($gms as $gm){
mail($gm, "A map on your server has crashed", "Map $map has crashed at $time");
}
echo "Mail Sent!";
?>
.htaccess for mailsend folder
since I was lazy and didn't put any checks in
Code:
DENY FROM ALL
ALLOW FROM 127.0.0.1
Other then the im notification that should do it