From c2bedff12cf03c636611495ea5b29f34c0a905db Mon Sep 17 00:00:00 2001 From: Amo Date: Tue, 1 Jun 2021 22:29:51 +0530 Subject: [PATCH] Use git with tags and an option to force upgrade for user --- check_process | 3 ++- manifest.json | 9 +++++++++ scripts/_common.sh | 3 +++ scripts/install | 5 +++-- scripts/upgrade | 21 ++++++++++++++++++--- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/check_process b/check_process index 23c886c..478cacc 100644 --- a/check_process +++ b/check_process @@ -9,7 +9,8 @@ admin="john" (USER) registration=1 is_public=1 (PUBLIC|public=1|private=0) - ; Checks + update=0 + ; Checks pkg_linter=1 setup_sub_dir=0 setup_root=1 diff --git a/manifest.json b/manifest.json index 9629ff5..69642c0 100644 --- a/manifest.json +++ b/manifest.json @@ -68,6 +68,15 @@ "cs": "Mohou se noví uživatelé registrovat?" }, "default": false + }, + { + + "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 c6f97cf..32558b8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,9 @@ # COMMON VARIABLES #================================================= +# Latest tag +latest_tag=$(curl -s https://api.github.com/repos/kevinpapst/kimai2/releases/latest | grep 'tag_name' | cut -d\" -f4) +tag="1.14.3" # dependencies used by the app pkg_dependencies="" diff --git a/scripts/install b/scripts/install index f648bde..06d8e7b 100755 --- a/scripts/install +++ b/scripts/install @@ -31,6 +31,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC registration=$YNH_APP_ARG_REGISTRATION random_key=$(ynh_string_random 32) app=$YNH_APP_INSTANCE_NAME +update=$YNH_APP_ARG_UPDATE #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -54,6 +55,7 @@ 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=registration --value=$registration ynh_app_setting_set --app=$app --key=random_key --value=$random_key +ynh_app_setting_set --app=$app --key=update --value=$update #================================================= # STANDARD MODIFICATIONS @@ -72,9 +74,8 @@ ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Clone the latest version -latest_tag=$(curl -s https://api.github.com/repos/kevinpapst/kimai2/releases/latest | grep 'tag_name' | cut -d\" -f4) -git clone -b $latest_tag --depth 1 https://github.com/kevinpapst/kimai2.git $final_path +git clone -b $tag --depth 1 https://github.com/kevinpapst/kimai2.git $final_path #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 5830c99..0653907 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,7 @@ is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) registration=$(ynh_app_setting_get --app=$app --key=registration) random_key=$(ynh_app_setting_get --app=$app --key=random_key) +update=$(ynh_app_setting_get --app=$app --key=update) #================================================= # CHECK VERSION @@ -76,8 +77,14 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then if [ `cd $final_path && git rev-parse --is-inside-work-tree` ]; then pushd "$final_path" - git fetch --tags - git checkout $latest_tag + if [ $update -eq 1 ] + then + git fetch --tags + git checkout $latest_tag + else + git fetch --tags + git checkout $tag + fi popd else ynh_script_progression --message="Upgrading source files..." @@ -97,7 +104,15 @@ 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/kevinpapst/kimai2.git $final_path + else + git clone -b $tag --depth 1 https://github.com/kevinpapst/kimai2.git $final_path + fi + + + # Restore config if [ -f $tmpdir/local.yaml ]; then