1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kimai2_ynh.git synced 2024-09-03 19:26:26 +02:00
This commit is contained in:
ericgaspar 2021-09-27 08:08:35 +02:00
parent 4bb3cba14a
commit 4dfda47343
5 changed files with 26 additions and 77 deletions

View file

@ -5,7 +5,7 @@
#================================================= #=================================================
# Latest tag # Latest tag
latest_tag=$(curl -s https://api.github.com/repos/kevinpapst/kimai2/releases/latest | grep 'tag_name' | cut -d\" -f4) latest_tag=$(curl -s https://api.github.com/repos/kevinpapst/kimai2/releases/latest | grep 'tag_name' | cut -d\" -f4 2>&1)
tag="1.15.2" tag="1.15.2"
YNH_PHP_VERSION="7.3" YNH_PHP_VERSION="7.3"

View file

@ -56,7 +56,7 @@ ynh_app_setting_set --app=$app --key=update --value=$update
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Configuring system user..." ynh_script_progression --message="Configuring system user..." --weight=1
# Create a 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"
@ -105,6 +105,7 @@ ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencie
ynh_script_progression --message="Configuring Kimai2..." --weight=1 ynh_script_progression --message="Configuring Kimai2..." --weight=1
local_conf="$final_path/config/packages/local.yaml" local_conf="$final_path/config/packages/local.yaml"
# Configure registration # Configure registration
cp ../conf/local.yaml $local_conf 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"
@ -116,19 +117,7 @@ then
else else
ynh_replace_string --match_string="__REGISTRATION__" --replace_string="false" --target_file="$local_conf" ynh_replace_string --match_string="__REGISTRATION__" --replace_string="false" --target_file="$local_conf"
fi fi
ynh_store_file_checksum --file="$local_conf"
# env_conf="$final_path/.env"
# # 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_PWD__" --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_add_config --template="../conf/.env.mysql" --destination="$final_path/.env" ynh_add_config --template="../conf/.env.mysql" --destination="$final_path/.env"
@ -144,15 +133,6 @@ pushd "$final_path"
php${YNH_PHP_VERSION} bin/console kimai:install -n php${YNH_PHP_VERSION} bin/console kimai:install -n
popd popd
#=================================================
# STORE THE CONFIG FILE CHECKSUM
#=================================================
ynh_script_progression --message="Storing the config file checksum..." --weight=1
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$local_conf"
#ynh_store_file_checksum --file="$env_conf"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -26,7 +26,7 @@ db_user=$db_name
#================================================= #=================================================
# REMOVE THE MYSQL DATABASE # REMOVE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Removing the MySQL database..." ynh_script_progression --message="Removing the MySQL database..." --weight=1
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
@ -34,7 +34,7 @@ ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -42,7 +42,7 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" ynh_secure_remove --file="$final_path"
@ -50,7 +50,7 @@ ynh_secure_remove --file="$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing nginx web server configuration..." ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -58,7 +58,7 @@ ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE PHP-FPM CONFIGURATION # REMOVE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing php-fpm configuration..." ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=1
# Remove the dedicated php-fpm config # Remove the dedicated php-fpm config
ynh_remove_fpm_config ynh_remove_fpm_config
@ -68,7 +68,7 @@ ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Removing the dedicated system user..." ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
@ -77,4 +77,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" ynh_script_progression --message="Removal of $app completed" --last

View file

@ -20,7 +20,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -34,7 +34,7 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." ynh_script_progression --message="Validating restoration parameters..." --weight=1
test ! -d $final_path \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
@ -44,14 +44,14 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the nginx configuration..." ynh_script_progression --message="Restoring the nginx configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the 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"
@ -59,7 +59,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
@ -70,7 +70,7 @@ chown -R $app:www-data "$final_path"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE THE PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring PHP-FPM configuration..." ynh_script_progression --message="Restoring PHP-FPM configuration..." --weight=1
# Restore the file first, so it can have a backup if different # Restore the file first, so it can have a backup if different
ynh_restore_file --origin_path="/etc/php/${YNH_PHP_VERSION}/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/php/${YNH_PHP_VERSION}/fpm/pool.d/$app.conf"
@ -78,20 +78,10 @@ ynh_restore_file --origin_path="/etc/php/${YNH_PHP_VERSION}/fpm/pool.d/$app.conf
# Recreate a dedicated php-fpm config # Recreate a dedicated php-fpm config
ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # RESTORE THE MYSQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the MySQL database..." ynh_script_progression --message="Restoring the MySQL database..." --weight=2
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
@ -102,7 +92,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./
#================================================= #=================================================
# RELOAD NGINX AND PHP-FPM # RELOAD NGINX AND PHP-FPM
#================================================= #=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
@ -111,4 +101,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -24,6 +24,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
registration=$(ynh_app_setting_get --app=$app --key=registration) registration=$(ynh_app_setting_get --app=$app --key=registration)
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) update=$(ynh_app_setting_get --app=$app --key=update)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -155,13 +158,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_nginx_config ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
@ -189,24 +185,7 @@ else
fi fi
ynh_store_file_checksum --file="$local_conf" ynh_store_file_checksum --file="$local_conf"
env_conf=$final_path/.env ynh_add_config --template="../conf/.env.mysql" --destination="$final_path/.env"
ynh_backup_if_checksum_is_different --file="$env_conf"
# Configure environement
# 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"
#================================================= #=================================================
# UPGRADE KIMAI2 # UPGRADE KIMAI2