1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jellyfin-vue_ynh.git synced 2024-09-03 19:26:31 +02:00
jellyfin-vue_ynh/scripts/_common.sh

71 lines
1.9 KiB
Bash
Raw Normal View History

2023-09-01 22:50:48 +02:00
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
2023-11-03 11:57:04 +01:00
nodejs_version=20
2023-09-01 22:50:48 +02:00
#=================================================
# PERSONAL HELPERS
#=================================================
_patch_config_json() {
sourcedir=$1
# Required for sub-path installation
sed -i \
"s|'/config.json'|import.meta.env.BASE_URL + 'config.json'|" \
"$1/frontend/src/utils/external-config.ts"
}
_npm_build_install() {
sourcedir=$1
targetdir=$2
subpath=$3
2023-11-03 13:11:43 +01:00
ynh_use_nodejs
pushd "$sourcedir/frontend" || ynh_die "Could not pushd $sourcedir/frontend"
2023-09-01 22:50:48 +02:00
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" \
2023-11-03 13:05:06 +01:00
"$ynh_npm" ci --no-audit --ignore-scripts
2023-09-01 22:50:48 +02:00
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" \
2023-11-03 13:11:43 +01:00
"$ynh_npm" run build
ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" \
"$ynh_npm" cache clean --force
2023-09-01 22:50:48 +02:00
popd || ynh_die "Could not popd"
ynh_secure_remove --file="$targetdir"
2023-09-01 22:50:48 +02:00
mv "$sourcedir/frontend/dist" "$targetdir"
}
_list_jellyfin_urls() {
yunohost app list --full --json \
| jq -r '.apps[] | select(.manifest.id=="jellyfin") | .domain_path'
}
PYTHON_APPEND_TO_SERVER_URLS='
import sys
import json
file = sys.argv[1]
url = sys.argv[2]
with open(file, encoding="utf-8") as configfile:
data = json.load(configfile)
if url not in data["defaultServerURLs"]:
data["defaultServerURLs"].append(url)
with open(file, "w", encoding="utf-8") as configfile:
configfile.write(json.dumps(data, indent=2))
'
_append_to_server_urls() {
python3 -c "$PYTHON_APPEND_TO_SERVER_URLS" "$@"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================