Exemple #1
0
def init():
    # Config.show_keep_alive_after_idle = 1
    Config = Factory.get('Config')
    Lang = Factory.get('Translation')
    try:
        Config.printSettings()
        Db.init()

        if not ServerControl.is_server_running():
            out(Lang.get('server_not_running'))
            ServerControl.start_server()

        custom_import(Config.events_config, 'events')  #Load events

        Rcon.init(Config.rcon_host, Config.rcon_port, Config.query_port,
                  Config.rcon_password, Config.rcon_socket_timeout)

        InputHandler.init()  #Activate listening for terminal input

        #custom_import(Config.events_config,'input') #Load terminal input configuration
        custom_import(Config.tasks_config, 'tasks')  #Load tasks

        # Prevent threads from dying due to early main completed execution.
        while True:
            if Storage.terminate_application is True:
                exit()
            time.sleep(1)  # Important part of not being a CPU hog.

    except KeyboardInterrupt:
        Storage.terminate_application = True
Exemple #2
0
    def callback_restart(cls,*args):
        """ Callback for broadcast on immediate restarts

        Broadcast does not happen if you restart immedietly
        """
        out('Issuing IMMEDIDATE server restart')
        ServerControl.restart_server()
Exemple #3
0
        def delayed_message(minutes,message=""):
            if minutes == 60:
                cls.broadcast(Lang.get('restart_default').format('60 minutes',message), cls.response_callback_response_only)
                time.sleep(30*60)
                minutes = 30

            if minutes == 30:
                cls.broadcast(Lang.get('restart_default').format('30 minutes',message), cls.response_callback_response_only)
                time.sleep(20*60)
                minutes = 10

            if minutes == 10:
                cls.broadcast(Lang.get('restart_default').format('10 minutes',message), cls.response_callback_response_only)
                time.sleep(5*60)

            cls.broadcast(Lang.get('restart_default').format('5 minutes',message), cls.response_callback_response_only)
            time.sleep(4*60)

            cls.broadcast(Lang.get('restart_default').format('60 seconds',message), cls.response_callback_response_only)
            time.sleep(50)

            cls.broadcast(Lang.get('restart_default').format('10 seconds',message), cls.response_callback_response_only)
            time.sleep(10)

            Storage.restart_timestamp = None
            ServerControl.restart_server()
Exemple #4
0
def init():
    # Config.show_keep_alive_after_idle = 1
    Config = Factory.get('Config')
    Lang = Factory.get('Translation')
    try:
        Config.printSettings()
        Db.init()

        if not ServerControl.is_server_running():
            out(Lang.get('server_not_running'))
            ServerControl.start_server()

        custom_import(Config.events_config,'events') #Load events

        Rcon.init(Config.rcon_host, Config.rcon_port, Config.query_port, Config.rcon_password, Config.rcon_socket_timeout)

        InputHandler.init() #Activate listening for terminal input

        #custom_import(Config.events_config,'input') #Load terminal input configuration
        custom_import(Config.tasks_config,'tasks') #Load tasks

        # Prevent threads from dying due to early main completed execution.
        while True:
            if Storage.terminate_application is True:
                exit()
            time.sleep(1)  # Important part of not being a CPU hog.

    except KeyboardInterrupt:
        Storage.terminate_application = True
Exemple #5
0
 def admin_update_now(steam_name,player_name,text):
     if not Rcon.is_admin(steam_name=steam_name):
         out(Lang.get('unauthorized'), text)
         return False
     res, live_version, steam_version = ServerControl.new_version()
     if res is True:
         ServerControl.update_and_restart_server()
         Rcon.message_steam_name(steam_name,Lang.get('update_restart'))
         Rcon.broadcast(Lang.get('update_restart'), Rcon.response_callback_response_only)
         return True
     else:
         Rcon.message_steam_name(steam_name,Lang.get('no_new_version'))
         return False
Exemple #6
0
    def parse(steam_name,player_name,text):
        #recipient = Db.find_player(player_name=player_name)
        cmd = ChatCommands._find_cmd(text)
        if cmd is False:
            debug_out(Lang.get('not_a_command').format(text),level=1)
            return False
        
        cmd = cmd.lower()
        debug_out('Processing chat command: ',cmd,level=1)
        if cmd == 'lastseen':
            ChatCommands.last_seen(steam_name,text)
            return True
        elif cmd == 'online':
            ChatCommands.list_online(steam_name)
            return True
        elif cmd == 'admin_restart':
            if not Rcon.is_admin(steam_name=steam_name):
                out(Lang.get('unauthorized'), cmd)
                return False

            if text.lower().strip() == '!admin_restart now':
                Rcon.message_steam_name(steam_name,Lang.get('issue_restart_now'))
                Rcon.broadcast(Lang.get('restarting'))
                ServerControl.restart_server()
                return True

            regex = re.compile('!admin_restart (?P<minutes>[\d]+)',re.IGNORECASE)
            matches = regex.search(text)
            if matches is None:
                Rcon.message_steam_name(steam_name,Lang.get('admin_restart_failed'))
                return False

            minutes = matches.group('minutes')

            result, err = Rcon.delayed_restart(minutes)
            if not result:
                Rcon.message_steam_name(steam_name,'ERROR: {}'.format(err))
                return False

            Rcon.message_steam_name(steam_name,Lang.get('issue_restart'))
            return True
        elif cmd == 'next_restart':
            seconds_left, str_countdown = Rcon.get_next_restart_string()
            response = 'Next restart: {}'.format(str_countdown)
            Rcon.message_steam_name(steam_name,response)
            return True
        elif cmd == 'help':
            Rcon.message_steam_name(steam_name,Lang.get('chat_help'))
            return True
        return False
