diff --git a/conf/.env.example b/conf/.env.example index 3f5e94d..30b9315 100644 --- a/conf/.env.example +++ b/conf/.env.example @@ -4,7 +4,6 @@ DATABASE_URL=mysql://__DB_USER__:__DB_PWD__@127.0.0.1:3306/__DB_NAME__?charset=u # Email will be sent with this address as sender MAILER_FROM=admin@__DOMAIN__ - # Email connection (disabled by default) more info at https://www.kimai.org/documentation/emails.html MAILER_URL=smtp://localhost:25?encryption=&auth_mode= diff --git a/conf/local.yaml b/conf/local.yaml index d23025d..0c18b56 100644 --- a/conf/local.yaml +++ b/conf/local.yaml @@ -7,6 +7,7 @@ security: secured_area: kimai_ldap: ~ kimai: + data_dir: "__DATADIR__" user: registration: __REGISTRATION__ ldap: diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 59a4e84..f8ff3a0 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -3,10 +3,10 @@ #### Multi-user support -LDAP is supported -HTTP auth is not supported +- LDAP is supported +- HTTP auth is not supported -Defaul Kimai2 roles are: +#### Defaul Kimai2 roles are: * ROLE_USER * ROLE_TEAMLEAD => Kimai2 (Teamlead) YunoHost permission * ROLE_ADMIN => Kimai2 (Admin) YunoHost permission diff --git a/scripts/backup b/scripts/backup index 86cad22..b86ddbf 100755 --- a/scripts/backup +++ b/scripts/backup @@ -31,6 +31,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -43,6 +44,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/install b/scripts/install index 0107276..5ffbe3d 100755 --- a/scripts/install +++ b/scripts/install @@ -114,6 +114,20 @@ ynh_script_progression --message="Configuring PHP-FPM..." ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." + +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # SPECIFIC SETUP #================================================= diff --git a/scripts/remove b/scripts/remove index 9fb39ec..e88de1c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # STANDARD REMOVE @@ -39,6 +40,17 @@ ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" +#================================================= +# REMOVE DATA DIR +#================================================= + +# Remove the data directory if --purge option is used +if [ "${YNH_APP_PURGE:-0}" -eq 1 ] +then + ynh_script_progression --message="Removing app data directory..." + ynh_secure_remove --file="$datadir" +fi + #================================================= # REMOVE NGINX CONFIGURATION #================================================= diff --git a/scripts/restore b/scripts/restore index 171f473..ab21fbd 100755 --- a/scripts/restore +++ b/scripts/restore @@ -33,6 +33,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -72,6 +73,19 @@ 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 DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= @@ -80,7 +94,7 @@ 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 +# Recreate a dedicated PHP-FPM config ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) diff --git a/scripts/upgrade b/scripts/upgrade index 626ebdd..f3e4252 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,7 @@ db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) random_key=$(ynh_app_setting_get --app=$app --key=random_key) phpversion=$YNH_PHP_VERSION +datadir=$(ynh_app_setting_get --app=$app --key=datadir) registration=$(ynh_app_setting_get --app=$app --key=registration) @@ -66,6 +67,16 @@ if [ -z "$registration" ]; then ynh_app_setting_set --app=$app --key=registration --value=$registration fi +# If public_path doesn't exist, create it +if [ -z "$datadir" ]; then + datadir=/home/yunohost.app/$app + mkdir -p $datadir + chmod 750 "$datadir" + chmod -R o-rwx "$datadir" + chown -R $app:www-data "$datadir" + ynh_app_setting_set --app=$app --key=datadir --value=$datadir +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all