def do_enable_autostart(self, line): if line == '': self.help_enable_autostart() return 0 try: int(line) except ValueError: console.error("Server ID must be a string") self.help_enable_autostart() return 0 try: server = MC_settings.get_by_id(line) except Exception as e: console.help("Unable to find a server with that ID: {}".format(e)) return 0 server = int(line) MC_settings.update({ MC_settings.auto_start_server: True }).where(MC_settings.id == server).execute() logger.info( "Enabled Autostart for Server {} via the console".format(server)) console.info("Enabled Autostart for Server {} ".format(server))
def do_restart(self, line): if line == '': self.help_start() return 0 try: int(line) except ValueError: console.error("Server ID must be a number") self.help_start() return 0 try: server = MC_settings.get_by_id(line) except Exception as e: console.help("Unable to find a server with that ID: {}".format(e)) return 0 server = int(line) Remote.insert({ Remote.command: 'restart_mc_server', Remote.server_id: server, Remote.command_source: "localhost" }).execute() console.info("Restarting Minecraft Server in background")
def do_change_web_port(self, line): if int(line) > 65535: console.error("Invalid Port") return False if int(line) < 1: console.error("Invalid Port") return False Webserver.update({Webserver.port_number: int(line)}).execute() console.info("Tornado Webserver Port set to port: {}".format(line))
def do_start(self, line): if line == '': self.help_start() return 0 try: int(line) except ValueError: console.error("Server ID must be a number") self.help_start() return 0 try: server = MC_settings.get_by_id(line) except Exception as e: console.help("Unable to find a server with that ID: {}".format(e)) return 0 server = int(line) if helper.is_setup_complete(): srv_obj = multi.get_server_obj(server) if srv_obj.check_running(): console.warning("Server already running") else: console.info("Starting Minecraft Server in background") Remote.insert({ Remote.command: 'start_mc_server', Remote.server_id: server, Remote.command_source: "localhost" }).execute() else: console.warning( "Unable to start server, please complete setup in the web GUI first" )
def do_stop(self, line): if line == '': self.help_stop() return 0 try: int(line) except ValueError: console.error("Server ID must be a number") self.help_stop() return 0 try: server = MC_settings.get_by_id(line) except Exception as e: console.help("Unable to find a server with that ID: {}".format(e)) return 0 server = int(line) if helper.is_setup_complete(): srv_obj = multi.get_server_obj(server) if not srv_obj.check_running(): console.warning("Server already stopped") else: console.info("Stopping Minecraft Server") multi.stop_server(server) ''' Remote.insert({ Remote.command: 'stop_mc_server' }).execute() ''' else: console.warning( "Unable to stop server, please complete setup in the web GUI first" )
def do_set_passwd(self, line): try: user = Users.get(Users.username == line).username except: console.error("User: {} Not Found".format(line)) return False new_pass = input("NEW password for: {} > ".format(user)) if len(new_pass) > 512: console.warning("Password Too Long") return False if len(new_pass) < 6: console.warning("Password Too Short") return False Users.update({ Users.password: helper.encode_pass(new_pass) }).where(Users.username == user).execute() console.info("Password for {} is now set to {}".format(user, new_pass))
def do_revert_server_jar(self, line): if line == '': self.help_update_server_jar() return 0 try: int(line) except ValueError: console.error("Server ID must be a number") self.help_update_server_jar() return 0 try: server = MC_settings.get_by_id(line) except Exception as e: console.help("Unable to find a server with that ID: {}".format(e)) return 0 server = int(line) if helper.is_setup_complete(): srv_obj = multi.get_server_obj(server) console.info("Reverting updated Server Jar in background") Remote.insert({ Remote.command: 'revert_server_jar_console', Remote.server_id: server, Remote.command_source: "localhost" }).execute() else: console.warning( "Unable to update server jar, please complete setup in the web GUI first" )