Jump to content

PY - General Panel Manager


Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

Hello community and happy new year!!

 

I will release a panel written to waste of time that will allow you to start, turn off, perform backups, compile quests or clean the syserr in a very fast and all in one interface and thus eliminating the classic bash file " start.sh, close.sh etc ...!

I wrote the script very "easy" to be understandable for anyone who has a minimum of Python knowledge and also I put the most important variables immediately after import!

The script works on Python 2.7 with FreeBSD 9.7 machine.

Well make good use 

 

##FreeWar Panel
import os
import subprocess
import time

TO_DELETE = ["syserr", "syslog", "cartof.core", "db.core"]
CORE_NAME = "cartof"
BACKUP_PATH = "/usr/game/backup"
SERVER_PATH = "/usr/game/server/"
LOCALE_SERVICE_QUESTS = "/usr/game/share/locale/romania/quest"

def main():
    print('''
\033[1;32;40m___________                     __      __               
\_   _____/______   ____   ____/  \    /  \_____ _______ 
 |    __) \_  __ \_/ __ \_/ __ \   \/\/   /\__  \\_  __  \ 
 |     \   |  | \/\  ___/\  ___/\        /  / __ \|  | \/
 \___  /   |__|    \___  >\___  >\__/\__/  (____  /__|   
     \/                \/     \/  \/  \/       
         __________                      .__             
         \______   \_____    ____   ____ |  |            
          |     ___/\__  \  /    \_/ __ \|  |            
          |    |     / __ \|   |  \  ___/|  |__          
          |____|    (____  /___|  /\___  >____/          
                 \/     \/     \/ 
Press Key:
1) Start Server
2) Close Server
3) Clean SYSERR, SYSLOG, CoreDump
4) Compile all or one quest
5) Backup Server
0) Close        
\033[0;37;40m             
    ''')

    while True:
        a = raw_input("Value between 0 and 5:")
        try:
           a = int(a)
        except ValueError:
           print "Valid number, please"
           continue
        if 0 <= a <= 5:
           break
        else:
           print "Valid range, please: 0-5"
       
    if a == 1:
        print("\033[1;36;40mPlease enter number of CH(1-4): \033[0;37;40m")
        while True:
            chn = raw_input("Digit 0 to break start operation! ")
            try:
               chn = int(chn)
            except ValueError:
               print "Valid number, please"
               continue
            if 0 <= chn <= 4:
               break
            else:
               print "Valid range, please: 0-4"
               
               
        if chn == 0:
            return
        os.chdir(SERVER_PATH + "db_auth/db")
        subprocess.Popen("./db")
        time.sleep(2)
        os.chdir(SERVER_PATH + "db_auth/auth")
        subprocess.Popen("./auth")
        time.sleep(2)
        for x in range(1, (chn + 1)):
            folderlink = (SERVER_PATH + "ch" + str(chn))
            for y in range(1, 5):
                os.chdir(folderlink + "/core_" + str(y))
                subprocess.Popen("./core_" + str(y))
                time.sleep(2)

        print("\033[1;32;40m ++Server Online++ \033[0;37;40m")
        return
        
    elif a == 2:
        Alive = ""
        ps = subprocess.Popen("pgrep " + CORE_NAME, shell=True, stdout=subprocess.PIPE)
        Alive = ps.stdout.read()
        ps.stdout.close()
        ps.wait()
        if len(Alive) > 0:
            subprocess.Popen("pkill " + CORE_NAME, shell=True, stdout=subprocess.PIPE)
            print("Metin2 server closed!")
        
        elif len(Alive) == 0:
            print("Metin2 Server is already Offline!")
        return
        
    elif a == 3:
        for x in range(0, len(TO_DELETE)):
            print "Deleting " + TO_DELETE[x]
            ps = subprocess.Popen("find . -name " + TO_DELETE[x] + " -delete", shell=True, stdout=subprocess.PIPE)
        print("Clean!1")
    
    elif a == 4:
        print("Digit the name of the quest or digit 'ALL' to compile all quests: ")
        name = raw_input()
        os.chdir(LOCALE_SERVICE_QUESTS)
        if name == "ALL":
            os.system("for f in *.quest; do ./qc $f; done")
            os.system("for f in *.lua; do ./qc $f; done")
        else:
            os.system("./qc " + name)
            
    elif a == 5:
        from datetime import datetime
        Time = str(datetime.now())
        print "Backup on the way..."
        if not os.path.exists(BACKUP_PATH):
            os.makedirs(BACKUP_PATH)
        os.chdir(BACKUP_PATH)
        os.makedirs(Time)
        os.chdir(Time)
        os.system("tar cfzv GAME_" + Time + ".tar.gz /usr/game")
        os.system("tar cfzv MySQL_" + Time +".tar.gz /var/db/mysql")
        
        
    elif a == 0:
        os.system("clear")
        return
        
    
    time.sleep(1)
    main()
        
main()

 

  • Metin2 Dev 1
  • Smile Tear 1
  • Love 2
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.