From 94859076b540c50b4496c5d0b0d489f777acd2ac Mon Sep 17 00:00:00 2001 From: Amo Date: Tue, 1 Jun 2021 23:34:25 +0530 Subject: [PATCH] Git for install and update --- check_process | 1 + manifest.json | 134 +++++++++++++++++++++++---------------------- scripts/_common.sh | 4 ++ scripts/install | 13 +++-- scripts/upgrade | 21 ++++++- 5 files changed, 100 insertions(+), 73 deletions(-) diff --git a/check_process b/check_process index 189ba42..84078dd 100644 --- a/check_process +++ b/check_process @@ -7,6 +7,7 @@ path="/path" (PATH) admin="john" (USER) is_public=1 (PUBLIC|public=1|private=0) + update=0 ; Checks pkg_linter=1 setup_sub_dir=1 diff --git a/manifest.json b/manifest.json index 7d771e9..0278f7c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,67 +1,71 @@ { - "name": "Firefly III", - "id": "firefly-iii", - "packaging_format": 1, - "description": { - "en": "Self-hosted financial manager.", - "fr": "Gestionnaire de finances personnelles." - }, - "version": "5.5.11~ynh2", - "url": "https://firefly-iii.org/", - "license": "GPL-3.0-or-later", - "maintainer": { - "name": "Anmol Sharma", - "email": "anmol@datamol.org", - "url": "https://datamol.org" - }, - "requirements": { - "yunohost": ">= 4.1.0" - }, - "multi_instance": true, - "services": [ - "nginx", - "php7.0-fpm", - "mysql" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain for Firefly III", - "fr": "Choisissez un nom de domaine pour Firefly III" - }, - "example": "example.com" - }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for Firefly III", - "fr": "Choisissez un chemin pour Firefly III" - }, - "example": "/example", - "default": "/firefly" - }, - { - "name": "admin", - "type": "user", - "ask": { - "en": "Choose an admin user (should be a YunoHost registered user)", - "fr": "Choisissez l’administrateur (should be a YunoHost registered user)" - }, - "example": "johndoe" - }, - { - "name": "is_public", - "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, - "default": true - } - ] - } + "name": "Firefly III", + "id": "firefly-iii", + "packaging_format": 1, + "description": { + "en": "Self-hosted financial manager.", + "fr": "Gestionnaire de finances personnelles." + }, + "version": "5.5.11~ynh2", + "url": "https://firefly-iii.org/", + "license": "GPL-3.0-or-later", + "maintainer": { + "name": "Anmol Sharma", + "email": "anmol@datamol.org", + "url": "https://datamol.org" + }, + "requirements": { + "yunohost": ">= 4.1.0" + }, + "multi_instance": true, + "services": ["nginx", "php7.0-fpm", "mysql"], + "arguments": { + "install": [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain for Firefly III", + "fr": "Choisissez un nom de domaine pour Firefly III" + }, + "example": "example.com" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Firefly III", + "fr": "Choisissez un chemin pour Firefly III" + }, + "example": "/example", + "default": "/firefly" + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Choose an admin user (should be a YunoHost registered user)", + "fr": "Choisissez l’administrateur (should be a YunoHost registered user)" + }, + "example": "johndoe" + }, + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" + }, + "default": true + }, + { + "name": "update", + "type": "boolean", + "ask": { + "en": "Making this option to true will give you an option to force upgrade to new version without the package being updated to that version. WARNING: This can be risky and break your app if specific version have additional steps than noraml upgrade. Keep the option false, if you are not sure." + }, + "default": false + } + ] + } } diff --git a/scripts/_common.sh b/scripts/_common.sh index 3ad3af3..7cb76ac 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,6 +5,10 @@ #================================================= # dependencies used by the app + +latest_tag=$(curl -s https://api.github.com/repos/firefly-iii/firefly-iii/releases/latest | grep 'tag_name' | cut -d\" -f4) +tag="5.5.11" + pkg_dependencies="redis-server" YNH_PHP_VERSION="7.4" diff --git a/scripts/install b/scripts/install index c2ef0ed..aa9c23c 100755 --- a/scripts/install +++ b/scripts/install @@ -27,7 +27,7 @@ admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC random_key=$(ynh_string_random --length=32) email=$(ynh_user_get_info --username=$admin --key=mail) - +update=$YNH_APP_ARG_UPDATE app=$YNH_APP_INSTANCE_NAME #================================================= @@ -46,11 +46,12 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= ynh_script_progression --message="Storing installation settings..." -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=is_public --value=$is_public +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=is_public --value=$is_public ynh_app_setting_set --app=$app --key=random_key --value=$random_key +ynh_app_setting_set --app=$app --key=update --value=$update #================================================= # INSTALL DEPENDENCIES @@ -76,7 +77,7 @@ ynh_script_progression --message="Cloning Firefly-iii..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path -git clone https://github.com/firefly-iii/firefly-iii.git $final_path +git clone -b $tag --depth 1 https://github.com/firefly-iii/firefly-iii.git $final_path #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 0d2bdc8..8f1a1b9 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,6 +26,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) random_key=$(ynh_app_setting_get --app=$app --key=random_key) email=$(ynh_user_get_info --username=$admin --key=mail) +update=$(ynh_app_setting_get --app=$app --key=update) #================================================= # CHECK VERSION @@ -92,7 +93,14 @@ then if [ `cd $final_path && git rev-parse --is-inside-work-tree` ]; then pushd "$final_path" - git pull + if [ $update -eq 1 ] + then + git fetch --tags + git checkout $latest_tag + else + git fetch --tags + git checkout $tag + fi ynh_secure_remove bootstrap/cache/* ynh_secure_remove vendor/ popd @@ -112,7 +120,16 @@ then ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + if [ $update -eq 1 ] + then + + git clone -b $latest_tag --depth 1 https://github.com/firefly-iii/firefly-iii.git $final_path + + else + git clone -b $tag --depth 1 https://github.com/firefly-iii/firefly-iii.git $final_path + + fi + ynh_secure_remove bootstrap/cache/* # Restore the config file and data mkdir -p "$final_path/storage/upload/"