2018-09-30 11:51:17 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2019-01-19 12:00:42 +01:00
|
|
|
source scripts/_common.sh
|
2018-09-30 11:51:17 +02:00
|
|
|
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-20 23:09:08 +02:00
|
|
|
is_public_old=$(ynh_app_setting_get --app=$app --key=is_public)
|
2018-09-30 11:51:17 +02:00
|
|
|
|
|
|
|
if [ $is_public -eq $is_public_old ]
|
|
|
|
then
|
2019-05-20 23:09:08 +02:00
|
|
|
ynh_die --message="is_public is already set as $is_public." 0
|
2018-09-30 11:51:17 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC ACTION
|
|
|
|
#=================================================
|
|
|
|
# MOVE TO PUBLIC OR PRIVATE
|
|
|
|
#=================================================
|
2019-05-20 23:09:08 +02:00
|
|
|
|
2019-01-30 16:15:24 +01:00
|
|
|
if [ $is_public -eq 0 ]; then
|
|
|
|
public_private="private"
|
|
|
|
else
|
|
|
|
public_private="public"
|
|
|
|
fi
|
2019-03-12 20:09:45 +01:00
|
|
|
ynh_script_progression --message="Moving the application to $public_private..." --weight=3
|
2018-09-30 11:51:17 +02:00
|
|
|
|
|
|
|
if [ $is_public -eq 0 ]
|
|
|
|
then
|
2019-05-20 23:09:08 +02:00
|
|
|
ynh_app_setting_delete --app=$app --key=unprotected_uris
|
2019-01-19 12:13:45 +01:00
|
|
|
# Set the action.php script public for the cron task
|
2019-05-20 23:09:08 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=skipped_uris --value="/action.php"
|
2018-09-30 11:51:17 +02:00
|
|
|
else
|
2019-05-20 23:09:08 +02:00
|
|
|
ynh_app_setting_delete --app=$app --key=skipped_uris
|
|
|
|
ynh_app_setting_set --app=$app --key=unprotected_uris --value="/"
|
2018-09-30 11:51:17 +02:00
|
|
|
fi
|
|
|
|
|
2019-05-20 23:09:08 +02:00
|
|
|
ynh_script_progression --message="Upgrading SSOwat configuration..."
|
2018-09-30 11:51:17 +02:00
|
|
|
# Regen ssowat configuration
|
|
|
|
yunohost app ssowatconf
|
|
|
|
|
|
|
|
# Update the config of the app
|
2019-05-20 23:09:08 +02:00
|
|
|
ynh_app_setting_set --app=$app --key=is_public --value=$is_public
|
2018-09-30 11:51:17 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2019-03-12 20:09:45 +01:00
|
|
|
ynh_script_progression --message="Reloading nginx web server..."
|
2018-09-30 11:51:17 +02:00
|
|
|
|
2019-05-20 23:09:08 +02:00
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
2019-01-30 16:15:24 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_script_progression --message="Execution completed" --last
|