def fix_permissions(path): try: if os.path.isdir(path): log.debug(f"Fix permissions recursively for directory {path}") run_shell_command_as_user(f"chown -R arkserver:arkserver {path}", user='******') else: log.debug(f"Fix permissions for file {path}") run_shell_command_as_user(f"chown arkserver:arkserver {path}", user='******') return True except: log.error("Unable to fix mod permissions.", exc_info=True) return False
def update_server(*args, **kwargs): log.info("Updating...") # steamcmd = """/home/arkserver/arkserver update""" # Had an issue with SteamCMD failing to check new version # while Arkbot was able to detect new version. Force update makes more sense this way. steamcmd = """/home/arkserver/arkserver force-update""" cmd_out = run_shell_command_as_user(steamcmd) log.info(str(cmd_out))
def download_mods(self, modids): args = [ os.path.join(self.steamcmd_directory, STEAMCMD_SCRIPT), "+login anonymous" ] for modid in modids: args.extend(["+workshop_download_item", "346110", modid]) args.append("+quit") try: log.debug(f"Downloading mods: {args}") return run_shell_command_as_user( args) == 0 #subprocess.call(args) == 0 except Exception as e: log.error("Could not start steamcmd to download mods:\n" + str(e)) sys.exit(1)
def reboot_server(): log.info("Rebooting...") steamcmd = """reboot now""" cmd_out = run_shell_command_as_user(steamcmd, user='******') log.info(str(cmd_out))
def start_server(): log.info("Starting...") steamcmd = """/home/arkserver/arkserver start""" cmd_out = run_shell_command_as_user(steamcmd) log.info(str(cmd_out))
def update_server(*args, **kwargs): log.info("Updating...") steamcmd = """/home/arkserver/arkserver update""" cmd_out = run_shell_command_as_user(steamcmd) log.info(str(cmd_out))