diff --git a/README.md b/README.md index c804b08..425c4e8 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Cesium package for YunoHost -[![Integration level](https://dash.yunohost.org/integration/cesium.svg)](https://dash.yunohost.org/appci/app/cesium) ![](https://ci-apps.yunohost.org/ci/badges/cesium.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cesium.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/cesium.svg)](https://dash.yunohost.org/appci/app/cesium) ![](https://ci-apps.yunohost.org/ci/badges/cesium.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/cesium.maintain.svg) [![Install Custom Webapp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=cesium) -> *This package allow you to install Cesium quickly and simply on a YunoHost server. +> *This package allow you to install Cesium quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview @@ -12,7 +12,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to [Cesium](https://cesium.app) is an [Unhosted webapp](https://unhosted.org) client for any [Duniter](https://duniter.org) crypto-currency. It allows you to manage your wallet, certify your friends, and more ! -**Shipped version:** v1.6.3 +**Shipped version:** v1.6.7 ## Links diff --git a/check_process b/check_process index 740aae0..8e0b5c4 100644 --- a/check_process +++ b/check_process @@ -2,7 +2,7 @@ auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) - path="/cesium" (PATH) + path="/path" (PATH) is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 @@ -14,10 +14,16 @@ upgrade=1 backup_restore=1 multi_instance=0 - wrong_user=0 - wrong_path=1 - incorrect_path=1 - corrupt_source=0 - fail_download_source=0 port_already_use=0 - final_path_already_use=0 + change_url=1 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto + Level 4=na + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 \ No newline at end of file diff --git a/conf/app.src b/conf/app.src index bfc90a7..8831ae2 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/duniter/cesium/releases/download/v1.6.3/cesium-v1.6.3-web.zip -SOURCE_SUM=e6bb12bb56453781d01fe0f74afd28990d693010652b542eae0d3348f51d911e +SOURCE_URL=https://github.com/duniter/cesium/releases/download/v1.6.7/cesium-v1.6.7-web.zip +SOURCE_SUM=99157da53e42096c51ebf845c40c155cb1ed6d66678983c9947b528869b6284f SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=false diff --git a/conf/nginx.conf b/conf/nginx.conf index f65be88..508fc0a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,8 @@ -location YNH_WWW_PATH { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { # Path to source - alias YNH_WWW_ALIAS ; + alias __FINALPATH__/ ; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/helper-update-version.sh b/helper-update-version.sh index 070a7cc..089c11f 100755 --- a/helper-update-version.sh +++ b/helper-update-version.sh @@ -1,16 +1,16 @@ #!/bin/bash # Retrieve sources, get sha256sum, parse package version and update these strings in manifest, README and /conf/app.src - -URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/latest | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) -wget -nc --quiet $URL -P ./tmp -CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64) -sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src -sed -i "s#SOURCE_URL=.*#SOURCE_URL=$URL#" ./conf/app.src -VERSION=$(echo $URL | sed "s#https://github.com/duniter/cesium/releases/download/\(.*\)/cesium.*#\1#") -sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${VERSION}#" ./README.md -sed -i "s# \"version\": \".*# \"version\": \"${VERSION}\~ynh1\",#" ./manifest.json +# URL=$(curl -s https://api.github.com/repos/duniter/cesium/releases/latest | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) +# wget -nc --quiet $URL -P ./tmp +# CHECKSUM=$(sha256sum ./tmp/cesium-*-web.zip | head -c 64) +# sed -i "s/SOURCE_SUM=.*/SOURCE_SUM=${CHECKSUM}/" ./conf/app.src +# sed -i "s#SOURCE_URL=.*#SOURCE_URL=$URL#" ./conf/app.src -rm -f -R ./tmp +# VERSION=$(echo $URL | sed "s#https://github.com/duniter/cesium/releases/download/\(.*\)/cesium.*#\1#") +# sed -i "s#\*\*Shipped version:\*\*.*#\*\*Shipped version:\*\* ${VERSION}#" ./README.md +# sed -i "s# \"version\": \".*# \"version\": \"${VERSION}\~ynh1\",#" ./manifest.json -git commit README.md manifest.json conf/app.src -m "$VERSION" +# rm -f -R ./tmp + +# git commit README.md manifest.json conf/app.src -m "$VERSION" diff --git a/manifest.json b/manifest.json index d8f1a9c..5f89554 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Duniter client to manage wallets, certifications in a libre money.", "fr": "Client Duniter pour gérer ses portes-monnaie, les certifications au sein d’une monnaie libre." }, - "version": "v1.6.3~ynh1", + "version": "v1.6.7~ynh1", "url": "https://github.com/duniter/cesium", "license": "AGPL-3.0-or-later", "maintainer": { @@ -15,7 +15,7 @@ "url": "https://moul.re" }, "requirements": { - "yunohost": ">> 2.4.0" + "yunohost": ">> 3.7.0" }, "multi_instance": false, "services": [ diff --git a/scripts/backup b/scripts/backup index f944306..85799e7 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,18 +1,60 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." -# See comments in install script app=$YNH_APP_INSTANCE_NAME -# Source YunoHost helpers -source /usr/share/yunohost/helpers +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) + +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs +### to be backuped and not an actual copy of any file. The actual backup that +### creates and fill the archive with the files happens in the core after this +### script is called. Hence ynh_backups calls takes basically 0 seconds to run. + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." -# Backup sources & data -# Note: the last argument is where to save this path, see the restore script. -ynh_backup "/var/www/${app}" "sources" -# Copy NGINX configuration -domain=$(ynh_app_setting_get "$app" domain) -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..72a982b --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,92 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating nginx web server configuration..." + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the nginx config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +fi + + +# Change the domain for nginx +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum --file="$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + + + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --time --last + diff --git a/scripts/install b/scripts/install index 1702adf..a2b2c65 100755 --- a/scripts/install +++ b/scripts/install @@ -1,43 +1,115 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Exit on command errors and treat unset variables as an error -set -eu +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= # Retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN -path=$YNH_APP_ARG_PATH +path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -# Source YunoHost helpers -source /usr/share/yunohost/helpers +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +ynh_script_progression --message="Validating installation parameters..." + +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +# Normalize the url path syntax +path_url=$(ynh_normalize_url_path $path_url) + +# Check web path availability +ynh_webpath_available $domain $path_url +# Register (book) web path +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url + +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= +ynh_script_progression --message="Storing installation settings..." # Save app settings -ynh_app_setting_set "$app" is_public "$is_public" +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public -# Check domain/path availability -yunohost app checkurl "${domain}${path}" -a "$app" \ - || ynh_die "Path not available: ${domain}${path}" +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." # Retrieve sources and install them -src_path=/var/www/$app -mkdir -p $src_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src - ynh_script_progression --message="Setting up source files..." --time --weight=1 - ynh_setup_source --dest_dir=$src_path -chown -R www-data: $src_path -# Modify Nginx configuration file and copy it to Nginx conf directory -nginx_conf=../conf/nginx.conf -sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf -sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf -cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +ynh_setup_source --dest_dir="$final_path" + +#================================================= +# Permissions files +#================================================= + +chown -R www-data: $final_path -# If app is public, add url to SSOWat conf as skipped_uris +# Remove the public access +ynh_app_setting_delete --app=$app --key=skipped_uris + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring nginx web server..." + +### `ynh_add_nginx_config` will use the file conf/nginx.conf +# Create a dedicated nginx config +ynh_add_nginx_config + + +if [ "$path_url" != "/" ] +then + ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" +fi + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring permissions..." + +# If app is public, add url to SSOWat conf as skipped_uris and read-only mode if [[ $is_public -eq 1 ]]; then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" + ynh_permission_update --permission "main" --add "visitors" + # activate read-only + ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js" fi -# Reload nginx service -systemctl reload nginx +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --time --last \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index 32713ca..275c66a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,17 +1,52 @@ #!/bin/bash -# Source YunoHost helpers +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source /usr/share/yunohost/helpers -# Retrieve app settings +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." + app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -# Remove sources -ynh_secure_remove /var/www/$app +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + + +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_script_progression --message="Removing app main directory..." + +# Remove the app directory securely +ynh_secure_remove --file="$final_path" + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Removing nginx web server configuration..." + +# Remove the dedicated nginx config +ynh_remove_nginx_config + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --time --last + + -# Remove configuration files -rm -f /etc/nginx/conf.d/$domain.d/$app.conf -# Reload nginx service -systemctl reload nginx diff --git a/scripts/restore b/scripts/restore index 89abc87..3ce8d38 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,35 +1,79 @@ #!/bin/bash -# Note: each files and directories you've saved using the ynh_backup helper -# will be located in the current directory, regarding the last argument. +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Exit on command errors and treat unset variables as an error -set -eu +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." -# See comments in install script app=$YNH_APP_INSTANCE_NAME -# Source YunoHost helpers -source /usr/share/yunohost/helpers +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) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_script_progression --message="Validating restoration parameters..." + +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." + +ynh_restore_file --origin_path="$final_path" -# Retrieve old app settings -domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) +#================================================= +# RESTORE USER RIGHTS +#================================================= -# Check domain/path availability -yunohost app checkurl "${domain}${path}" -a "$app" \ - || ynh_die "Path not available: ${domain}${path}" +# Restore permissions on app files +chown -R www-data: $final_path -# Restore sources & data -src_path="/var/www/${app}" -cp -a ./sources "$src_path" +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." -# Restore permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) -chown -R www-data: "$src_path" +ynh_systemd_action --service_name=nginx --action=reload -# Restore NGINX configuration -cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +#================================================= +# END OF SCRIPT +#================================================= -# Restart webserver -systemctl reload nginx +ynh_script_progression --message="Restoration completed for $app" --time --last \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 79820c9..bd7f001 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,16 +1,29 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source YunoHost helpers source /usr/share/yunohost/helpers -# Retrieve app settings +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get "$app" domain) -path=$(ynh_app_setting_get "$app" path) -is_public=$(ynh_app_setting_get "$app" is_public) + +# Retrieve app settings +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + + +#================================================= +# CHECK VERSION +#================================================= ### This helper will compare the version of the currently installed app and the version of the upstream package. ### $upgrade_type can have 2 different values @@ -20,33 +33,107 @@ is_public=$(ynh_app_setting_get "$app" is_public) ### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) -# Remove trailing "/" for next commands -path=${path%/} -# Retreive sources and install them -src_path=/var/www/$app +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 +fi + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK THE PATH +#================================================= + +# Normalize the URL path syntax +# N.B. : this is for app installations before YunoHost 2.7 +# where this value might be something like /foo/ or foo/ +# instead of /foo .... +# If nobody installed your app before 2.7, then you may +# safely remove this line +path_url=$(ynh_normalize_url_path --path_url=$path_url) + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_secure_remove $src_path - mkdir -p $src_path - ynh_script_progression --message="Upgrading source files..." --time --weight=1 + ynh_script_progression --message="Upgrading source files..." + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi + + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$src_path - chown -R www-data: $src_path +ynh_add_nginx_config + +if [ "$path_url" != "/" ] +then + ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" fi +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R www-data: $final_path -# Modify Nginx configuration file and copy it to Nginx conf directory -nginx_conf=../conf/nginx.conf -sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf -sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf -cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +#================================================= +# SETUP SSOWAT +#================================================= +ynh_script_progression --message="Configuring permissions..." -# If app is public, add url to SSOWat conf as skipped_uris +# If app is public, add url to SSOWat conf as skipped_uris and read-only mode if [[ $is_public -eq 1 ]]; then - ynh_app_setting_set "$app" unprotected_uris "/" + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_permission_update --permission "main" --add "visitors" + # activate read-only + ynh_replace_string --match_string='"readonly": false,' --replace_string='"readonly": true,' --target_file="$final_path/config.js" fi -# Reload nginx service -systemctl reload nginx +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --time --last \ No newline at end of file