mirror of
https://github.com/YunoHost-Apps/kimai2_ynh.git
synced 2024-09-03 19:26:26 +02:00
enhancement:Added mysql database
This commit is contained in:
parent
20f67319d6
commit
d705a35246
8 changed files with 57 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
|||
[](https://ci-apps.yunohost.org/jenkins/job/kimai2%20%28Community%29/lastBuild/consoleFull)
|
||||
[](https://install-app.yunohost.org/?app=kimai2)<br>
|
||||
|
||||
Shipped Version: **0.4 (pre-release)**
|
||||
Shipped Version: **0.5 (pre-release)**
|
||||
|
||||
**Please note that this app will install PHP 7.2**
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ APP_SECRET=__RANDOM_KEY__
|
|||
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
|
||||
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data/kimai.sqlite"
|
||||
# Configure your db driver and server_version in config/packages/doctrine.yaml
|
||||
# DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name
|
||||
DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite
|
||||
DATABASE_URL=mysql://__DB_USER__:__DB_PASSWORD__@127.0.0.1:3306/__DB_NAME__
|
||||
# DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite
|
||||
###< doctrine/doctrine-bundle ###
|
||||
|
||||
###> symfony/swiftmailer-bundle ###
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"fr": "Kimai2 de package d’application pour YunoHost.",
|
||||
"de": "Kimai 2 Paket für YunoHost."
|
||||
},
|
||||
"version": "0.4",
|
||||
"version": "0.5",
|
||||
"url": "https://v2.kimai.org",
|
||||
"license": "free",
|
||||
"maintainer": {
|
||||
|
|
|
@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# STANDARD BACKUP STEPS
|
||||
|
@ -50,3 +51,9 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
|
||||
ynh_backup "/etc/php/7.2/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
ynh_mysql_dump_db "$db_name" > db.sql
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ admin=$YNH_APP_ARG_ADMIN
|
|||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||
admin_pass=$(ynh_string_random 24)
|
||||
random_key=$(ynh_string_random 32)
|
||||
registration="true"
|
||||
|
||||
|
||||
# This is a multi-instance app, meaning it can be installed several times independently
|
||||
|
@ -64,6 +65,7 @@ ynh_app_setting_set $app path $path_url
|
|||
ynh_app_setting_set $app admin $admin
|
||||
ynh_app_setting_set $app is_public $is_public
|
||||
ynh_app_setting_set $app random_key $random_key
|
||||
ynh_app_setting_set $app registration $registration
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
|
@ -73,6 +75,22 @@ ynh_app_setting_set $app random_key $random_key
|
|||
|
||||
ynh_install_php7
|
||||
|
||||
#=================================================
|
||||
# CREATE A MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
### Use these lines if you need a database for the application.
|
||||
### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password.
|
||||
### The password will be stored as 'mysqlpwd' into the app settings,
|
||||
### and will be available as $db_pwd
|
||||
### If you're not using these lines:
|
||||
### - Remove the section "BACKUP THE MYSQL DATABASE" in the backup script
|
||||
### - Remove also the section "REMOVE THE MYSQL DATABASE" in the remove script
|
||||
### - As well as the section "RESTORE THE MYSQL DATABASE" in the restore script
|
||||
|
||||
db_name=$(ynh_sanitize_dbid $app)
|
||||
ynh_app_setting_set $app db_name $db_name
|
||||
ynh_mysql_setup_db $db_name $db_name
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
|
@ -123,6 +141,10 @@ sudo cp ../conf/.env $final_path/.env
|
|||
#=================================================
|
||||
ynh_replace_string "__RANDOM_KEY__" "$random_key" "$final_path/.env"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/.env"
|
||||
ynh_replace_string "__DB_PASSWORD__" "$db_pwd" "$final_path/.env"
|
||||
ynh_replace_string "__DB_USER__" "$db_name" "$final_path/.env"
|
||||
ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/.env"
|
||||
|
||||
|
||||
|
||||
init_composer $final_path
|
||||
|
|
|
@ -17,6 +17,8 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
|
||||
domain=$(ynh_app_setting_get $app domain)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_user=$db_name
|
||||
|
||||
#=================================================
|
||||
# STANDARD REMOVE
|
||||
|
@ -37,6 +39,13 @@ ynh_secure_remove "$final_path"
|
|||
# Remove the dedicated nginx config
|
||||
ynh_remove_nginx_config
|
||||
|
||||
#=================================================
|
||||
# REMOVE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
# Remove a database if it exists, along with the associated user
|
||||
ynh_mysql_remove_db $db_user $db_name
|
||||
|
||||
#=================================================
|
||||
# REMOVE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
|
|
@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME
|
|||
domain=$(ynh_app_setting_get $app domain)
|
||||
path_url=$(ynh_app_setting_get $app path)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
|
||||
#=================================================
|
||||
# CHECK IF THE APP CAN BE RESTORED
|
||||
|
@ -61,6 +62,14 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
|
||||
ynh_restore_file "$final_path"
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
ynh_mysql_setup_db $db_name $db_name $db_pwd
|
||||
ynh_mysql_connect_as $db_name $db_pwd $db_name < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RECREATE THE DEDICATED USER
|
||||
#=================================================
|
||||
|
|
|
@ -21,6 +21,9 @@ admin=$(ynh_app_setting_get $app admin)
|
|||
is_public=$(ynh_app_setting_get $app is_public)
|
||||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
random_key=$(ynh_app_setting_get $app random_key)
|
||||
db_name=$(ynh_app_setting_get $app db_name)
|
||||
db_pwd=$(ynh_app_setting_get $app mysqlpwd)
|
||||
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
|
@ -119,6 +122,9 @@ sudo cp ../conf/.env $final_path/.env
|
|||
#=================================================
|
||||
ynh_replace_string "__RANDOM_KEY__" "$random_key" "$final_path/.env"
|
||||
ynh_replace_string "__DOMAIN__" "$domain" "$final_path/.env"
|
||||
ynh_replace_string "__DB_PASSWORD__" "$db_pwd" "$final_path/.env"
|
||||
ynh_replace_string "__DB_USER__" "$db_name" "$final_path/.env"
|
||||
ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/.env"
|
||||
|
||||
init_composer $final_path
|
||||
(
|
||||
|
|
Loading…
Add table
Reference in a new issue