Salve community, stasera vi rilascio un pannello scritto a perdita di tempo che vi consentirá di avviare, spegnere, eseguire backup, compilare quest o pulire i syserr in modo del tutto veloce e tutto in un'unica interfaccia ed eliminando cosi i classici bash file "start.sh, close.sh ecc...!
Lo script l'ho scritto molto "easy" per essere comprensibile per chiunque che ha un minimo di conoscenza Python ed inoltre ho messo le variabili piú importanti subito dopo gli import!
Lo script lavora su Python 2.7 con macchina FreeBSD 9.7.
Beh fatene buon uso
Lo script l'ho scritto molto "easy" per essere comprensibile per chiunque che ha un minimo di conoscenza Python ed inoltre ho messo le variabili piú importanti subito dopo gli import!
Lo script lavora su Python 2.7 con macchina FreeBSD 9.7.
Beh fatene buon uso
Python:
##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()