Exemple #7
0
 def store_settings_to_db(cls):
     config = ServerControl.get_config()
     Db.website_data_set('Game.ini',config['Game.ini'])
     Db.website_data_set('GameUserSettings.ini',config['GameUserSettings.ini'])
     data = Rcon.query_server()
     Db.website_data_set('game_version',data['game_version'])
     out('Settings uploaded to database.')
Exemple #8
0
 def store_settings_to_db(cls):
     config = ServerControl.get_config()
     Db.website_data_set('Game.ini', config['Game.ini'])
     Db.website_data_set('GameUserSettings.ini',
                         config['GameUserSettings.ini'])
     data = Rcon.query_server()
     Db.website_data_set('game_version', data['game_version'])
     out('Settings uploaded to database.')
Exemple #9
0
    def reconnect(cls):
        cls.is_reconnecting = True
        cls.is_connected = False
        cls.close_socket()
        cls.incoming_packets.clear()
        if not ServerControl.is_server_running():
            out('Waiting for connection to query port.')
            while not ServerControl.is_server_running():
                time.sleep(1)
            out('Query successful.')

        result, err = cls.socket_connect(cls.socket_host, cls.socket_port, cls.socket_query_port, cls.password, cls.socket_timeout)
        while not result:
            out('Retrying reconnect in {}s'.format(Config.reconnect_wait))
            time.sleep(Config.reconnect_wait)
            result, err = cls.socket_connect(cls.socket_host, cls.socket_port, cls.socket_query_port, cls.password, cls.socket_timeout)

        cls.is_reconnecting = False
Exemple #10
0
    def socket_connect(cls, host, port, query_port, password=None, timeout=None):
        if not ServerControl.is_server_running():
            out('Waiting for connection to query port.')
            while not ServerControl.is_server_running():
                time.sleep(1)
            out('Query successful.')

        out('Connecting to {}:{}...'.format(host, port))
        cls.timestamp_transmission_opened = time.time()
        result, err = super().socket_connect(host, port, query_port, password, timeout)
        if result:
            out('Connected!')
            result, err = cls.socket_auth(password)
            if not result:
                return result, err
        else:
            out('Unable to connect: ', err)

        return result, err
Exemple #11
0
    def socket_connect(cls, host, port, query_port, password=None, timeout=None):
        if not ServerControl.is_server_running():
            out('Waiting for connection to query port.')
            while not ServerControl.is_server_running():
                time.sleep(1)
            out('Query successful.')

        out('Connecting to {}:{}...'.format(host, port))
        cls.timestamp_transmission_opened = time.time()
        result, err = super().socket_connect(host, port, query_port, password, timeout)
        if result:
            out('Connected!')
            result, err = cls.socket_auth(password)
            if not result:
                return result, err
        else:
            out('Unable to connect: ', err)

        return result, err
Exemple #12
0
 def admin_check_version(steam_name,player_name,text):
     if not Rcon.is_admin(steam_name=steam_name):
         out(Lang.get('unauthorized'), text)
         return False
     res, live_version, steam_version = ServerControl.new_version()
     if res is True:
         Rcon.message_steam_name(steam_name,Lang.get('new_version'))
         return True
     else:
         Rcon.message_steam_name(steam_name,Lang.get('no_new_version'))
         return False
Exemple #13
0
    def reconnect(cls):
        cls.is_reconnecting = True
        cls.is_connected = False
        cls.close_socket()
        cls.incoming_packets.clear()
        if not ServerControl.is_server_running():
            out('Waiting for connection to query port.')
            while not ServerControl.is_server_running():
                time.sleep(1)
            out('Query successful.')

        result, err = cls.socket_connect(cls.socket_host, cls.socket_port,
                                         cls.socket_query_port, cls.password,
                                         cls.socket_timeout)
        while not result:
            out('Retrying reconnect in {}s'.format(Config.reconnect_wait))
            time.sleep(Config.reconnect_wait)
            result, err = cls.socket_connect(cls.socket_host, cls.socket_port,
                                             cls.socket_query_port,
                                             cls.password, cls.socket_timeout)

        cls.is_reconnecting = False
Exemple #14
0
        def delayed_message(minutes, message=""):
            if minutes == 60:
                cls.broadcast(
                    Lang.get('restart_default').format('60 minutes', message),
                    cls.response_callback_response_only)
                time.sleep(30 * 60)
                minutes = 30

            if minutes == 30:
                cls.broadcast(
                    Lang.get('restart_default').format('30 minutes', message),
                    cls.response_callback_response_only)
                time.sleep(20 * 60)
                minutes = 10

            if minutes == 10:
                cls.broadcast(
                    Lang.get('restart_default').format('10 minutes', message),
                    cls.response_callback_response_only)
                time.sleep(5 * 60)

            cls.broadcast(
                Lang.get('restart_default').format('5 minutes', message),
                cls.response_callback_response_only)
            time.sleep(4 * 60)

            cls.broadcast(
                Lang.get('restart_default').format('60 seconds', message),
                cls.response_callback_response_only)
            time.sleep(50)

            cls.broadcast(
                Lang.get('restart_default').format('10 seconds', message),
                cls.response_callback_response_only)
            time.sleep(10)

            Storage.restart_timestamp = None
            ServerControl.restart_server()
 def run():
     if ServerControl.new_version() is True:
         EventHandler.triggerEvent(EventHandler.E_NEW_ARK_VERSION)
     else:
         debug_out('No server update available', level=3)
 def run():
     if ServerControl.new_version() is True:
         EventHandler.triggerEvent(EventHandler.E_NEW_ARK_VERSION)
     else:
         debug_out('No server update available',level=3)