mirror of
https://github.com/YunoHost-Apps/lstu_ynh.git
synced 2024-09-03 19:36:12 +02:00
fix change url
This commit is contained in:
parent
8fa8e8d7a6
commit
5e24e659a8
5 changed files with 50 additions and 42 deletions
|
@ -30,4 +30,4 @@
|
|||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
Level 10=0
|
||||
|
|
|
@ -1,19 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
config_file_is_public() {
|
||||
|
||||
ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
|
||||
|
||||
if [ $is_public -eq 0 ];
|
||||
then
|
||||
ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lstu.conf"
|
||||
else
|
||||
ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lstu.conf"
|
||||
fi
|
||||
|
||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
||||
}
|
||||
|
||||
# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started
|
||||
#
|
||||
# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ]
|
||||
|
|
|
@ -12,14 +12,22 @@ 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}
|
||||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
secret=$(ynh_app_setting_get $app secret)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_user=$db_name
|
||||
db_pwd=$(ynh_app_setting_get $app psqlpwd)
|
||||
theme=$(ynh_app_setting_get $app theme)
|
||||
hashed_password=$(ynh_app_setting_get $app hashed_password)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF ARGUMENTS ARE CORRECT
|
||||
|
@ -41,27 +49,41 @@ fi
|
|||
#=================================================
|
||||
# MOVE TO PUBLIC OR PRIVATE
|
||||
#=================================================
|
||||
|
||||
ynh_backup_if_checksum_is_different "$final_path/lstu.conf"
|
||||
cp conf/lstu.conf.template "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__PATH__" "$path_url" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__PORT__" "$port" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DB_NAME__" "$db_name" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DB_USER__" "$db_user" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__DB_PWD__" "$db_pwd" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__SELECTED_THEME__" "$theme" "${final_path}/lstu.conf"
|
||||
ynh_replace_string "__PASSWORD_HASHED__" "$hashed_password" "${final_path}/lstu.conf"
|
||||
|
||||
ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf"
|
||||
if [ $is_public -eq 0 ];
|
||||
then
|
||||
ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lstu.conf"
|
||||
else
|
||||
ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lstu.conf"
|
||||
fi
|
||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
||||
|
||||
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 "/"
|
||||
ynh_app_setting_set $app unprotected_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/$"
|
||||
ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$"
|
||||
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
|
||||
|
||||
|
@ -71,12 +93,9 @@ 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
|
||||
|
|
|
@ -130,6 +130,12 @@ ynh_replace_string "__PASSWORD_HASHED__" "$hashed_password" "${final_path}/lstu.
|
|||
secret=$(ynh_string_random 24)
|
||||
ynh_app_setting_set $app secret $secret
|
||||
ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf"
|
||||
if [ $is_public -eq 0 ];
|
||||
then
|
||||
ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lstu.conf"
|
||||
else
|
||||
ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lstu.conf"
|
||||
fi
|
||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
||||
|
||||
#=================================================
|
||||
|
@ -165,19 +171,14 @@ yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/pro
|
|||
#=================================================
|
||||
|
||||
# Make app public or private
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
ynh_app_setting_set $app unprotected_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/$"
|
||||
ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$"
|
||||
else
|
||||
ynh_app_setting_delete $app protected_regex
|
||||
fi
|
||||
|
||||
config_file_is_public
|
||||
|
||||
#=================================================
|
||||
# Configure owner
|
||||
#=================================================
|
||||
|
@ -197,3 +198,4 @@ ynh_systemd_action -n $app -a start -l "Server available at" -p "systemd"
|
|||
|
||||
# Reload Nginx
|
||||
systemctl reload nginx
|
||||
yunohost app ssowatconf
|
||||
|
|
|
@ -122,6 +122,12 @@ ynh_replace_string "__SELECTED_THEME__" "$theme" "${final_path}/lstu.conf"
|
|||
ynh_replace_string "__PASSWORD_HASHED__" "$hashed_password" "${final_path}/lstu.conf"
|
||||
|
||||
ynh_replace_string "__SECRET__" "$secret" "${final_path}/lstu.conf"
|
||||
if [ $is_public -eq 0 ];
|
||||
then
|
||||
ynh_replace_string "__IS_PUBLIC__" "" "${final_path}/lstu.conf"
|
||||
else
|
||||
ynh_replace_string "__IS_PUBLIC__" "#" "${final_path}/lstu.conf"
|
||||
fi
|
||||
ynh_store_file_checksum "${final_path}/lstu.conf"
|
||||
|
||||
#=================================================
|
||||
|
@ -169,19 +175,14 @@ ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "s
|
|||
#=================================================
|
||||
|
||||
# Make app public or private
|
||||
ynh_app_setting_set $app skipped_uris "/"
|
||||
ynh_app_setting_set $app unprotected_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/$"
|
||||
ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$"
|
||||
else
|
||||
ynh_app_setting_delete $app protected_regex
|
||||
fi
|
||||
|
||||
config_file_is_public
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue