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

refactor is_public config file

This commit is contained in:
Pierre Bourré 2019-02-15 15:02:34 +01:00
parent 3f6129248d
commit 8fa8e8d7a6
5 changed files with 26 additions and 52 deletions

View file

@ -178,14 +178,14 @@
# set `ldap` if you want that only authenticated users can shorten URLs # set `ldap` if you want that only authenticated users can shorten URLs
# please note that everybody can still use shortend URLs # please note that everybody can still use shortend URLs
# optional, no default # optional, no default
ldap => { __IS_PUBLIC__ldap => {
uri => 'ldap://localhost:389', # server URI __IS_PUBLIC__ uri => 'ldap://localhost:389', # server URI
user_tree => 'dc=yunohost,dc=org', # search base DN __IS_PUBLIC__ user_tree => 'dc=yunohost,dc=org', # search base DN
bind_dn => 'ou=users,dc=yunohost,dc=org', # search bind DN __IS_PUBLIC__ bind_dn => 'ou=users,dc=yunohost,dc=org', # search bind DN
# bind_pwd => '', # search bind password __IS_PUBLIC__# bind_pwd => '', # search bind password
user_attr => 'uid', # user attribute (uid, mail, sAMAccountName, etc.) __IS_PUBLIC__ user_attr => 'uid', # user attribute (uid, mail, sAMAccountName, etc.)
# user_filter => '(!(uid=ldap_user))', # user filter (to exclude some users, etc.) __IS_PUBLIC__# user_filter => '(!(uid=ldap_user))', # user filter (to exclude some users, etc.)
}, #end of ldap conf __IS_PUBLIC__},
# set `htpasswd` if you want to use an htpasswd file instead of ldap # set `htpasswd` if you want to use an htpasswd file instead of ldap
# create the file with `htpasswd -c lstu.passwd user`, update it with `htpasswd lstu.passwd user2` # create the file with `htpasswd -c lstu.passwd user`, update it with `htpasswd lstu.passwd user2`

View file

@ -1,7 +1,17 @@
#!/bin/bash #!/bin/bash
set_config_file() { 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 # Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started

View file

@ -55,24 +55,12 @@ then # If the app is private, only the shortened URLs are publics
path_url="" path_url=""
fi 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 "$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_replace_string "#ldap => {" "ldap => {" "${final_path}/lstu.conf"
ynh_replace_string "#uri => 'ldap://localhost:389'," "uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
ynh_replace_string "#user_tree => 'dc=yunohost,dc=org'," "user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "#user_attr => 'uid'," "user_attr => 'uid'," "${final_path}/lstu.conf"
ynh_replace_string "#}, #end of ldap conf" "}, #end of ldap conf" "${final_path}/lstu.conf"
else else
ynh_app_setting_delete $app protected_regex ynh_app_setting_delete $app protected_regex
ynh_replace_string "ldap => {" "#ldap => {" "${final_path}/lstu.conf"
ynh_replace_string "uri => 'ldap://localhost:389'," "#uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
ynh_replace_string "user_tree => 'dc=yunohost,dc=org'," "#user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "bind_dn => 'ou=users,dc=yunohost,dc=org'," "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "user_attr => 'uid'," "#user_attr => 'uid'," "${final_path}/lstu.conf"
ynh_replace_string "}, #end of ldap conf" "#}, #end of ldap conf" "${final_path}/lstu.conf"
fi fi
config_file_is_public
ynh_script_progression --message="Reconfigure SSOwat" ynh_script_progression --message="Reconfigure SSOwat"
# Regen ssowat configuration # Regen ssowat configuration
yunohost app ssowatconf yunohost app ssowatconf

View file

@ -172,24 +172,12 @@ then # If the app is private, only the shortened URLs are publics
path_url="" path_url=""
fi 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 "$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_replace_string "#ldap => {" "ldap => {" "${final_path}/lstu.conf"
ynh_replace_string "#uri => 'ldap://localhost:389'," "uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
ynh_replace_string "#user_tree => 'dc=yunohost,dc=org'," "user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "#user_attr => 'uid'," "user_attr => 'uid'," "${final_path}/lstu.conf"
ynh_replace_string "#}, #end of ldap conf" "}, #end of ldap conf" "${final_path}/lstu.conf"
else else
ynh_app_setting_delete $app protected_regex ynh_app_setting_delete $app protected_regex
ynh_replace_string "ldap => {" "#ldap => {" "${final_path}/lstu.conf"
ynh_replace_string "uri => 'ldap://localhost:389'," "#uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
ynh_replace_string "user_tree => 'dc=yunohost,dc=org'," "#user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "bind_dn => 'ou=users,dc=yunohost,dc=org'," "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "user_attr => 'uid'," "#user_attr => 'uid'," "${final_path}/lstu.conf"
ynh_replace_string "}, #end of ldap conf" "#}, #end of ldap conf" "${final_path}/lstu.conf"
fi fi
config_file_is_public
#================================================= #=================================================
# Configure owner # Configure owner
#================================================= #=================================================

View file

@ -176,24 +176,12 @@ then # If the app is private, only the shortened URLs are publics
path_url="" path_url=""
fi 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 "$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_replace_string "#ldap => {" "ldap => {" "${final_path}/lstu.conf"
ynh_replace_string "#uri => 'ldap://localhost:389'," "uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
ynh_replace_string "#user_tree => 'dc=yunohost,dc=org'," "user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "#user_attr => 'uid'," "user_attr => 'uid'," "${final_path}/lstu.conf"
ynh_replace_string "#}, #end of ldap conf" "}, #end of ldap conf" "${final_path}/lstu.conf"
else else
ynh_app_setting_delete $app protected_regex ynh_app_setting_delete $app protected_regex
ynh_replace_string "ldap => {" "#ldap => {" "${final_path}/lstu.conf"
ynh_replace_string "uri => 'ldap://localhost:389'," "#uri => 'ldap://localhost:389'," "${final_path}/lstu.conf"
ynh_replace_string "user_tree => 'dc=yunohost,dc=org'," "#user_tree => 'dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "bind_dn => 'ou=users,dc=yunohost,dc=org'," "#bind_dn => 'ou=users,dc=yunohost,dc=org'," "${final_path}/lstu.conf"
ynh_replace_string "user_attr => 'uid'," "#user_attr => 'uid'," "${final_path}/lstu.conf"
ynh_replace_string "}, #end of ldap conf" "#}, #end of ldap conf" "${final_path}/lstu.conf"
fi fi
config_file_is_public
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================