From cdf518312736873b37ef106c9f098c045967dfaa Mon Sep 17 00:00:00 2001 From: gilbn Date: Sun, 10 Jul 2022 15:30:20 +0200 Subject: [PATCH 1/3] add mods to json file --- themes.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/themes.py b/themes.py index 1417623d..b50e8599 100644 --- a/themes.py +++ b/themes.py @@ -61,7 +61,7 @@ def create_addons_json(): return dumps(ADDONS, sort_keys=True) -def create_json(app_folders: list = None, themes: list = None, community_themes: list = None, no_sub_folders=False): +def create_json(app_folders: list = None, themes: list = None, community_themes: list = None ,docker_mods: list = None, no_sub_folders=False) -> str: if no_sub_folders: THEMES_DICT = {} theme_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/theme-options/*.css"]) if isdir(".git") else [] @@ -71,12 +71,12 @@ def create_json(app_folders: list = None, themes: list = None, community_themes: THEMES = { theme.split(".")[0].capitalize(): { "url": f"{scheme}://{DOMAIN}/css/theme-options/{theme}?sha={THEME_SHAS.get(theme)}" - }for theme in themes + }for theme in themes if themes } COMMUNITY_THEMES = { theme.split(".")[0].capitalize(): { "url": f"{scheme}://{DOMAIN}/css/community-theme-options/{theme}?sha={COMMUNITY_THEME_SHAS.get(theme)}" - }for theme in community_themes + }for theme in community_themes if community_themes } THEMES_DICT.update(dict(sorted({ "themes": { @@ -111,12 +111,17 @@ def create_json(app_folders: list = None, themes: list = None, community_themes: } for app in app_folders if isfile(f'./css/base/{app}/.deprecated') } }.items()))) + APPS.update(dict(sorted({ + "docker-mods": { + mod: f"{scheme}://{DOMAIN}/docker-mods/{mod}/root/etc/cont-init.d/98-themepark" for mod in docker_mods if docker_mods + } + }.items()))) THEMES = loads(create_json(themes=themes, community_themes=community_themes, no_sub_folders=True)) APPS.update(ADDONS) APPS.update(THEMES) return dumps(APPS) -def create_theme_options(): +def create_theme_options() -> None: app_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/base/*base.css"]) if isdir(".git") else [] theme_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/theme-options/*.css"]) if isdir(".git") else [] community_theme_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/community-theme-options/*.css"]) if isdir(".git") else [] @@ -145,6 +150,7 @@ scheme = env.get('TP_SCHEME','https') if env.get('TP_SCHEME') else 'https' if __name__ == "__main__": app_folders = [name for name in listdir('./css/base') if isdir(join('./css/base', name))] themes = [name for name in listdir('./css/theme-options') if isfile(join('./css/theme-options', name))] + docker_mods = [name for name in listdir('./docker-mods') if isdir(join('./docker-mods', name))] community_themes = [name for name in listdir('./css/community-theme-options') if isfile(join('./css/community-theme-options', name))] develop = True if isdir(".git") and subprocess.check_output(["git", "symbolic-ref", "--short", "HEAD"]).decode('ascii').strip() == "develop" else False if env_domain: @@ -153,7 +159,7 @@ if __name__ == "__main__": with open("CNAME", "rt", closefd=True) as cname: CNAME = cname.readline() DOMAIN = CNAME if not develop else f"develop.{CNAME}" - apps = loads(create_json(app_folders=app_folders, themes=themes, community_themes=community_themes)) + apps = loads(create_json(app_folders=app_folders, themes=themes, community_themes=community_themes, docker_mods=docker_mods)) with open("themes.json", "w") as outfile: dump(apps, outfile, indent=2, sort_keys=True) create_theme_options() \ No newline at end of file From a4f2b2da549ebceb7d60a29f18cd9381891a77e2 Mon Sep 17 00:00:00 2001 From: GilbN Date: Sun, 10 Jul 2022 18:39:49 +0200 Subject: [PATCH 2/3] Add docker mods fetch script --- docker-mods/fetch.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docker-mods/fetch.sh diff --git a/docker-mods/fetch.sh b/docker-mods/fetch.sh new file mode 100644 index 00000000..b545c139 --- /dev/null +++ b/docker-mods/fetch.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +MODS=$(curl https://develop.theme-park.dev/themes.json | jq -r '.["docker-mods"]') +if [[ "$0" == "bash" ]]; then + DIR="/tmp/theme-park-mods" +else + DIR="$0" +fi +mkdir -p "$DIR" +printf "\nSaving mods into $DIR\n\n" +jq -r 'to_entries | map(.key + "|" + (.value | tostring)) | .[]' <<< "$MODS" | \ + while IFS='|' read key value; do + curl "$value" --create-dirs --output "$DIR/$key" --silent + echo "Fetched $key script" + done +sudo chmod go+rx $DIR \ No newline at end of file From ae571bfccd6f5d557e144448e514c516f28a67a1 Mon Sep 17 00:00:00 2001 From: Marius <24592972+gilbN@users.noreply.github.com> Date: Sun, 10 Jul 2022 18:49:03 +0200 Subject: [PATCH 3/3] move script out of docker.mods folder --- docker-mods/fetch.sh => fetch.sh | 1 + 1 file changed, 1 insertion(+) rename docker-mods/fetch.sh => fetch.sh (88%) diff --git a/docker-mods/fetch.sh b/fetch.sh similarity index 88% rename from docker-mods/fetch.sh rename to fetch.sh index b545c139..9f137ab3 100644 --- a/docker-mods/fetch.sh +++ b/fetch.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# Downloads all docker mod scripts MODS=$(curl https://develop.theme-park.dev/themes.json | jq -r '.["docker-mods"]') if [[ "$0" == "bash" ]]; then