diff --git a/check_process b/check_process index 37569a9..b7a8b6c 100644 --- a/check_process +++ b/check_process @@ -30,4 +30,4 @@ Level 7=auto Level 8=0 Level 9=0 - Level 10=0 + Level 10=0 diff --git a/scripts/_common.sh b/scripts/_common.sh index a69356d..ecb2ba3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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] ] diff --git a/scripts/actions/public_private b/scripts/actions/public_private index afe4749..34ea183 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -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 diff --git a/scripts/install b/scripts/install index b987ef8..2b3f820 100644 --- a/scripts/install +++ b/scripts/install @@ -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 diff --git a/scripts/upgrade b/scripts/upgrade index b2b32df..3d45188 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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 #=================================================