diff --git a/conf/nginx.conf b/conf/nginx.conf index 076c7d0..74fc6a8 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,12 +2,12 @@ location __PATH__/ { # Path to source - alias __INSTALL_DIR__/; + alias __INSTALL_DIR__/www/; - try_files $uri /index.html; + try_files $uri __PATH__/index.html; - location ~ ^.*/olm.wasm$ { - try_files $uri /olm.wasm; + location ~ ^__PATH__/.*/olm.wasm$ { + try_files $uri __PATH__/olm.wasm; } # From upstream, FIXME: not needed? diff --git a/manifest.toml b/manifest.toml index 5bab3b9..01c5f71 100644 --- a/manifest.toml +++ b/manifest.toml @@ -63,10 +63,9 @@ ram.runtime = "50M" [resources.sources] [resources.sources.main] - url = "https://github.com/cinnyapp/cinny/releases/download/v4.1.0/cinny-v4.1.0.tar.gz" - sha256 = "64bce650b1d5ee281e215f732fa40e40e2d38ebf8c2a8ed87ca0ae9ebe5ed788" + url = "https://github.com/ajbura/cinny/archive/refs/tags/v4.1.0.tar.gz" + sha256 = "468e7f769b68d81b8681647a84c5783f4683f1b75bcadf9eca99575f5f1de01b" autoupdate.strategy = "latest_github_release" - autoupdate.asset = "cinny-v.*.tar.gz$" [resources.system_user] diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..502358f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,10 +4,39 @@ # COMMON VARIABLES #================================================= +nodejs_version=20 + #================================================= # PERSONAL HELPERS #================================================= +_patch_build_config() { + sourcedir=$1 + + # Required for sub-path installation + sed -i \ + "s|base: '.*'|base: '$path'|" \ + "$1/build.config.ts" +} + +_npm_build_install() { + sourcedir=$1 + targetdir=$2 + + ynh_use_nodejs + pushd "$sourcedir" || ynh_die "Could not pushd $sourcedir" + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" \ + "$ynh_npm" ci + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" \ + "$ynh_npm" --max-old-space-size=4096 run build + ynh_exec_warn_less ynh_exec_as "$app" env "$ynh_node_load_PATH" \ + "$ynh_npm" cache clean --force + popd || ynh_die "Could not popd" + + ynh_secure_remove --file="$targetdir" + mv "$sourcedir/dist" "$targetdir" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 52eea5b..342aced 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index a4fcb69..9175691 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,8 +7,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD MODIFICATIONS #================================================= # MODIFY URL IN NGINX CONF #================================================= @@ -18,6 +14,22 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config +#================================================= +# REBUILD CINNY +#================================================= +ynh_script_progression --message="Rebuilding $app..." --weight=1 + +cp "$install_dir/www/config.json" "$install_dir/config.json" + +_patch_build_config "$install_dir/source" +_npm_build_install "$install_dir/source" "$install_dir/www" + +mv "$install_dir/config.json" "$install_dir/www/config.json" + +# Fix any permissions in the install dir +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 688be5f..9ef18f6 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,24 +7,32 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing NodeJS..." --weight=5 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/source" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= -# NGINX CONFIGURATION +# BUILD APP #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression --message="Building $app..." --weight=5 -# Create a dedicated NGINX config -ynh_add_nginx_config +_patch_build_config "$install_dir/source" +_npm_build_install "$install_dir/source" "$install_dir/www" #================================================= # CINNY CONFIGURATION @@ -34,12 +40,20 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring Cinny..." --weight=1 # Copy over the Cinny configuration file -ynh_add_config --template="../conf/cinny.json" --destination="$install_dir/config.json" +ynh_add_config --template="cinny.json" --destination="$install_dir/www/config.json" # Fix any permissions in the install dir chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 92ffbd9..ffaacc6 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,21 +8,14 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# REMOVE NGINX CONFIGURATION +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." --weight=1 - -# Remove the log files +ynh_remove_nodejs #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 38c3995..26987ed 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -11,7 +9,13 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD RESTORATION STEPS +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Reinstalling NodeJS..." --weight=5 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -27,10 +31,8 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" -chown -R $app:www-data "$install_dir" +chown -R "$app:www-data" "$install_dir" -#================================================= -# GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 524e36a..aa47e09 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,17 +7,33 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Updating NodeJS..." --weight=5 + +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config.json" +ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1 --keep="config.json" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" +#================================================= +# BUILD APP +#================================================= +ynh_script_progression --message="Rebuilding $app..." --weight=5 + +_patch_build_config "$install_dir/source" +_npm_build_install "$install_dir/source" "$install_dir/www" + #================================================= # NGINX CONFIGURATION #=================================================