diff --git a/conf/lstu.conf.template b/conf/lstu.conf.template index e5be2ad..2a70fbd 100644 --- a/conf/lstu.conf.template +++ b/conf/lstu.conf.template @@ -178,14 +178,14 @@ # set `ldap` if you want that only authenticated users can shorten URLs # please note that everybody can still use shortend URLs # optional, no default - ldap => { - uri => 'ldap://localhost:389', # server URI - user_tree => 'dc=yunohost,dc=org', # search base DN - bind_dn => 'ou=users,dc=yunohost,dc=org', # search bind DN - # bind_pwd => '', # search bind password - user_attr => 'uid', # user attribute (uid, mail, sAMAccountName, etc.) - # user_filter => '(!(uid=ldap_user))', # user filter (to exclude some users, etc.) - }, #end of ldap conf + __IS_PUBLIC__ldap => { + __IS_PUBLIC__ uri => 'ldap://localhost:389', # server URI + __IS_PUBLIC__ user_tree => 'dc=yunohost,dc=org', # search base DN + __IS_PUBLIC__ bind_dn => 'ou=users,dc=yunohost,dc=org', # search bind DN + __IS_PUBLIC__# bind_pwd => '', # search bind password + __IS_PUBLIC__ user_attr => 'uid', # user attribute (uid, mail, sAMAccountName, etc.) + __IS_PUBLIC__# user_filter => '(!(uid=ldap_user))', # user filter (to exclude some users, etc.) + __IS_PUBLIC__}, # 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` diff --git a/scripts/_common.sh b/scripts/_common.sh index b41d451..a69356d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,7 +1,17 @@ #!/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 diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 337c444..afe4749 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -55,24 +55,12 @@ then # If the app is private, only the shortened URLs are publics 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_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 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 +config_file_is_public + ynh_script_progression --message="Reconfigure SSOwat" # Regen ssowat configuration yunohost app ssowatconf diff --git a/scripts/install b/scripts/install index 3986617..b987ef8 100644 --- a/scripts/install +++ b/scripts/install @@ -172,24 +172,12 @@ then # If the app is private, only the shortened URLs are publics 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_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 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 +config_file_is_public + #================================================= # Configure owner #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9b41bb3..b2b32df 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -176,24 +176,12 @@ then # If the app is private, only the shortened URLs are publics 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_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 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 +config_file_is_public + #================================================= # RELOAD NGINX #=================================================