diff --git a/check_process b/check_process index f514ce4..79c22d7 100644 --- a/check_process +++ b/check_process @@ -1,8 +1,8 @@ ;; Test complet mysql ; Manifest domain="domain.tld" - admin="john" is_public=1 + admin="john" database="mysql" registration=1 ; Checks @@ -17,6 +17,8 @@ upgrade=1 from_commit=22580412fae14859f661c1f9b54a3131a60c9323 # 1.11.1~ynh1 upgrade=1 from_commit=f26285511a167a1ed591a7fa96ae786ea89efb1e + # 1.17.1~ynh1 + upgrade=1 from_commit=6b3ab38a5bf6aa48aaef23254381e8063839598b backup_restore=1 multi_instance=1 port_already_use=0 @@ -24,8 +26,8 @@ ;; Test complet sqlite ; Manifest domain="domain.tld" - admin="john" is_public=1 + admin="john" database="sqlite" registration=1 ; Checks @@ -40,6 +42,8 @@ upgrade=1 from_commit=22580412fae14859f661c1f9b54a3131a60c9323 # 1.11.1~ynh1 upgrade=1 from_commit=f26285511a167a1ed591a7fa96ae786ea89efb1e + # 1.17.1~ynh1 + upgrade=1 from_commit=6b3ab38a5bf6aa48aaef23254381e8063839598b backup_restore=1 multi_instance=1 port_already_use=0 @@ -47,8 +51,3 @@ ;;; Options Email=anmol@datamol.org Notification=change -;;; Upgrade options - ; commit=22580412fae14859f661c1f9b54a3131a60c9323 - name=1.9~ynh1 - ; commit=f26285511a167a1ed591a7fa96ae786ea89efb1e - name=1.11.1~ynh1 diff --git a/conf/.env.mysql b/conf/.env.mysql index 2a53aaf..a726ebb 100644 --- a/conf/.env.mysql +++ b/conf/.env.mysql @@ -5,8 +5,8 @@ ###> symfony/framework-bundle ### APP_ENV=prod APP_SECRET=__RANDOM_KEY__ -#TRUSTED_PROXIES=127.0.0.1,127.0.0.2 -#TRUSTED_HOSTS=localhost,example.com +TRUSTED_PROXIES=127.0.0.1 +TRUSTED_HOSTS=localhost,__DOMAIN__ ###< symfony/framework-bundle ### ###> doctrine/doctrine-bundle ### diff --git a/conf/.env.sqlite b/conf/.env.sqlite index c708414..7b1e34c 100644 --- a/conf/.env.sqlite +++ b/conf/.env.sqlite @@ -5,8 +5,8 @@ ###> symfony/framework-bundle ### APP_ENV=prod APP_SECRET=__RANDOM_KEY__ -#TRUSTED_PROXIES=127.0.0.1,127.0.0.2 -#TRUSTED_HOSTS=localhost,example.com +TRUSTED_PROXIES=127.0.0.1 +TRUSTED_HOSTS=localhost,__DOMAIN__ ###< symfony/framework-bundle ### ###> doctrine/doctrine-bundle ### diff --git a/conf/nginx.conf b/conf/nginx.conf index d219fe5..8c7ad9e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -3,9 +3,6 @@ root __FINALPATH__/public/ ; location __PATH__/ { - # Path to source - # alias __FINALPATH__/public/ ; - index index.php; # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file diff --git a/manifest.json b/manifest.json index ee19fb3..272b6c0 100644 --- a/manifest.json +++ b/manifest.json @@ -8,7 +8,7 @@ "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.17.1~ynh1", + "version": "1.17.1~ynh2", "url": "https://www.kimai.org", "upstream": { "license": "MIT", @@ -38,10 +38,6 @@ "name": "domain", "type": "domain" }, - { - "name": "admin", - "type": "user" - }, { "name": "is_public", "type": "boolean", @@ -53,6 +49,10 @@ }, "default": false }, + { + "name": "admin", + "type": "user" + }, { "name": "registration", "type": "boolean", diff --git a/scripts/_common.sh b/scripts/_common.sh index c6f97cf..9233b19 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,14 +5,10 @@ #================================================= # dependencies used by the app -pkg_dependencies="" - YNH_PHP_VERSION="7.3" - +pkg_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pdo php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-xsl php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3" YNH_COMPOSER_VERSION="2.0.4" -extra_php_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pdo php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-xsl php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 5b33202..50e3475 100755 --- a/scripts/install +++ b/scripts/install @@ -25,11 +25,11 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" -admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +admin=$YNH_APP_ARG_ADMIN registration=$YNH_APP_ARG_REGISTRATION database="mysql" -random_key=$(ynh_string_random 32) +random_key=$(ynh_string_random --length=32) app=$YNH_APP_INSTANCE_NAME @@ -71,7 +71,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A MYSQL DATABASE @@ -100,6 +100,15 @@ chown -R $app:www-data "$final_path" setfacl -dR -m g:"www-data":rwX -m u:$app:rwX "$final_path/var/" setfacl -R -m g:"www-data":rwX -m u:$app:rwX "$final_path/var/" +#================================================= +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring PHP-FPM..." + +# Create a dedicated PHP-FPM config +ynh_add_fpm_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + #================================================= # NGINX CONFIGURATION #================================================= @@ -108,15 +117,6 @@ ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring PHP-FPM..." - -# Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # SPECIFIC SETUP #================================================= diff --git a/scripts/restore b/scripts/restore index b23f90e..e852b04 100755 --- a/scripts/restore +++ b/scripts/restore @@ -45,13 +45,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -73,18 +66,6 @@ chown -R $app:www-data "$final_path" setfacl -dR -m g:"www-data":rwX -m u:$app:rwX "$final_path/var/" setfacl -R -m g:"www-data":rwX -m u:$app:rwX "$final_path/var/" -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." - -# Restore the file first, so it can have a backup if different -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -# Recreate a dedicated php-fpm config -ynh_add_fpm_config --package="$extra_php_dependencies" -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # SPECIFIC RESTORATION #================================================= @@ -95,6 +76,20 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the PHP-FPM configuration..." + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE MYSQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9205484..3a28f39 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,6 +34,17 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +if [ "$database" == "sqlite" ] +then + ynh_script_progression --message="Sqlite is not more supported by Kimai2..." + ynh_script_progression --message="Kimai2 will be upgrade to last available version : 1.13" + if ynh_compare_current_package_version --comparison ge --version 1.17.1~ynh1 + then + ynh_script_progression --message="Kimai2 sqlite version is already to the last available version, no upgrade will be made" + ynh_die "" 0 + fi +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -80,13 +91,18 @@ if ! ynh_permission_exists --permission="super_admin"; then ynh_permission_create --permission="super_admin" --allowed="$admin" fi +if [ -z "$registration" ]; then + registration_enabled="false" + ynh_app_setting_set --app=$app --key=registration --value=$registration +fi + #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -95,36 +111,9 @@ ynh_system_user_create --username=$app --home_dir=$final_path if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." - - # Create a temporary directory and backup config - tmpdir="$(mktemp -d)" - if [ -f $final_path/config/packages/local.yaml ]; then - cp -af "$final_path/config/packages/local.yaml" "$tmpdir/." - fi - if [ -d $final_path/var/invoices ]; then - cp -af "$final_path/var/invoices" "$tmpdir/." - fi - if [ -d $final_path/var/data ]; then - cp -af "$final_path/var/data" "$tmpdir/." - fi - - ynh_secure_remove --file="$final_path" - + # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --source_id="$database" - - # Restore config - if [ -f $tmpdir/local.yaml ]; then - cp -af "$tmpdir/local.yaml" "$final_path/config/packages/." - fi - if [ -d $tmpdir/invoices ]; then - cp -af "$tmpdir/invoices" "$final_path/var/." - fi - if [ -d $tmpdir/data ]; then - cp -af "$tmpdir/data" "$final_path/var/." - fi - - ynh_secure_remove --file="$tmpdir" + ynh_setup_source --dest_dir="$final_path" --source_id="$database" --keep="config/packages/local.yaml var/invoices/ var/data/" fi chmod 750 "$final_path" @@ -133,14 +122,6 @@ chown -R $app:www-data "$final_path" setfacl -dR -m g:"www-data":rwX -m u:$app:rwX "$final_path/var/" setfacl -R -m g:"www-data":rwX -m u:$app:rwX "$final_path/var/" -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - -# Create a dedicated NGINX config -ynh_add_nginx_config - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -154,9 +135,17 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Upgrading PHP-FPM configuration..." # Create a dedicated PHP-FPM config -ynh_add_fpm_config --package="$extra_php_dependencies" +ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." + +# Create a dedicated NGINX config +ynh_add_nginx_config + #================================================= # SPECIFIC UPGRADE #=================================================