This commit is contained in:
Andrew 2021-12-09 11:33:27 -05:00
commit fd62da8137
11 changed files with 357 additions and 42 deletions

View File

@ -2,6 +2,7 @@
docker/
.dockerignore
Dockerfile
docker-compose.yml
# git & gitlab related
.git/

View File

@ -2,9 +2,11 @@ FROM python:alpine
LABEL maintainer="Dockerfile created by Zedifus <https://gitlab.com/zedifus>"
# Install Packages, Build Dependencies & Garbage Collect & Harden
# Install Packages & Garbage Collect Compile Deps & Harden
COPY requirements.txt /commander/requirements.txt
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/community llvm11-libs openssl-dev rust cargo gcc musl-dev libffi-dev make openjdk8-jre-base openjdk11-jre-headless openjdk16-jre-headless mariadb-dev \
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/latest-stable/community \
gcc musl-dev libffi-dev make rust cargo openssl-dev llvm11-libs \
openjdk8-jre-base openjdk11-jre-headless openjdk16-jre-headless openjdk17-jre-headless mariadb-dev \
&& pip3 install --no-cache-dir -r /commander/requirements.txt \
&& apk del --no-cache gcc musl-dev libffi-dev make rust cargo openssl-dev llvm11-libs \
&& rm -rf /sbin/apk \

View File

@ -34,17 +34,6 @@ class MainPrompt(cmd.Cmd, object):
def emptyline():
pass
@staticmethod
def _clean_shutdown():
exit_file = os.path.join(helper.root_dir, "exit.txt")
try:
with open(exit_file, 'w') as f:
f.write("exit")
except Exception as e:
logger.critical("Unable to write exit file due to error: {}".format(e))
console.critical("Unable to write exit file due to error: {}".format(e))
def do_exit(self, line):
self.universal_exit()
@ -77,7 +66,6 @@ class MainPrompt(cmd.Cmd, object):
logger.info("Stopping all server daemons / threads")
console.info("Stopping all server daemons / threads - This may take a few seconds")
websocket_helper.disconnect_all()
self._clean_shutdown()
console.info('Waiting for main thread to stop')
while True:
if self.tasks_manager.get_main_thread_run_status():

View File

@ -230,16 +230,6 @@ class Helpers:
version_data.get('meta', '?'))
return str(version)
def do_exit(self):
exit_file = os.path.join(self.root_dir, 'exit.txt')
try:
open(exit_file, 'a').close()
except Exception as e:
logger.critical("Unable to create exit file!")
console.critical("Unable to create exit file!")
sys.exit(1)
def encode_pass(self, password):
return self.passhasher.hash(password)

View File

@ -171,12 +171,10 @@ class Server:
if not helper.check_path_exists(self.server_path):
logger.critical("Server path: {} does not seem to exits".format(self.server_path))
console.critical("Server path: {} does not seem to exits".format(self.server_path))
helper.do_exit()
if not helper.check_writeable(self.server_path):
logger.critical("Unable to write/access {}".format(self.server_path))
console.warning("Unable to write/access {}".format(self.server_path))
helper.do_exit()
def start_server(self, user_id):
if not user_id:

View File

@ -48,7 +48,6 @@ class TasksManager:
self.webserver_thread = threading.Thread(target=self.tornado.run_tornado, daemon=True, name='tornado_thread')
self.main_kill_switch_thread = threading.Thread(target=self.main_kill_switch, daemon=True, name="main_loop")
self.main_thread_exiting = False
self.schedule_thread = threading.Thread(target=self.scheduler_thread, daemon=True, name="scheduler")
@ -65,16 +64,6 @@ class TasksManager:
def get_main_thread_run_status(self):
return self.main_thread_exiting
def start_main_kill_switch_watcher(self):
self.main_kill_switch_thread.start()
def main_kill_switch(self):
while True:
if os.path.exists(os.path.join(helper.root_dir, 'exit.txt')):
logger.info("Found Exit File, stopping everything")
self._main_graceful_exit()
time.sleep(5)
def reload_schedule_from_db(self):
jobs = management_helper.get_schedules_enabled()
schedule.clear(tag='backup')
@ -122,7 +111,6 @@ class TasksManager:
def _main_graceful_exit(self):
try:
os.remove(helper.session_file)
os.remove(os.path.join(helper.root_dir, 'exit.txt'))
os.remove(os.path.join(helper.root_dir, '.header'))
self.controller.stop_all_servers()
except:

View File

