#!/bin/bash #================================================= # GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= source scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= # Get is_public is_public=${YNH_ACTION_IS_PUBLIC} app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) #================================================= # CHECK IF ARGUMENTS ARE CORRECT #================================================= #================================================= # CHECK IF AN ACTION HAS TO BE DONE #================================================= is_public_old=$(ynh_app_setting_get --app=$app --key=is_public) if [ $is_public -eq $is_public_old ] then ynh_die --message="is_public is already set as $is_public." --ret_code=0 fi #================================================= # SPECIFIC ACTION #================================================= # MOVE TO PUBLIC OR PRIVATE #================================================= if [ $is_public -eq 0 ]; then public_private="private" else public_private="public" fi ynh_script_progression --message="Moving the application to $public_private..." --weight=3 if [ $is_public -eq 0 ] then # If the app is private, viewing images stays publicly accessible. if [ "$path_url" == "/" ]; then # If the path is /, clear it to prevent any error with the regex. path_url="" fi # Modify the domain to be used in a regex domain_regex=$(echo "$domain" | sed 's@-@.@g') ynh_app_setting_set --app=$app --key=protected_regex --value="$domain_regex$path_url/stats/?$","$domain_regex$path_url/manifest.webapp/?$","$domain_regex$path_url/?$","$domain_regex$path_url/[d-m]/.*$" else ynh_app_setting_delete --app=$app --key=protected_regex fi ynh_script_progression --message="Upgrading SSOwat configuration..." # Regen ssowat configuration yunohost app ssowatconf # Update the config of the app ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # 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="Execution completed" --last