From aaf722cd848a5b50c5eb98343107ee09d0465d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 16 Mar 2021 17:46:33 +0100 Subject: [PATCH] Cleaning up (#10) --- conf/config.php | 2 +- manifest.json | 16 ++-------------- scripts/change_url | 5 ----- scripts/install | 17 +++++++++-------- scripts/restore | 1 - scripts/upgrade | 22 +++++----------------- 6 files changed, 17 insertions(+), 46 deletions(-) diff --git a/conf/config.php b/conf/config.php index b2fabe5..fd82888 100755 --- a/conf/config.php +++ b/conf/config.php @@ -10,7 +10,7 @@ $config['db'] = 'mysql'; $config['mysql.host'] = "localhost"; $config['mysql.db'] = "__DB_NAME__"; $config['mysql.user'] = "__DB_NAME__"; -$config['mysql.password'] = "__DB_PASSWORD__"; +$config['mysql.password'] = "__DB_PWD__"; # Tables prefix $config['prefix'] = "mtt_"; diff --git a/manifest.json b/manifest.json index 8404194..eac3e08 100644 --- a/manifest.json +++ b/manifest.json @@ -8,13 +8,13 @@ }, "url": "http://www.mytinytodo.net/", "license": "GPL-2.0", - "version": "1.6.3~ynh1", + "version": "1.6.3~ynh2", "maintainer": { "name": "plabuse", "email": "pierre.levasseur@free.fr" }, "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 4.1.7" }, "multi_instance": false, "services": [ @@ -27,29 +27,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for myTinyTodo", - "fr": "Choisissez un nom de domaine pour myTinyTodo" - }, "example": "domaine.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for myTinyTodo", - "fr": "Choisissez un chemin pour myTinyTodo" - }, "example": "/mytinytodo", "default": "/mytinytodo" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "help": { "en": "If enabled, myTinyTodo will be accessible by people who do not have an account. This can be changed later via the webadmin.", "fr": "Si cette case est cochée, myTinyTodo sera accessible aux personnes n’ayant pas de compte. Vous pourrez changer ceci plus tard via la webadmin." diff --git a/scripts/change_url b/scripts/change_url index e06912d..6c0d39c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,11 +29,6 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= diff --git a/scripts/install b/scripts/install index 7a005a5..c67ddac 100644 --- a/scripts/install +++ b/scripts/install @@ -45,7 +45,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 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=is_public --value=$is_public ynh_app_setting_set --app=$app --key=language --value=$language #================================================= @@ -104,12 +103,14 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) # # la nom de la base et l'utilisateur de la base on la même valeur # # mise en place de la config de la base au niveau de myTinyTodo -cp ../conf/config.php $final_path/db/config.php +# cp ../conf/config.php $final_path/db/config.php + +# ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/db/config.php" +# ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/db/config.php" +# ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/db/config.php" + +ynh_add_config --template="../conf/config.php" --destination="$final_path/db/config.php" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/db/config.php" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/db/config.php" -ynh_replace_string --match_string="__DB_PASSWORD__" --replace_string="$db_pwd" --target_file="$final_path/db/config.php" - ynh_secure_remove --file="$final_path/setup.php" ynh_secure_remove --file="$final_path/db/todolist.db" @@ -127,12 +128,12 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary or protect it if [ $is_public -eq 1 ] then - ynh_permission_update --permission "main" --add "visitors" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/restore b/scripts/restore index d75d17e..3491624 100644 --- a/scripts/restore +++ b/scripts/restore @@ -25,7 +25,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name diff --git a/scripts/upgrade b/scripts/upgrade index 50f390b..2bf5c41 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) language=$(ynh_app_setting_get --app=$app --key=language) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -36,23 +35,12 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -# -# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* -# of what you may want to do in some cases (e.g. a setting was not defined on -# some legacy installs and you therefore want to initiaze stuff during upgrade) -# +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all -# 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 -#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 -#fi + ynh_app_setting_delete --app=$app --key=is_public +fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP