mirror of
https://github.com/YunoHost-Apps/lutim_ynh.git
synced 2024-09-03 19:36:24 +02:00
Remove public_private action/config
This commit is contained in:
parent
21a6a7ced6
commit
3952aec549
4 changed files with 0 additions and 117 deletions
12
actions.toml
12
actions.toml
|
@ -21,15 +21,3 @@ name = "Reset the config file and restore a default one."
|
|||
command = "/bin/bash scripts/actions/reset_default_config \"lutim.conf\""
|
||||
accepted_return_codes = [0]
|
||||
description = "Reset the config file lutim.conf."
|
||||
|
||||
[public_private]
|
||||
name = "Move to public or private"
|
||||
command = "/bin/bash scripts/actions/public_private"
|
||||
accepted_return_codes = [0]
|
||||
description = "Change the public access of the app."
|
||||
|
||||
[public_private.arguments]
|
||||
[public_private.arguments.is_public]
|
||||
type = "boolean"
|
||||
ask = "Is it a public app ?"
|
||||
default = true
|
||||
|
|
|
@ -24,14 +24,6 @@ name = "Lutim configuration"
|
|||
default = "Year"
|
||||
help = "Users won't be able to ask Lutim to download images more than one per anti_flood_delay seconds."
|
||||
|
||||
[main.is_public]
|
||||
name = "Public access"
|
||||
|
||||
[main.is_public.is_public]
|
||||
ask = "Is it a public website?"
|
||||
type = "boolean"
|
||||
default = true
|
||||
|
||||
[main.overwrite_files]
|
||||
name = "Overwriting config files"
|
||||
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
#!/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
|
|
@ -61,10 +61,6 @@ else
|
|||
fi
|
||||
delay="${YNH_CONFIG_MAIN_CONFIGURATION_DELAY:-$old_delay}"
|
||||
|
||||
# is_public
|
||||
old_is_public="$(ynh_app_setting_get --app=$app --key=is_public)"
|
||||
is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}"
|
||||
|
||||
# Overwrite settings.json file
|
||||
old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)"
|
||||
overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}"
|
||||
|
@ -93,8 +89,6 @@ show_config() {
|
|||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_ANTIFLOOD=$antiflood"
|
||||
ynh_return "YNH_CONFIG_MAIN_CONFIGURATION_DELAY=$delay"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public"
|
||||
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
|
||||
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SYSTEMD=$overwrite_systemd"
|
||||
|
@ -154,14 +148,6 @@ apply_config() {
|
|||
ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120"
|
||||
fi
|
||||
|
||||
# Change public accessibility
|
||||
if [ "$is_public" = "true" ]
|
||||
then
|
||||
yunohost app action run $app public_private --args is_public=1
|
||||
else
|
||||
yunohost app action run $app public_private --args is_public=0
|
||||
fi
|
||||
|
||||
# Set overwrite_settings
|
||||
ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings"
|
||||
# Set overwrite_nginx
|
||||
|
|
Loading…
Reference in a new issue