def install(self, mod_pack, server_or_client): assert server_or_client in ("server","client") if not self.selected_for_install(server_or_client): print "Skipping {f} (optional or not required on {sc}).".format(f=self['install_filename'], sc=server_or_client) return if self['download_url_primary'] == "Download file manually": print "Not installing {f} automatically. Download it manually if you need it.".format(f=self['install_filename']) return self.validate_attributes() inst_path = os.path.join(mod_pack['install_folder'], self['install_path']) src_path = os.path.join(mod_pack['download_cache_folder'], self['install_filename']) mkdir(inst_path) if self['install_method'] == 'copy': print ("Installing {f} by copying to {d}".format(f=src_path, d=inst_path)) shutil.copy(src_path, inst_path) elif self['install_method'] == 'unzip': with ZipFile(src_path, 'r') as z: print ("Installing {f} by unzipping to {d}".format(f=src_path, d=inst_path)) z.extractall(inst_path) if self['special_actions'] == 'create_run_sh': if 'forge' in self['install_filename']: script_name = 'start_forge_server.sh' elif 'cauldron' in self['install_filename']: script_name = 'start_cauldron_server.sh' else: raise ValueError script = STARTUP_SCRIPT_TEMPLATE.format(fn=self['install_filename']) script_path = os.path.join(mod_pack['install_folder'],script_name) with open(script_path, 'w') as fh: fh.write(script)
def install_server(self): self.mod_files.append(self.minecraft_server_jar()) for f in self.mod_files: if not f['required_on_server']: # pass - note that currently, there are some files (i.e. authlib-1.5.13.jar) which don't have an install path, so can't be handled. continue try: f.validate_attributes() except AssertionError: print ("INSTALLATION FAILED - MOD FILE DEFINITION INVALID.") import pprint pprint.pprint(f) return 'FAILURE' print ('-') mkdir(self['download_cache_folder']) os.chdir(self['download_cache_folder']) f.download("server") mkdir(self['install_folder']) os.chdir(self['install_folder']) f.install(self, "server") print ('-\r\nWriting eula.txt') os.chdir(self['install_folder']) with open('eula.txt', 'w') as eula: eula.write("eula=true")
def install_server(self): self.mod_files.append(self.minecraft_server_jar()) for f in self.mod_files: if not f['required_on_server']: # pass - note that currently, there are some files (i.e. authlib-1.5.13.jar) which don't have an install path, so can't be handled. continue try: f.validate_attributes() except AssertionError: print("INSTALLATION FAILED - MOD FILE DEFINITION INVALID.") import pprint pprint.pprint(f) return 'FAILURE' print('-') mkdir(self['download_cache_folder']) os.chdir(self['download_cache_folder']) f.download("server") mkdir(self['install_folder']) os.chdir(self['install_folder']) f.install(self, "server") print('-\r\nWriting eula.txt') os.chdir(self['install_folder']) with open('eula.txt', 'w') as eula: eula.write("eula=true")
def main(operation, pack_name, pack_version, install_folder, cache_folder, share_code, dry_run): """A tool for installing and updating Minecraft servers based on ATLauncher mod packs. Example invocations: cat_herder.py list_packs Installing with share code: cat_herder.py install-from-share-code -s QtDNnlfZ As above, but manually specifying the download cache and server install folders: cat_herder.py install-from-share-code -s QtDNnlfZ -c /home/mc/cache -i /home/mc/install/ Installing with manually specified pack name and pack version: cat_herder.py install -p BevosTechPack -v BTP-11-Full -c /home/mc/cache -i /home/mc/install/ """ if install_folder: install_folder = os.path.realpath(install_folder) else: install_folder = os.path.realpath('./install/{pn}/{pv}'.format(pn=pack_name,pv=pack_version)) if cache_folder: cache_folder = os.path.realpath(cache_folder) else: cache_folder = os.path.realpath('./cache/') mkdir (cache_folder) os.chdir(cache_folder) packs_json = get_pack_json() pack_names = [p['name'] for p in packs_json] if operation == 'list_packs': list_packs(packs_json) if operation == 'update': print "Update not implemented yet." if operation == 'install': if not pack_version: pack_version = get_latest_pack_version (packs_json, pack_name) mp = atlauncher_to_catherder(pack_name, pack_version, cache_folder, install_folder) if dry_run: mp.print_mod_files_list() else: mp.install_server() if operation == 'install-from-share-code': if not share_code: print ("install-from-share-code option requires a share code to be specified using the -s option.") if not re.match("[A-Za-z0-9]{8}",share_code): print ("install-from-share-code requires an 8-character alphanumeric share code.") mp = get_mod_pack_with_share_code(share_code, cache_folder, install_folder) if dry_run: mp.print_mod_files_list() else: mp.install_server()
def install(self, mod_pack, server_or_client): assert server_or_client in ("server", "client") if not self.selected_for_install(server_or_client): print "Skipping {f} (optional or not required on {sc}).".format( f=self['install_filename'], sc=server_or_client) return if self['download_url_primary'] == "Download file manually": print "Not installing {f} automatically. Download it manually if you need it.".format( f=self['install_filename']) return self.validate_attributes() inst_path = os.path.join(mod_pack['install_folder'], self['install_path']) src_path = os.path.join(mod_pack['download_cache_folder'], self['install_filename']) mkdir(inst_path) if self['install_method'] == 'copy': print("Installing {f} by copying to {d}".format(f=src_path, d=inst_path)) shutil.copy(src_path, inst_path) elif self['install_method'] == 'unzip': with ZipFile(src_path, 'r') as z: print("Installing {f} by unzipping to {d}".format(f=src_path, d=inst_path)) z.extractall(inst_path) if self['special_actions'] == 'create_run_sh': if 'forge' in self['install_filename']: script_name = 'start_forge_server.sh' elif 'cauldron' in self['install_filename']: script_name = 'start_cauldron_server.sh' else: raise ValueError script = STARTUP_SCRIPT_TEMPLATE.format( fn=self['install_filename']) script_path = os.path.join(mod_pack['install_folder'], script_name) with open(script_path, 'w') as fh: fh.write(script)
def main(operation, pack_name, pack_version, install_folder, cache_folder, share_code, dry_run): """A tool for installing and updating Minecraft servers based on ATLauncher mod packs. Example invocations: cat_herder.py list_packs Installing with share code: cat_herder.py install-from-share-code -s QtDNnlfZ As above, but manually specifying the download cache and server install folders: cat_herder.py install-from-share-code -s QtDNnlfZ -c /home/mc/cache -i /home/mc/install/ Installing with manually specified pack name and pack version: cat_herder.py install -p BevosTechPack -v BTP-11-Full -c /home/mc/cache -i /home/mc/install/ """ if install_folder: install_folder = os.path.realpath(install_folder) else: install_folder = os.path.realpath('./install/{pn}/{pv}'.format( pn=pack_name, pv=pack_version)) if cache_folder: cache_folder = os.path.realpath(cache_folder) else: cache_folder = os.path.realpath('./cache/') mkdir(cache_folder) os.chdir(cache_folder) packs_json = get_pack_json() pack_names = [p['name'] for p in packs_json] if operation == 'list_packs': list_packs(packs_json) if operation == 'update': print "Update not implemented yet." if operation == 'install': if not pack_version: pack_version = get_latest_pack_version(packs_json, pack_name) mp = atlauncher_to_catherder(pack_name, pack_version, cache_folder, install_folder) if dry_run: mp.print_mod_files_list() else: mp.install_server() if operation == 'install-from-share-code': if not share_code: print( "install-from-share-code option requires a share code to be specified using the -s option." ) if not re.match("[A-Za-z0-9]{8}", share_code): print( "install-from-share-code requires an 8-character alphanumeric share code." ) mp = get_mod_pack_with_share_code(share_code, cache_folder, install_folder) if dry_run: mp.print_mod_files_list() else: mp.install_server()