mirror of
https://github.com/YunoHost-Apps/lstu_ynh.git
synced 2024-09-03 19:36:12 +02:00
82 lines
2.5 KiB
Bash
Executable file
82 lines
2.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source scripts/_common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# RETRIEVE ARGUMENTS
|
|
#=================================================
|
|
ynh_script_progression --message="Retrieve arguments from the manifest"
|
|
|
|
# Get is_public
|
|
is_public=${YNH_ACTION_IS_PUBLIC}
|
|
|
|
app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
|
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
|
|
#=================================================
|
|
# CHECK IF ARGUMENTS ARE CORRECT
|
|
#=================================================
|
|
|
|
#=================================================
|
|
# CHECK IF AN ACTION HAS TO BE DONE
|
|
#=================================================
|
|
|
|
is_public_old=$(ynh_app_setting_get $app is_public)
|
|
|
|
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
|
|
ynh_script_progression --message="Move the application to $public_private" --weight=3
|
|
|
|
ynh_app_setting_set $app skipped_uris "/"
|
|
if [ $is_public -eq 0 ];
|
|
then # If the app is private, only the shortened URLs are publics
|
|
if [ "$path_url" == "/" ]; then
|
|
path_url=""
|
|
fi
|
|
ynh_app_setting_set $app protected_regex "$domain$path_url/login$","$domain$path_url/logout$","$domain$path_url/api$","$domain$path_url/extensions$","$domain$path_url/stats$","$domain$path_url/d/.*$","$domain$path_url/a$","$domain$path_url/$"
|
|
else
|
|
ynh_app_setting_delete $app protected_regex
|
|
fi
|
|
|
|
config_file_is_public
|
|
|
|
ynh_script_progression --message="Reconfigure SSOwat"
|
|
# Regen ssowat configuration
|
|
yunohost app ssowatconf
|
|
|
|
# Update the config of the app
|
|
ynh_app_setting_set $app is_public $is_public
|
|
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
ynh_script_progression --message="Reload $app"
|
|
|
|
ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "systemd"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Execution completed" --last
|