2019-04-11 01:12:07 +02:00
|
|
|
#!/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}
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF ARGUMENTS ARE CORRECT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK IF AN ACTION HAS TO BE DONE
|
|
|
|
#=================================================
|
|
|
|
|
2019-05-09 01:13:48 +02:00
|
|
|
is_public_old=$(ynh_app_setting_get --app=$app --key=is_public)
|
2019-04-11 01:12:07 +02:00
|
|
|
|
|
|
|
if [ $is_public -eq $is_public_old ]
|
|
|
|
then
|
|
|
|
ynh_die "is_public is already set as $is_public." 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC ACTION
|
|
|
|
#=================================================
|
|
|
|
# MOVE TO PUBLIC OR PRIVATE
|
|
|
|
#=================================================
|
|
|
|
if [ $is_public -eq 0 ]; then
|
|
|
|
public_private="private"
|
|
|
|
else
|
|
|
|
public_private="public"
|
|
|
|
fi
|
2019-05-09 09:03:19 +02:00
|
|
|
ynh_script_progression --message=--message="Moving the application to $public_private..." --weight=1
|
2019-04-11 01:12:07 +02:00
|
|
|
|
|
|
|
# Make app public if necessary
|
|
|
|
if [ $is_public -eq 0 ]; then
|
|
|
|
ynh_app_setting_delete $app unprotected_uris
|
|
|
|
else
|
|
|
|
# unprotected_uris allows SSO credentials to be passed anyway.
|
2019-05-09 01:13:48 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
2019-04-11 01:12:07 +02:00
|
|
|
fi
|
|
|
|
|
2019-05-09 09:03:19 +02:00
|
|
|
ynh_script_progression --message=--message="Reconfiguring SSOwat..." --weight=1
|
2019-04-11 01:12:07 +02:00
|
|
|
# Regen ssowat configuration
|
|
|
|
yunohost app ssowatconf
|
|
|
|
|
|
|
|
# Update the config of the app
|
2019-05-09 01:13:48 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
2019-04-11 01:12:07 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2019-05-09 09:03:19 +02:00
|
|
|
ynh_script_progression --message=--message="Reloading nginx web server..." --weight=1
|
2019-04-11 01:12:07 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --action=reload --service_name=nginx
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2019-05-09 09:03:19 +02:00
|
|
|
ynh_script_progression --message="Execution completed" --last
|