Start maps by script without pwAdmin

Results 1 to 13 of 13
  1. #1
    cats addicted Zorno is offline
    MemberRank
    Apr 2010 Join Date
    GermanyLocation
    1,465Posts

    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
    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


  2. #2
    Omega 343 is offline
    MemberRank
    Oct 2009 Join Date
    Ancient DGN CTYLocation
    5,514Posts

    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
    Last edited by 343; 19-09-10 at 12:56 AM.

  3. #3
    cats addicted Zorno is offline
    MemberRank
    Apr 2010 Join Date
    GermanyLocation
    1,465Posts

    Re: Start maps by script without pwAdmin

    Quote Originally Posted by 343 View Post
    ./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

  4. #4
    Black Magic Development das7002 is offline
    MemberRank
    Apr 2010 Join Date
    EarthLocation
    2,188Posts

    Re: Start maps by script without pwAdmin

    Quote Originally Posted by Zorno View Post
    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

  5. #5
    cats addicted Zorno is offline
    MemberRank
    Apr 2010 Join Date
    GermanyLocation
    1,465Posts

    Re: Start maps by script without pwAdmin

    Quote Originally Posted by das7002 View Post
    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

    Your mah man
    This will help me keeping ram free.
    Thanks for that

  6. #6
    Nerd-IO Romulan is offline
    MemberRank
    Feb 2009 Join Date
    BelgiumLocation
    3,333Posts

    Re: Start maps by script without pwAdmin

    crontab rulez XD

  7. #7
    Black Magic Development das7002 is offline
    MemberRank
    Apr 2010 Join Date
    EarthLocation
    2,188Posts

    Re: Start maps by script without pwAdmin

    Quote Originally Posted by Romulan View Post
    crontab rulez XD
    There are many awesome things about Linux/UNIX based os's and yes cron is one of them

    (Won't tell people about other nifty little things I know about that most I found out about on accident D: )

  8. #8
    Omega 343 is offline
    MemberRank
    Oct 2009 Join Date
    Ancient DGN CTYLocation
    5,514Posts

    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)

  9. #9
    Nerd-IO Romulan is offline
    MemberRank
    Feb 2009 Join Date
    BelgiumLocation
    3,333Posts

    Re: Start maps by script without pwAdmin

    I use it to check every 5min if a map is crashed and restart it if necessary.

  10. #10
    Black Magic Development das7002 is offline
    MemberRank
    Apr 2010 Join Date
    EarthLocation
    2,188Posts

    Re: Start maps by script without pwAdmin

    Quote Originally Posted by Romulan View Post
    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
    Last edited by das7002; 19-09-10 at 12:38 PM.

  11. #11
    Nerd-IO Romulan is offline
    MemberRank
    Feb 2009 Join Date
    BelgiumLocation
    3,333Posts

    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

  12. #12
    Omega 343 is offline
    MemberRank
    Oct 2009 Join Date
    Ancient DGN CTYLocation
    5,514Posts

    Re: Start maps by script without pwAdmin

    Quote Originally Posted by das7002 View Post
    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' ;)

  13. #13
    Black Magic Development das7002 is offline
    MemberRank
    Apr 2010 Join Date
    EarthLocation
    2,188Posts

    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
    Last edited by das7002; 19-09-10 at 01:49 PM.



Advertisement