diff --git a/README.md b/README.md index 78d1b93..f2a4b9c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Kimai2 app for YunoHost -[![Integration level](https://dash.yunohost.org/integration/kimai2.svg)](https://dash.yunohost.org/appci/app/kimai2) ![](https://ci-apps.yunohost.org/ci/badges/kimai2.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/kimai2.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/kimai2.svg)](https://dash.yunohost.org/appci/app/kimai2) ![](https://ci-apps.yunohost.org/ci/badges/kimai2.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/kimai2.maintain.svg) + [![Install Kimai2 with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=kimai2) > *This package allows you to install kimai2 quickly and simply on a YunoHost server. @@ -12,7 +13,7 @@ This is the reloaded version of the open source timetracker Kimai. Right now its Kimai v2 has nothing in common with its predecessor Kimai v1 besides the basic ideas of time-tracking and the current development team. It is based on a lot of great frameworks. Special thanks to Symfony v4, Doctrine, AdminThemeBundle (based on AdminLTE). https://github.com/kevinpapst/kimai2 -Shipped Version: **1.11.1** +Shipped Version: **1.14.3** ## Screenshots diff --git a/check_process b/check_process index 765d710..a1fa64f 100644 --- a/check_process +++ b/check_process @@ -7,10 +7,9 @@ ; Manifest domain="domain.tld" (DOMAIN) admin="john" (USER) - database="mysql" registration=1 is_public=1 (PUBLIC|public=1|private=0) - ; Checks + ; Checks pkg_linter=1 setup_sub_dir=0 setup_root=1 @@ -19,8 +18,9 @@ setup_public=1 upgrade=1 # 1.9~ynh1 - upgrade=1 from_commit=e5ce0d869526c6c856c1e2398b4b2ce0ba8e7542 - backup_restore=1 + upgrade=1 + from_commit=f26285511a167a1ed591a7fa96ae786ea89efb1e + backup_restore=1 multi_instance=1 # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. # incorrect_path=1 @@ -30,7 +30,7 @@ # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto ;;; Options -Email=anmol@datamol.org +Email= Notification=change ;;; Upgrade options ; commit=e5ce0d869526c6c856c1e2398b4b2ce0ba8e7542 diff --git a/conf/app.src b/conf/app.src index 05d59b1..39973ce 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/kevinpapst/kimai2/archive/1.11.1.tar.gz -SOURCE_SUM=ebca79e6fc4597a4a914a3005c3a450bbe956fd05fce8a4d962d9ca943589a28 +SOURCE_URL=https://github.com/kevinpapst/kimai2/archive/refs/tags/1.14.3.tar.gz +SOURCE_SUM=1a5d084fbac071ca7c5897ef439bd4bec5fb1f367e6f39b029917590110fda7d SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index b9f5043..0e90bae 100644 --- a/manifest.json +++ b/manifest.json @@ -8,16 +8,14 @@ "de": "Eine web-basierte Mehrbenutzer-Zeiterfassung mit Rechnungsdruck mit Unterstützung für mobile Endgeräte", "cs": "Víceuživatelská webová aplikace pro sledování času s podporou mobilních zařízení" }, - "version": "1.11.1~ynh1", + "version": "1.14.3~ynh1", "url": "https://www.kimai.org", "license": "MIT", "maintainer": { - "name": "Anmol Sharma", - "email": "anmol@datamol.org", - "url": "datamol.org" + "name": "Anmol Sharma" }, "requirements": { - "yunohost": ">= 3.8" + "yunohost": ">= 4.0.0" }, "multi_instance": true, "services": [ @@ -60,18 +58,6 @@ }, "default": false }, - { - "name": "database", - "type": "string", - "ask": { - "en": "Choose the database to use (for production usage choose: mysql)", - "fr": "Choisissez le type de base de données à utiliser (mysql pour un usage en production)", - "de": "Wählen Sie die zu nutzende Datenbank (für produktive Zwecke wähle: mysql)", - "cs": "Zvolte databázi (pro produkční použití vyberte: mysql)" - }, - "choices": ["mysql","sqlite"], - "default": "mysql" - }, { "name": "registration", "type": "boolean", @@ -82,7 +68,6 @@ "cs": "Mohou se noví uživatelé registrovat?" }, "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/backup b/scripts/backup index bc8674a..2b2278a 100755 --- a/scripts/backup +++ b/scripts/backup @@ -29,7 +29,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) -database=$(ynh_app_setting_get --app=$app --key=database) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -58,11 +57,11 @@ ynh_backup --src_path="/etc/php/${YNH_PHP_VERSION}/fpm/pool.d/$app.conf" # BACKUP THE MYSQL DATABASE #================================================= -if [ "$database" = "mysql" ]; then - ynh_print_info --message="Backing up the MySQL database..." - db_name=$(ynh_app_setting_get --app=$app --key=db_name) - ynh_mysql_dump_db --database="$db_name" > db.sql -fi + +ynh_print_info --message="Backing up the MySQL database..." +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +ynh_mysql_dump_db --database="$db_name" > db.sql + #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index fa80023..e1a6cee 100755 --- a/scripts/install +++ b/scripts/install @@ -29,10 +29,9 @@ path_url="/" admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC registration=$YNH_APP_ARG_REGISTRATION -database=$YNH_APP_ARG_DATABASE random_key=$(ynh_string_random 32) - app=$YNH_APP_INSTANCE_NAME +update=0 #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -50,13 +49,13 @@ 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=registration --value=$registration -ynh_app_setting_set --app=$app --key=database --value=$database -ynh_app_setting_set --app=$app --key=random_key --value=$random_key +ynh_app_setting_set --app=$app --key=random_key --value=$random_key +ynh_app_setting_set --app=$app --key=update --value=$update #================================================= # STANDARD MODIFICATIONS @@ -73,8 +72,10 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" + +# Clone the latest version + +git clone -b $tag --depth 1 https://github.com/kevinpapst/kimai2.git $final_path #================================================= # NGINX CONFIGURATION @@ -110,34 +111,28 @@ ynh_script_progression --message="Configuring Kimai2..." local_conf="$final_path/config/packages/local.yaml" # Configure registration cp ../conf/local.yaml $local_conf -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$local_conf" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$local_conf" + +# Registration should be allowed or not if [ $registration -eq 1 ] then - ynh_replace_string --match_string="__REGISTRATION__" --replace_string="true" --target_file="$local_conf" + ynh_replace_string --match_string="__REGISTRATION__" --replace_string="true" --target_file="$local_conf" else ynh_replace_string --match_string="__REGISTRATION__" --replace_string="false" --target_file="$local_conf" fi env_conf="$final_path/.env" -# Configure environement -if [ "$database" = "mysql" ]; then - # setup application config - cp ../conf/.env.mysql $env_conf - db_name=$(ynh_sanitize_dbid --db_name=$app) - db_user=$db_name - ynh_app_setting_set --app=$app --key=db_name --value=$db_name - ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name - ynh_replace_string --match_string="__RANDOM_KEY__" --replace_string="$random_key" --target_file="$env_conf" - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$env_conf" - ynh_replace_string --match_string="__DB_PASSWORD__" --replace_string="$db_pwd" --target_file="$env_conf" - ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$env_conf" - ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$env_conf" -else - # setup application config - cp ../conf/.env.sqlite $env_conf - ynh_replace_string --match_string="__RANDOM_KEY__" --replace_string="$random_key" --target_file="$env_conf" - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$env_conf" -fi +# setup application config +cp ../conf/.env.mysql $env_conf +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name +ynh_replace_string --match_string="__RANDOM_KEY__" --replace_string="$random_key" --target_file="$env_conf" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$env_conf" +ynh_replace_string --match_string="__DB_PASSWORD__" --replace_string="$db_pwd" --target_file="$env_conf" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$env_conf" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$env_conf" #================================================= # BUILD KIMAI2 diff --git a/scripts/remove b/scripts/remove index 7e410b0..a971096 100755 --- a/scripts/remove +++ b/scripts/remove @@ -18,7 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -database=$(ynh_app_setting_get --app=$app --key=database) + #================================================= # STANDARD REMOVE @@ -26,13 +26,13 @@ database=$(ynh_app_setting_get --app=$app --key=database) # REMOVE THE MYSQL DATABASE #================================================= -if [ "$database" = "mysql" ]; then - ynh_script_progression --message="Removing the MySQL database..." - db_name=$(ynh_app_setting_get --app=$app --key=db_name) - db_user=$db_name - # Remove a database if it exists, along with the associated user - ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name -fi + +ynh_script_progression --message="Removing the MySQL database..." +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +# Remove a database if it exists, along with the associated user +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name + #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index b3bda5a..c9ddafa 100755 --- a/scripts/restore +++ b/scripts/restore @@ -30,7 +30,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) final_path=$(ynh_app_setting_get --app=$app --key=final_path) -database=$(ynh_app_setting_get --app=$app --key=database) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -99,14 +98,12 @@ ynh_install_app_dependencies $pkg_dependencies # RESTORE THE MYSQL DATABASE #================================================= -if [ "$database" = "mysql" ]; then - ynh_script_progression --message="Restoring the MySQL database..." - db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - db_name=$(ynh_app_setting_get --app=$app --key=db_name) - db_user=$db_name - ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd - ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql -fi +ynh_script_progression --message="Restoring the MySQL database..." +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index ebf44e1..d2ce465 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,14 +17,14 @@ ynh_script_progression --message="Loading installation settings..." 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) +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) registration=$(ynh_app_setting_get --app=$app --key=registration) -database=$(ynh_app_setting_get --app=$app --key=database) -random_key=$(ynh_app_setting_get --app=$app --key=random_key) +random_key=$(ynh_app_setting_get --app=$app --key=random_key) +update=$(ynh_app_setting_get --app=$app --key=update) #================================================= # CHECK VERSION @@ -72,9 +72,21 @@ ynh_abort_if_errors #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= - +latest_tag=$(curl -s https://api.github.com/repos/kevinpapst/kimai2/releases/latest | grep 'tag_name' | cut -d\" -f4) if [ "$upgrade_type" == "UPGRADE_APP" ] then + if [ `cd $final_path && git rev-parse --is-inside-work-tree` ]; then + pushd "$final_path" + if [ $update -eq 1 ] + then + git fetch origin tag $latest_tag --no-tags + git checkout $latest_tag + else + git fetch origin tag $tag --no-tags + git checkout $tag + fi + popd + else ynh_script_progression --message="Upgrading source files..." # Create a temporary directory and backup config @@ -92,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 @@ -106,8 +126,10 @@ then fi ynh_secure_remove --file="$tmpdir" + fi fi + #================================================= # NGINX CONFIGURATION #================================================= @@ -161,23 +183,20 @@ ynh_store_file_checksum --file="$local_conf" env_conf=$final_path/.env ynh_backup_if_checksum_is_different --file="$env_conf" # Configure environement -if [ "$database" = "mysql" ]; then - # setup application config - cp ../conf/.env.mysql $env_conf - db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - db_name=$(ynh_app_setting_get --app=$app --key=db_name) - db_user=$db_name - ynh_replace_string --match_string="__RANDOM_KEY__" --replace_string="$random_key" --target_file="$env_conf" - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$env_conf" - ynh_replace_string --match_string="__DB_PASSWORD__" --replace_string="$db_pwd" --target_file="$env_conf" - ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$env_conf" - ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$env_conf" -else - # setup application config - cp ../conf/.env.sqlite $env_conf - ynh_replace_string --match_string="__RANDOM_KEY__" --replace_string="$random_key" --target_file="$env_conf" - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$env_conf" -fi + +# setup application config + +cp ../conf/.env.mysql $env_conf + +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name +ynh_replace_string --match_string="__RANDOM_KEY__" --replace_string="$random_key" --target_file="$env_conf" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$env_conf" +ynh_replace_string --match_string="__DB_PASSWORD__" --replace_string="$db_pwd" --target_file="$env_conf" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$env_conf" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$env_conf" + ynh_store_file_checksum --file="$env_conf" #=================================================