diff --git a/README.md b/README.md index 25f2242..e27ac9c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in End-to-end encrypted note-taking app -**Shipped version:** 3.39.1~ynh1 +**Shipped version:** 3.66.0~ynh1 *(:warning: This is the `testing` branch. The [`master` branch](https://github.com/YunoHost-Apps/snweb_ynh/tree/master) used in the catalog is currently on version 3.39.1\~ynh1.)* + **Demo:** https://standardnotes.org/demo diff --git a/README_fr.md b/README_fr.md index 61b0a43..24d9133 100644 --- a/README_fr.md +++ b/README_fr.md @@ -17,7 +17,8 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour Application de prise de notes chiffrées -**Version incluse :** 3.39.1~ynh1 +**Version incluse :** 3.66.0~ynh1 *(:warning: Il s'agit de la branche `testing`. La [branche `master`](https://github.com/YunoHost-Apps/snweb_ynh/tree/master) utilisée dans le catalogue est actuellement en 3.39.1\~ynh1.)* + **Démo :** https://standardnotes.org/demo diff --git a/conf/app.src b/conf/app.src index abd6a8e..bb320d4 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/standardnotes/app/archive/refs/tags/@standardnotes/web@3.39.1.tar.gz -SOURCE_SUM=1dc84e151c20f5a31cf8b6f9c1248b14d2f72800f58557ddb8fe8ee54d360c58 +SOURCE_URL=https://github.com/standardnotes/app/archive/refs/tags/@standardnotes/web@3.66.0.tar.gz +SOURCE_SUM=135aea740cb5d0497faf1f05a234965f6410f07cf429d839ea516179e0d57f40 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/env.sample b/conf/env.sample deleted file mode 100644 index a9bb6b5..0000000 --- a/conf/env.sample +++ /dev/null @@ -1,15 +0,0 @@ -RAILS_ENV=production -PORT=__PORT__ - -DEFAULT_SYNC_SERVER=https://__SNSERVER_DOMAIN__/ - -# Subscription related endpoints -DASHBOARD_URL=http://standardnotes.com/dashboard -PLANS_URL=https://standardnotes.com/plans -PURCHASE_URL=https://standardnotes.com/purchase - -# Used by Rails internals and not Standard Notes related -SECRET_KEY_BASE=__SECRET_KEY_BASE__ - -# Sub-URI -RAILS_RELATIVE_URL_ROOT=__PATH__/ diff --git a/conf/nginx.conf b/conf/nginx.conf index 426082e..6bc0218 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,18 +1,12 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__/ { # Path to source - alias __FINALPATH__/live/packages/web-server/public ; + alias __FINALPATH__/live/packages/web/dist/ ; - # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file - client_max_body_size 50M; - - proxy_pass http://127.0.0.1:__PORT____PATH__/; - proxy_http_version 1.1; - proxy_set_header Host $http_host; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_buffering off; + # Redirects + sub_filter ' href="/' ' href="__PATH__/'; + sub_filter ' src="/' ' src="__PATH__/'; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/conf/systemd.service b/conf/systemd.service deleted file mode 100644 index 8a571ea..0000000 --- a/conf/systemd.service +++ /dev/null @@ -1,44 +0,0 @@ -[Unit] -Description=__APP__ -After=network.target - -[Service] -Type=simple -User=__APP__ -Group=__APP__ -EnvironmentFile=__FINALPATH__/live/.env -WorkingDirectory=__FINALPATH__/live/packages/web-server/ -ExecStart=__RBENV_INSTALL_DIR__/versions/__APP__/bin/bundle exec rails s -b 0.0.0.0 -p __PORT__ -e production -StandardOutput=append:/var/log/__APP__/snweb.log -StandardError=inherit -Restart=always - -# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html -NoNewPrivileges=yes -PrivateTmp=yes -PrivateDevices=yes -RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 -RestrictNamespaces=yes -RestrictRealtime=yes -DevicePolicy=closed -ProtectSystem=full -ProtectControlGroups=yes -ProtectKernelModules=yes -ProtectKernelTunables=yes -LockPersonality=yes -SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap - -# Denying access to capabilities that should not be relevant for webapps -# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html -CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD -CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE -CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT -CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK -CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM -CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG -CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE -CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW -CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG - -[Install] -WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index 0ef3c17..36fb407 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "End-to-end encrypted note-taking app", "fr": "Application de prise de notes chiffrées" }, - "version": "3.39.1~ynh1", + "version": "3.66.0~ynh1", "url": "https://github.com/standardnotes/web", "upstream": { "license": "AGPL-3.0-or-later", @@ -58,7 +58,7 @@ "en": "Choose the default Standard Notes Syncing Server", "de": "Wähle den Standard Notes Syncing Server" }, - "default": "api.standardnotes.org" + "default": "api.standardnotes.com" } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index c47cfa8..960eb53 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,31 +5,15 @@ #================================================= # dependencies used by the app -pkg_dependencies="\ - " - -RUBY_VERSION="2.7.4" -NODEJS_VERSION="16" +pkg_dependencies="" +NODEJS_VERSION="16.17.0" node_max_old_space_size=2048 #================================================= # PERSONAL HELPERS #================================================= -# Check if service is ready -is_service_ready() { - for ((i = 0 ; i < 15 ; i++)) - do - if [ "200" -eq $(curl --silent --insecure --resolve $domain:443:127.0.0.1 https://$domain$path_url/ -o /dev/null --write-out "%{http_code}") ] - then - break - else - sleep 2 - fi - done -} - #================================================ # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 7e4729f..9b468a7 100755 --- a/scripts/backup +++ b/scripts/backup @@ -50,16 +50,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= -# BACKUP LOGROTATE -#================================================= - -ynh_backup --src_path="/etc/logrotate.d/$app" - -#================================================= -# BACKUP SYSTEMD -#================================================= - -ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index 09bfb4d..82517c7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,9 +28,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -port=$(ynh_app_setting_get --app=$app --key=port) snserver_domain=$(ynh_app_setting_get --app=$app --key=snserver_domain) -secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP @@ -67,13 +65,6 @@ fi #================================================= # STANDARD MODIFICATIONS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" - #================================================= # MODIFY URL IN NGINX CONF #================================================= @@ -106,24 +97,20 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= +ynh_script_progression --message="Modify Configuration..." --weight=1 -config_file="$final_path/live/.env" - -domain=$new_domain -path_url=$new_path - -ynh_add_config --template="env.sample" --destination="$config_file" +if [ $change_path -eq 1 ] +then + cp "$final_path/live/packages/web/dist/app.js.orginal" "$final_path/live/packages/web/dist/app.js" + # If $new_path is used modify .js file for a working app on a subpath + if [ $new_path != "/" ] + then + ynh_replace_string --match_string="/components/" --replace_string="$new_path/components/" --target_file="$final_path/live/packages/web/dist/app.js" + fi +fi #================================================= # GENERIC FINALISATION -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -# Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - #================================================= # RELOAD NGINX #================================================= @@ -131,15 +118,6 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# WAITING FOR SERVICE -#================================================= -ynh_script_progression --message="Waiting for service..." --weight=1 - -domain=$new_domain -path_url=$new_path -is_service_ready - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index ab683b6..778b9a9 100644 --- a/scripts/install +++ b/scripts/install @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_install_ruby__2 source /usr/share/yunohost/helpers #================================================= @@ -39,7 +38,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Validating installation parameters..." --weight=2 -final_path=/opt/yunohost/$app +final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path @@ -57,23 +56,14 @@ ynh_app_setting_set --app=$app --key=snserver_domain --value=$snserver_domain #================================================= # STANDARD MODIFICATIONS #================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port -port=$(ynh_find_port --port=3000) -ynh_app_setting_set --app=$app --key=port --value=$port - #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." --weight=30 -ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies +ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # CREATE DEDICATED USER @@ -94,7 +84,7 @@ ynh_setup_source --dest_dir="$final_path/live" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app: "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -107,77 +97,39 @@ ynh_add_nginx_config #================================================= # SPECIFIC SETUP #================================================= -# INSTALLING RUBY AND BUNDLER -#================================================= -ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #212 - -pushd "$final_path/live" - ynh_use_ruby - ynh_gem update --system --no-document --quiet - ynh_gem install bundler --no-document --quiet -popd - -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 - -config_file="$final_path/live/.env" -secret_key_base=$(ynh_string_random --length=48 | base64) - -ynh_app_setting_set --app=$app --key=secret_key_base --value=$secret_key_base - -ynh_add_config --template="env.sample" --destination="$config_file" - #================================================= # BUILDING #================================================= ynh_script_progression --message="Building... ( This may take a while... )" --weight=100 #497 -chown -R $app: "$final_path" - pushd "$final_path/live" ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install - ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build:web-server - ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build:web + ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn install --immutable + ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn build:web popd +chown -R $app:www-data "$final_path" #================================================= -# SETUP SYSTEMD +# Modify Config #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=3 +ynh_script_progression --message="Configuring..." --weight=1 -# Create a dedicated systemd config -ynh_add_systemd_config +# If $path is used modify .js file for a working app on a subpath +cp "$final_path/live/packages/web/dist/app.js" "$final_path/live/packages/web/dist/app.js.orginal" +if [ $path_url != "/" ] +then + ynh_replace_string --match_string="/components/" --replace_string="$path_url/components/" --target_file="$final_path/live/packages/web/dist/app.js" +fi -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=2 - -mkdir -p "/var/log/$app" -chown -R $app: "/var/log/$app" - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="/var/log/$app/$app.log" - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Standard Notes" --log="/var/log/$app/$app.log" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -# Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +# Modify Config +index_file="$final_path/live/packages/web/dist/index.html" +ynh_replace_string --match_string="\(defaultSyncServer = \).*" --replace_string="\1\"$snserver_domain\"" --target_file="$index_file" +ynh_replace_string --match_string="\(defaultFilesHost = \).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace_string --match_string="\(enabledUnfinishedFeatures = \).*" --replace_string="\1false" --target_file="$index_file" +ynh_replace_string --match_string="\(websocketUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace_string --match_string="\(purchaseUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace_string --match_string="\(plansUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace_string --match_string="\(dashboardUrl =\).*" --replace_string="\1\"\"" --target_file="$index_file" #================================================= # SETUP SSOWAT @@ -199,13 +151,6 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# WAITING FOR SERVICE -#================================================= -ynh_script_progression --message="Waiting for service..." --weight=1 - -is_service_ready - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 4552e6f..3a79b16 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,37 +18,17 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST -#================================================= - -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status $app >/dev/null -then - ynh_script_progression --message="Removing $app service integration..." --weight=1 - yunohost service remove $app -fi - -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2 - -# Remove the dedicated systemd config -ynh_remove_systemd_config --service="$app" - #================================================= # REMOVE DEPENDENCIES #================================================= ynh_script_progression --message="Removing dependencies..." --weight=4 # Remove metapackage and its dependencies -ynh_remove_ruby ynh_remove_nodejs ynh_remove_app_dependencies @@ -68,23 +48,9 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=2 - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - -# Remove the log files -ynh_secure_remove --file="/var/log/$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index 5429da9..9295585 100755 --- a/scripts/restore +++ b/scripts/restore @@ -8,7 +8,6 @@ # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh -source ../settings/scripts/ynh_install_ruby__2 source /usr/share/yunohost/helpers #================================================= @@ -66,7 +65,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app: "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION @@ -76,53 +75,9 @@ chown -R $app: "$final_path" ynh_script_progression --message="Reinstalling dependencies... ( This may take a while... )" --weight=100 #294 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies +ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_install_ruby --ruby_version=$RUBY_VERSION - -#================================================= -# INSTALLING RUBY AND BUNDLER -#================================================= -ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #212 - -pushd "$final_path/live" - ynh_use_ruby - ynh_gem update --system --no-document --quiet - ynh_gem install bundler --no-document --quiet -popd - -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add $app --description="Standard Notes" --log="/var/log/$app/$app.log" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=2 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -mkdir -p "/var/log/$app" -chown -R $app: "/var/log/$app" - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION @@ -133,13 +88,6 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# WAITING FOR SERVICE -#================================================= -ynh_script_progression --message="Waiting for service..." --weight=1 - -is_service_ready - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6c11c3b..6e14e99 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,11 +20,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -port=$(ynh_app_setting_get --app=$app --key=port) snserver_domain=$(ynh_app_setting_get --app=$app --key=snserver_domain) -secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base) - -config_file="$final_path/live/.env" #================================================= # CHECK VERSION @@ -50,12 +46,6 @@ ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -70,7 +60,7 @@ fi # If final_path doesn't exist, create it if [ -z "$final_path" ]; then - final_path=/opt/yunohost/$app + final_path=/var/www/$app ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi @@ -78,10 +68,6 @@ if [ -z "$snserver_domain" ]; then snserver_domain="api.standardnotes.com" fi -if [ -z "$secret_key_base" ]; then - secret_key_base=$(ynh_string_random --length=48 | base64) -fi - #================================================= # CREATE DEDICATED USER #================================================= @@ -105,7 +91,7 @@ fi # Set permissions to app files chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app: "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -123,29 +109,10 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=37 ynh_install_app_dependencies $pkg_dependencies $build_pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # SPECIFIC UPGRADE #================================================= -# INSTALLING RUBY AND BUNDLER -#================================================= -ynh_script_progression --message="Installing Ruby... ( This may take a while... )" --weight=100 #331 - -pushd "$final_path/live" - ynh_use_ruby - ynh_gem update --system --no-document --quiet - ynh_gem install bundler --no-document --quiet -popd - -#================================================= -# UPDATE A CONFIG FILE -#================================================= - -ynh_script_progression --message="Updating a configuration file..." --weight=2 - -ynh_add_config --template="env.sample" --destination="$config_file" - #================================================= # BUILDING #================================================= @@ -154,51 +121,39 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Building... ( This may take a while... )" --weight=100 #131 - chown -R $app: "$final_path" - pushd "$final_path/live" ynh_use_nodejs - ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn install - ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build:web-server - ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" PATH=$ynh_node_load_PATH yarn build:web + ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn install --immutable + ynh_exec_warn_less ynh_exec_as $app env NODE_OPTIONS="--max-old-space-size=$node_max_old_space_size" $ynh_node_load_PATH yarn build:web popd + chown -R $app:www-data "$final_path" fi #================================================= -# SETUP SYSTEMD +# Modify Config #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=4 +ynh_script_progression --message="Configuring..." --weight=1 -# Create a dedicated systemd config -ynh_add_systemd_config +# If $path is used modify .js file for a working app on a subpath +cp "$final_path/live/packages/web/dist/app.js" "$final_path/live/packages/web/dist/app.js.orginal" +if [ $path_url != "/" ] +then + ynh_replace_string --match_string="/components/" --replace_string="$path_url/components/" --target_file="$final_path/live/packages/web/dist/app.js" +fi + +# Modify Config +index_file="$final_path/live/packages/web/dist/index.html" +ynh_replace_string --match_string="\(defaultSyncServer = \).*" --replace_string="\1\"$snserver_domain\"" --target_file="$index_file" +ynh_replace_string --match_string="\(defaultFilesHost = \).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace_string --match_string="\(enabledUnfinishedFeatures = \).*" --replace_string="\1false" --target_file="$index_file" +ynh_replace_string --match_string="\(websocketUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace_string --match_string="\(purchaseUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace_string --match_string="\(plansUrl = \).*" --replace_string="\1\"\"" --target_file="$index_file" +ynh_replace_string --match_string="\(dashboardUrl =\).*" --replace_string="\1\"\"" --target_file="$index_file" #================================================= # GENERIC FINALIZATION #================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - -mkdir -p "/var/log/$app" -chown -R $app: "/var/log/$app" - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate --logfile="/var/log/$app/$app.log" - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Standard Notes" --log="/var/log/$app/$app.log" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=2 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - #================================================= # RELOAD NGINX #================================================= @@ -206,13 +161,6 @@ ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# WAITING FOR SERVICE -#================================================= -ynh_script_progression --message="Waiting for service..." --weight=1 - -is_service_ready - #================================================= # END OF SCRIPT #================================================= diff --git a/sources/patches/app-00-add-path-url.patch b/sources/patches/app-00-add-path-url.patch deleted file mode 100644 index d9bab2f..0000000 --- a/sources/patches/app-00-add-path-url.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/packages/web-server/config.ru b/packages/web-server/config.ru -index bd83b25..6b1bb50 100644 ---- a/packages/web-server/config.ru -+++ b/packages/web-server/config.ru -@@ -1,4 +1,6 @@ - # This file is used by Rack-based servers to start the application. - - require ::File.expand_path('../config/environment', __FILE__) --run Rails.application -+map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do -+ run Rails.application -+end