@ -224,6 +224,9 @@
],
"UltraBlack": [
"German"
],
"Zedifus": [
"LOLCAT (Kingdum ov Katz)"
]
},
"patrons": [

View File

@ -146,7 +146,7 @@
"playerControls": "Player Management"
},
"serverTerm": {
"stopScroll": "Stop Auto Scrollling",
"stopScroll": "Stop Auto Scrolling",
"commandInput": "Enter your command",
"sendCommand": "Send command",
"start": "Start",

View File

@ -0,0 +1,347 @@
{
"login": {
"forgotPassword": "FORGWOTS YOUR SEEKRET",
"login": "WOG INZ",
"password": "SEEKRET",
"username": "USERNAEM"
},
"error": {
"hereIsTheError": "HER IZ TEH OOF",
"contact": "CONTACK CWAFTY CONTROLLR SUPORT ON DA DIZORD",
"terribleFailure": "SUMTIN DUN BWOKE",
"embarassing": "OH MAH, WELL, DIS AR TEH EMBARRASIN.",
"error": "BIG OOF!",
"start-error": "CHAIR {} FAILD 2 START WIF OOF CODE: {}",
"closedPort": "WE HAS DETECTD CAT FLAP {} CUD NOT BE OPEN ON TEH WARM CHAIR'Z NETWORK OR FIREWAL IZ BLOCKIN IT. REMOTE HOOMAN CONNECSHUNS 2 TEH CHAIR CUD BE LIMITD.",
"internet": "WE HAS DETECTD TEH BIG BOX RUNNIN CRAFTY HAS NO CONNECSHUN 2 TEH INTERNET. HOOMAN CONNECSHUNS 2 TEH SERVR CUD BE LIMITD.",
"eulaTitle": "SAYZ YESH TWOO TEH LEGAL-WEEGALS",
"eulaMsg": "U MUST SAY YESH. COPY OV TEH MOJANG EULA IZ LINKD UNDR DIS MESAGE.",
"eulaAgree": "DOZ HOOMAN AGWEE",
"noJava": "CHAIR {} FAILD 2 GO WIF OOF CODE: WE HAS DETECTD JAVA IZ NOT HEREZ. PLZ BRING UZ JAVA DEN START TEH SERVR."
},
"404": {
"contact": "CONTACK CWAFTY CONTROLLR SUPORT ON DA DWISCORDZ",
"unableToFind": "WE WUZ UNABLE 2 FIND TEH PAEG U R LOOKIN 4. PLZ TRY AGAIN, OR GO BAK AN REFRESH.",
"notFound": "PAEG NOT FINDZ"
},
"footer": {
"version": "VERSHUN",
"copyright": "COPYRIGHT",
"allRightsReserved": "ALL FISH MINEZ"
},
"sidebar": {
"dashboard": "DASHBORD",
"servers": "SERVRS",
"documentation": "DOCUMENTASHUN",
"credits": "GUD HOOMANS",
"contribute": "THROW MONZ",
"newServer": "CONSTWUCT A SERVR",
"navigation": "NAVIGASHUN"
},
"serverWizard": {
"newServer": "Maek a nu servr",
"importServer": "Addz servr to Cwafty",
"importZip": "Addz servr from Squeezd Box",
"serverName": "Servr Naym",
"serverPath": "Servr Peth",
"serverType": "Servr Typ",
"selectType": "Wut typ ov servr",
"serverVersion": "Servr Verzhun",
"selectVersion": "How old iz servr?",
"absoluteServerPath": "Wer iz servr? (Absolute peth)",
"serverJar": "Servr Jafarfile",
"minMem": "Smol Memz Limit",
"maxMem": "BIG Memz Limit",
"serverPort": "Catflap",
"defaultPort": "25565 iz nermalz choicez",
"sizeInGB": "Siez in Gigabitez",
"zipPath": "Wer iz Squeezed Box (Peth)",
"absoluteZipPath": "Absolute peth 2 ur tiny box",
"resetForm": "Rezet",
"importServerButton": "Get a servr",
"buildServer": "Maek a servr!",
"quickSettings": "FAST SETTINGZ!",
"quickSettingsDescription": "NO FEAR, IT NOT PERMZ",
"myNewServer": "MY NEW SOFT CHAIR",
"bePatient": "Plz be paitentz me iz ' + (importing ? 'claimzin' : 'findin') + ' teh warm comfy servrz",
"importing": "Claimzin servrz...",
"downloading": "Huntin fur gud servr...",
"addRole": "Maek servr huv Existing Role(s)",
"autoCreate": "If none r selectd me wil maek wan, I Gochu!",
"selectRole": "Chooz Role(s)"
},
"dashboard": {
"dashboard": "DASHBORD",
"memUsage": "MEMZ USAGE",
"cpuUsage": "CPUZ USAGE",
"host": "FAVORITE BOX",
"players": "HOOMANZ",
"backups": "BAKUPS",
"newServer": "Maek new Servr",
"allServers": "Pak of Servrs",
"server": "SERVRS",
"actions": "ACSHUNS",
"world": "WURLD",
"motd": "MOTD",
"version": "VERZHUN",
"status": "STATUZ",
"online": "Turnd on",
"offline": "Turnd off",
"lastBackup": "Last:",
"nextBackup": "Next:",
"servers": "Servrs",
"cannotSeeOnMobile": "U Havin problermz seeun tiny scrienz?",
"cannotSee": "U Havin problermz seeun?",
"cannotSeeOnMobile2": "Try scrollin teh tablez sidewayz.",
"max": "Max",
"avg": "Avg",
"bePatientStart": "Plz be paitentz we startin teh servr.<br /> Dis skreehn WILL refursh in momentz",
"bePatientStop": "Plz be paitentz we stoppin teh servr.<br /> Dis scrien will refursh in momentz",
"bePatientRestart": "Plz be paitentz we restartin teh servr.<br /> Dis skreehn will refursh in momentz",
"bePatientClone": "Plz be paitentz we clone teh server.<br /> Dis scrien will refursh in momentz",
"sendingCommand": "Sendz ur comarned",
"cpuCurFreq": "Hamstur(cpu) speedz right naow",
"cpuMaxFreq": "Hamstur(cpu) Omglimited speed",
"cpuCores": "Numbr ov hamstur wheelz",
"start": "Maek go",
"stop": "Stahp Plz",
"clone": "Copyz",
"kill": "Eatz teh process",
"restart": "Restart",
"killing": "Maekin process go bye...",
"starting": "I waitz b4 I start",
"delay-explained": "Teh service/agent hus resently startd an iz delayin teh startd ov teh servr",
"no-servers": "Thar R no servrs. Big sad :( 2 git startd nd maek servr, click",
"welcome": "Welcom 2 Cwafty Controllr"
},
"accessDenied": {
"accessDenied": "Acces Denid",
"noAccess": "U do not haz acces 2 dis litterbox",
"contactAdmin": "Contakt ur servr adminz 4 acces 2 dis litterbox, or if u finkz u sud has acces, contakt suport",
"contact": "Contack Cwafty Controllr Suport on da Dwiscordz"
},
"serverStats": {
"online": "Turnd on",
"offline": "Turnd off",
"serverStatus": "Servr Status",
"serverStarted": "Servr Started",
"serverUptime": "How longz servr been awaek",
"players": "Hoomanz",
"memUsage": "How hard iz thinkin rn",
"cpuUsage": "CPU Usage",
"version": "Verzhun",
"description": "Descripshun",
"errorCalculatingUptime": "I maek oof wen calculatin teh teim awaek!",
"serverTime": "UTC Teim",
"unableToConnect": "Not today... :("
},
"serverDetails": {
"serverDetails": "Servr infoz",
"terminal": "Cmds go here",
"logs": "Logz",
"schedule": "Schdulez",
"backup": "Bakup",
"files": "Filez",
"config": "Settingz Wurld",
"playerControls": "Hooman managementz"
},
"serverTerm": {
"stopScroll": "Stahp teh scrolin",
"commandInput": "Entr your comarned",
"sendCommand": "Send comarned",
"start": "Maek go",
"restart": "Copyz",
"stop": "Stahp Plz",
"updating": "Plz waitz...",
"starting": "I waitz b4 I start",
"delay-explained": "Teh service/agent hus resently startd an iz delayin teh startd ov teh servr"
},
"serverPlayerManagement": {
"players": "Hoomans",
"bannedPlayers": "Naughty Hoomans",
"loadingBannedPlayers": "Plz wait, I telz u abot teh bad hoomanz"
},
"serverBackups": {
"backupNow": "Bakup nowz!",
"backupAtMidnight": "Auto-bakup at middlenightz?",
"storageLocation": "Shiny Stash ov hingz",
"storageLocationDesc": "Wer do u wants 2 stash bakups?",
"maxBackups": "Max Bakups",
"maxBackupsDesc": "Cwafty will not keepz moar than N bckups, deletin teh most oldz furst (entr 0 to be big greedy)",
"save": "Dun",
"cancel": "Stahp",
"currentBackups": "Current stash ov bakups",
"download": "Downloadz",
"path": "Peth",
"size": "How bigz",
"delete": "Maek gone",
"backupTask": "Okai I getz fish, bak soonz",
"destroyBackup": "Eat bakup \" + file_to_del + \"?",
"confirmDelete": "R u sure u wantz me to eatz dis bakup? Wial beh lozt forevr (longir than kittehz napz)",
"confirm": "Yis",
"options": "Opshuns"
},
"serverFiles": {
"noscript": "Mr file manager needz JafarScrpt, U SHULD GET IT",
"error": "Big oof wen I try to getz fishies",
"files": "Fish",
"default": "Defaultz",
"save": "Dun",
"editingFile": "Maek fish differentz",
"delete": "Eat fish",
"createFile": "Maek fish (>O.O<)",
"createDir": "Create directory (for fish)",
"rename": "Naym Fish",
"createFileQuestion": "What naym u want 4 teh new file?",
"createDirQuestion": "What naym u want 4 teh new directory?",
"renameItemQuestion": "What should teh new naym be?",
"deleteItemQuestion": "Are u sure u want 2 delete \" + name + \"?",
"deleteItemQuestionMessage": "Ur deleting \\\"\" + path + \"\\\"!<br/><br/>Dis achshun will be ireeversibible an beh lozt forevr (longir than kittehz napz)",
"yesDelete": "Yis, I promize I understanth teh consequencez",
"noDelete": "Get me outta herez!",
"unsupportedLanguage": "Warning: Dis no be sumtin I can readz (file typ badz)",
"keybindings": "Pawbindz",
"fileReadError": "I can no readz... oof",
"upload": "Give fish",
"unzip": "Maek Unsmol",
"clickUpload": "Click her 2 select Ur fish",
"uploadTitle": "Upload fish 2: ",
"waitUpload": "Plz be paitentz we gib ur fish 2 de servr... Dis may take a while.",
"stayHere": "U MUST STAY HERE, PLZ DNT GO!",
"close": "Plz stahp",
"download": "Take fish"
},
"serverConfig": {
"serverName": "Server Naym",
"serverNameDesc": "Wat u wish 2 nayem dis server",
"serverPath": "Servr Wrking Dir",
"serverPathDesc": "Absolutley full peth (not including eggs-cute-able)",
"serverLogLocation": "Servr Log Location",
"serverLogLocationDesc": "Absolutley full peth 2 teh log fish",
"serverExecutable": "Servr Eggs-cute-able",
"serverExecutableDesc": "Teh server's fish dat mak hing go brr",
"serverExecutionCommand": "Servr Eggs-cute Cmd",
"serverExecutionCommandDesc": "Wat 2 do in a secret unseen terminal",
"serverStopCommand": "Servr Stahp Cmd",
"serverStopCommandDesc": "Comarned 2 send teh program 2 stop it",
"serverAutostartDelay": "Servr yawn Delay",
"serverAutostartDelayDesc": "How loz 2 stay in bedz b4 mak go servr (If yis below)",
"serverIP": "Servr IP",
"serverIPDesc": "IP Cwafty should mak connecshun 2 fur stats (Try a real ip, no 127.0.0.1 if u hav issues)",
"serverPort": "Servr Catflap",
"serverPortDesc": "Catflap Cwafty wud use to fur stats",
"removeOldLogsAfter": "Burry Old Logz After",
"removeOldLogsAfterDesc": "How lotz in dais will a log file has 2 be 2 to git burriedz (0 iz 'treasure 4 evr')",
"serverAutoStart": "Servr auto brrr",
"serverCrashDetection": "Know when servr go OOF...",
"save": "Dun",
"cancel": "Stahp",
"deleteServer": "Eat Server",
"stopBeforeDeleting": "Plz stop teh servr b4 you eatz it",
"exeUpdateURLDesc": "Fast URL to get new fish to updatz servr (Many cat go dis peth, very dirct).",
"exeUpdateURL": "Server Eggs-cuta-ble Update Direct URL",
"update": "Update Eggs-cuta-ble",
"bePatientUpdate": "Plz be paitentz we get teh newz server. Hunting teimz can vary if ur interwebz iz poop.<br /> Dis scrien will refresh soonz",
"sendingRequest": "Screaming @ catz wif ur request...",
"deleteServerQuestion": "I can eatz Servr?",
"deleteServerQuestionMessage": "R u sure u wants me 2 eat dis servr? After I eats tehre iz no go bak...",
"yesDelete": "Yis, eat it",
"noDelete": "No no no, pls go bak",
"deleteFilesQuestion": "Eat servr fish too?",
"deleteFilesQuestionMessage": "Wud u liek Cwafty 2 eat aw da fish dat wis in da servr? Wial beh lozt forevr (longir than kittehz napz)",
"yesDeleteFiles": "Yis, eat dem fishies",
"noDeleteFiles": "No, jst eat teh panelz",
"sendingDelete": "Okei I eatz Servr, yummi",
"bePatientDelete": "Plz be paitent I eat ur servr. Dis scrien will refresh soonz",
"bePatientDeleteFiles" : "Plz be paitent I eat ur servr an eat aw teh yummi fish. Dis scrien will refresh soonz"
},
"serverConfigHelp": {
"title": "Server Config Area",
"desc": "Here iz where u can change teh configuration of your server (Character break dis importantz)",
"perms": [
"It iz recommended 2 <code>NOT</code> change teh peths of a servr managed by Cwafty. DIS IS BAD JUJU",
"Changing peths <code>CAN</code> break things, especially on Linux typ operatin systems where file permissions are more locked down.",
"<br /><br/>",
"If u feel u hav 2 change where a server iz located u may do so as long as you give teh \"crafty\" user permission to read / write to teh server peth.",
"<br />",
"<br />",
"On Linux dis iz best done by executing teh following:<br />",
"<code>",
" sudo chown crafty:crafty /path/to/your/server -R<br />",
" sudo chmod 2775 /path/to/your/server -R<br />",
"</code>"
]
},
"panelConfig": {
"save": "Dun",
"cancel": "Stahp",
"delete": "Delet"
},
"datatables": {
"i18n": {
"decimal": "",
"emptyTable": "No data available in table",
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty": "Showing 0 to 0 of 0 entries",
"infoFiltered": "(filtered from _MAX_ total entries)",
"infoPostFix": "",
"thousands": ",",
"lengthMenu": "Show _MENU_ entries",
"loadingRecords": "Loading...",
"processing": "Processing...",
"search": "Search:",
"zeroRecords": "No matching records found",
"paginate": {
"first": "First",
"last": "Last",
"next": "Next",
"previous": "Previous"
},
"aria": {
"sortAscending": ": activate to sort column ascending",
"sortDescending": ": activate to sort column descending"
},
"buttons": {
"collection": "Collection <span class='ui-button-icon-primary ui-icon ui-icon-triangle-1-s'\/>",
"colvis": "Column Visibility",
"colvisRestore": "Restore visibility",
"copy": "Copy",
"copyKeys": "Press ctrl or u2318 + C to copy teh table data to your system clipboard.<br><br>To cancel, click this message or press escape.",
"copySuccess": {
"1": "Copied 1 row to clipboard",
"_": "Copied %d rows to clipboard"
},
"copyTitle": "Copy to Clipboard",
"csv": "CSV",
"excel": "Excel",
"pageLength": {
"-1": "Show all rows",
"1": "Show 1 row",
"_": "Show %d rows"
},
"pdf": "PDF",
"print": "Print"
},
"select": {
"rows": {
"0": "Click on a row to select it",
"1": "%d row selected",
"_": "%d rows selected"
},
"cells": {
"0": "Click on a cel to select it",
"1": "%d cell selected",
"_": "%d cells selected"
},
"columns": {
"0": "Click on a column to select it",
"1": "%d column selected",
"_": "%d columns selected"
}
}
}
},
"base": {
"doesNotWorkWithoutJavascript": "<strong>Warning: </strong>CWafty don't go brrrr wen JafarScwipt isn't der, U SHULD GET IT"
}
}

View File

@ -137,9 +137,6 @@ if __name__ == '__main__':
# refresh our cache and schedule for every 12 hoursour cache refresh for serverjars.com
tasks_manager.serverjar_cache_refresher()
# this should always be last
tasks_manager.start_main_kill_switch_watcher()
logger.info("Checking Internet/Port Service. This may take a minute.")
console.info("Checking Internet/Port Service. This may take a minute.")

View File

@ -2,6 +2,7 @@ cryptography~=3.4
argon2-cffi~=20.1
bleach~=3.1
colorama~=0.4
cryptography~=3.4
peewee~=3.13
pexpect~=4.8
psutil~=5.7