mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
67 lines
2 KiB
Text
67 lines
2 KiB
Text
|
#!/bin/bash
|
||
|
|
||
|
#=================================================
|
||
|
# GENERIC STARTING
|
||
|
#=================================================
|
||
|
# IMPORT GENERIC HELPERS
|
||
|
#=================================================
|
||
|
|
||
|
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 domain)
|
||
|
path_url=$(ynh_app_setting_get $app 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
|
||
|
# Si l'app est privée, seul le visionnage des images reste public
|
||
|
if [ "$path_url" == "/" ]; then
|
||
|
path_url="" # Si path correspond à la racine, supprime le / pour éviter une erreur de la regex.
|
||
|
fi
|
||
|
# Modifie le domaine pour qu'il passe dans une regex
|
||
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||
|
ynh_app_setting_set $app protected_regex "$domain_regex$path_url/stats$","$domain_regex$path_url/manifest.webapp$","$domain_regex$path_url/$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/m/.*$"
|
||
|
else
|
||
|
ynh_app_setting_delete $app protected_regex
|
||
|
fi
|
||
|
|
||
|
# Regen ssowat configuration
|
||
|
yunohost app ssowatconf
|
||
|
|
||
|
# Update the config of the app
|
||
|
ynh_app_setting_set $app is_public $is_public
|
||
|
|
||
|
#=================================================
|
||
|
# RELOAD NGINX
|
||
|
#=================================================
|
||
|
|
||
|
systemctl reload nginx
|