diff --git a/scripts/install b/scripts/install index 29f9805..ad94c8c 100644 --- a/scripts/install +++ b/scripts/install @@ -53,7 +53,6 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=admin_password --value=$admin_password -ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=wiki_name --value=$wiki_name @@ -181,6 +180,8 @@ ynh_replace_string --target_file="$final_path/LocalSettings.php" --match_string= chown -R $app:www-data "$final_path" +#================================================= +# GENERIC FINALIZATION #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 989eb36..f258818 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,23 +19,15 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app="$app" --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) -wiki_name=$(ynh_app_setting_get --app=$app --key=wiki_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - -# Note(decentral1se): avoid using this on upgrade for the versions -# of the application that upgrade and have not stored this in their -# settings (when it was not available to them). Later on, when we have -# moved a few versions on, we can re-enable this -# wiki_name=$(ynh_app_setting_get --app=$app --key=wiki_name) +wiki_name=$(ynh_app_setting_get --app=$app --key=wiki_name) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -60,30 +52,33 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - # If db_name doesn't exist, create it if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value="$db_name" + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi # If final_path doesn't exist, create it if [ -z "$final_path" ]; then - final_path="/var/www/$app" - ynh_app_setting_set --app=$app --key=final_path --value="$final_path" + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +if ! ynh_permission_exists --permission="admin"; then + # Create the required permissions + ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin +fi + +# Create a permission if needed +if ! ynh_permission_exists --permission="api"; then + ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" fi #=================================================