1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lstu_ynh.git synced 2024-09-03 19:36:12 +02:00

Merge pull request #33 from YunoHost-Apps/testing

Fix public/private
This commit is contained in:
Kayou 2019-03-12 16:18:33 +01:00 committed by GitHub
commit 4633863c8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 21 deletions

View file

@ -6,7 +6,8 @@ After=network.target
[Service]
Type=simple
User=www-data
User=__APP__
Group=__APP__
RemainAfterExit=yes
Restart=always
RestartSec=10

View file

@ -2,7 +2,7 @@
"name": "Lstu",
"id": "lstu",
"packaging_format": 1,
"version": "0.21-4~ynh3",
"version": "0.21-4~ynh4",
"requirements": {
"yunohost": ">= 3.0"
},

View file

@ -76,10 +76,16 @@ else
public_private="public"
fi
ynh_app_setting_set $app unprotected_uris "/"
if [ $is_public -eq 0 ];
then # If the app is private, only the shortened URLs are publics
ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$"
if [ $is_public -eq 0 ]
then
# If the app is private, only the shortened URLs are publics.
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 protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
else
ynh_app_setting_delete $app protected_regex
fi

View file

@ -127,6 +127,23 @@ ynh_store_file_checksum "${final_path}/lstu.conf"
#=================================================
# GENERIC FINALISATION
#=================================================
# UPDATE SSOWAT
#=================================================
ynh_print_info "Reconfigure SSOwat"
if [ $is_public -eq 0 ]
then
# If the app is private, only the shortened URLs are publics.
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 protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
fi
#=================================================
# RESTART LSTU
#=================================================

View file

@ -182,20 +182,24 @@ yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/pro
#=================================================
ynh_print_info "Configuring SSOwat..."
# Make app public or private
ynh_app_setting_set $app unprotected_uris "/"
if [ $is_public -eq 0 ];
then # If the app is private, only the shortened URLs are publics
ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$"
else
ynh_app_setting_delete $app protected_regex
if [ $is_public -eq 0 ]
then
# If the app is private, only the shortened URLs are publics.
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 protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
fi
#=================================================
# Configure owner
#=================================================
chown -R www-data $final_path
chown -R $app:$app "$final_path"
#=================================================
# Start lstu

View file

@ -91,7 +91,7 @@ ynh_psql_connect_as $db_name $db_pwd $db_name < ./db.sql
#=================================================
# Restore permissions on app files
chown -R www-data $final_path
chown -R $app:$app "$final_path"
#=================================================
# SPECIFIC RESTORATION

View file

@ -153,7 +153,7 @@ ynh_store_file_checksum "${final_path}/lstu.conf"
# SECURING FILES AND DIRECTORIES
#=================================================
chown -R www-data $final_path
chown -R $app:$app "$final_path"
#=================================================
# SETUP SYSTEMD
@ -196,13 +196,17 @@ ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "s
#=================================================
ynh_print_info "Upgrading SSOwat configuration..."
# Make app public or private
ynh_app_setting_set $app unprotected_uris "/"
if [ $is_public -eq 0 ];
then # If the app is private, only the shortened URLs are publics
ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$"
else
ynh_app_setting_delete $app protected_regex
if [ $is_public -eq 0 ]
then
# If the app is private, only the shortened URLs are publics.
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 protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$"
fi
#=================================================