def default(self): config = Configuration() if self.app.pargs.qldir is not None: config.set('dir', 'ql', os.path.expanduser(self.app.pargs.qldir)) if self.app.pargs.steamdir is not None: config.set('dir', 'steamcmd', os.path.expanduser(self.app.pargs.steamdir)) if self.app.pargs.servers is not None: config.set('config', 'servers', os.path.expanduser(self.app.pargs.servers)) if self.app.pargs.supervisor is not None: config.set('supervisor', 'supervisor', os.path.expanduser(self.app.pargs.supervisor)) if self.app.pargs.supervisorctl is not None: config.set('supervisor', 'supervisorctl', os.path.expanduser(self.app.pargs.supervisorctl)) if self.app.pargs.rcon is not None: config.set('config', 'rcon', os.path.expanduser(self.app.pargs.rcon)) config.update() data = [('QLDS dir', config.get('dir', 'ql')), ('SteamCMD dir', config.get('dir', 'steamcmd')), ('Supervisor', config.get('supervisor', 'supervisor')), ('Supervisorctl', config.get('supervisor', 'supervisorctl')), ('Servers config', config.get('config', 'servers')), ('Rcon config', config.get('config', 'rcon'))] for d in data: print('%s:\n %s' % d) print('Configuration updated')
class DownloadController(ManagerDefaultController): steamcmd_url = 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz' steamcmd_archive = '/steamcmd.tar.gz' ql_appid = 349090 config = Configuration() class Meta: label = 'download' description = 'Allows to download/update SteamCMD and QL Dedicated Server files' arguments = [(['--items'], dict(help='Workshop item ids (separated by space)', nargs='*'))] @expose(hide=True) def default(self): self.app.args.parse_args(['--help']) @expose(help='Downloads and installs SteamCMD') def steamcmd(self): steamcmd_dir = os.path.expanduser(self.config.get('dir', 'steamcmd')) steamcmd_dir_fs = FSCheck(steamcmd_dir, 'SteamCMD dir') #check if steamcmd dir exists if steamcmd_dir_fs.exists(error=False): print( '% exists. Remove it or change SteamCMD location in settings' % steamcmd_dir) exit(21) os.makedirs(steamcmd_dir) steamcmd_dir_fs.access('w') #check for write access in dir print('Downloading SteamCMD archive') urlretrieve(self.steamcmd_url, steamcmd_dir + self.steamcmd_archive) print('Extracting SteamCMD atchive to %s' % steamcmd_dir) archive = tarfile.open(steamcmd_dir + self.steamcmd_archive) archive.extractall(steamcmd_dir) steamcmd_stat = os.stat(steamcmd_dir + '/steamcmd.sh') os.chmod( steamcmd_dir + '/steamcmd.sh', steamcmd_stat.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) print('SteamCMD installed in %s' % steamcmd_dir) print('Remember that you need "lib32stdc++6" installed in your system') @expose(help='Downloads and updates QL Dedicated Server files') def ql(self): steamcmd = self.__steam_exists() print('Downloading QL Dedicated Server files using SteamCMD...') call([ steamcmd, '+login', 'anonymous', '+force_install_dir', os.path.expanduser(self.config.get('dir', 'ql')), '+app_update', str(self.ql_appid), '+quit' ]) @expose(help='Downloads or updates specified workshop items') def workshop(self): steamcmd = self.__steam_exists() if not self.app.pargs.items: print('You have to define items using "--items"') else: for item in self.app.pargs.items: call([ steamcmd, '+login', 'anonymous', '+workshop_download_item', str(self.ql_appid), '+app_update', item, '+quit' ]) def __steam_exists(self): steamcmd = os.path.expanduser( self.config.get('dir', 'steamcmd') + '/steamcmd.sh') steamcmd_fs = FSCheck(steamcmd, 'SteamCMD') steamcmd_fs.exists() steamcmd_fs.access('x') return steamcmd
__import__(module_name) except ImportError: return False else: return True commands = [ default.ManagerBaseController, version.VersionController, configure.ConfigureController, download.DownloadController, #download.DownloadWorkshopController, ] config = Configuration() supervisor_fs = FSCheck(config.get('supervisor', 'supervisor')) supervisorctl_fs = FSCheck(config.get('supervisor', 'supervisorctl')) if (supervisor_fs.exists(error=False) and supervisor_fs.access('x', error=False) and supervisorctl_fs.exists(error=False) and supervisorctl_fs.access('x', error=False)): from qldsmanager.command import server from qldsmanager.command import supervisor commands.append(server.ServerController) commands.append(supervisor.SupervisorController) if module_exists('zmq'):
def __init__(self): self.__config = Configuration() self.process_prefix = 'qlds_' self.__config_file = self.__config.get_config_dir( ) + '/supervisor.conf'