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