From 5854353e67bf03d910b78544545736befdcbe42d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 27 Sep 2021 11:03:19 +0200 Subject: [PATCH] cleaning up --- conf/.env.mysql | 2 +- conf/.env.sqlite | 34 -------------------------------- conf/app.src | 5 ++--- manifest.json | 12 ------------ scripts/install | 51 +++++++++++++++++++++++++++--------------------- 5 files changed, 32 insertions(+), 72 deletions(-) delete mode 100644 conf/.env.sqlite diff --git a/conf/.env.mysql b/conf/.env.mysql index c49f744..3b934cc 100644 --- a/conf/.env.mysql +++ b/conf/.env.mysql @@ -13,7 +13,7 @@ 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=mysql://__DB_USER__:__DB_PWD__@127.0.0.1:3306/__DB_NAME__ # DATABASE_URL=sqlite:///%kernel.project_dir%/var/data/kimai.sqlite ###< doctrine/doctrine-bundle ### diff --git a/conf/.env.sqlite b/conf/.env.sqlite deleted file mode 100644 index f06eba7..0000000 --- a/conf/.env.sqlite +++ /dev/null @@ -1,34 +0,0 @@ -# This file is a "template" of which env vars need to be defined for your application -# Copy this file to .env file for development, create environment variables when deploying to production -# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration - -###> 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 -###< symfony/framework-bundle ### - -###> doctrine/doctrine-bundle ### -# 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 -###< doctrine/doctrine-bundle ### - -###> nelmio/cors-bundle ### -CORS_ALLOW_ORIGIN=^https?://localhost(:[0-9]+)?$ -###< nelmio/cors-bundle ### - -### Email configuration -# SMTP: smtp://localhost:25?encryption=&auth_mode= -# Google: gmail://username:password@default -# Amazon: ses://ACCESS_KEY:SECRET_KEY@default?region=eu-west-1 -# Mailchimp: mandrill://KEY@default -# Mailgun: mailgun://KEY:DOMAIN@default -# Postmark: postmark://ID@default -# Sendgrid: sendgrid://KEY@default -# Disable emails: null://null -MAILER_URL=smtp://localhost:25?encryption=&auth_mode= -MAILER_FROM=admin@__DOMAIN__ diff --git a/conf/app.src b/conf/app.src index 05d59b1..2e82ee1 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +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.15.2.tar.gz +SOURCE_SUM=b321983d323bd9471444792c3527cc293376087d2c3b573d7f311f9f4693c394 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/manifest.json b/manifest.json index e9df06c..2c55bf1 100644 --- a/manifest.json +++ b/manifest.json @@ -41,18 +41,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", "ask": { diff --git a/scripts/install b/scripts/install index 411c706..da526c3 100755 --- a/scripts/install +++ b/scripts/install @@ -13,9 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -28,7 +25,6 @@ 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 @@ -36,7 +32,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -47,14 +43,13 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=1 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 #================================================= @@ -63,12 +58,22 @@ ynh_app_setting_set --app=$app --key=random_key --value=$random_key ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" + +#================================================= +# CREATE A MYSQL DATABASE +#================================================= +ynh_script_progression --message="Creating a MySQL database..." --weight=1 + +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 #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=1 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -77,7 +82,7 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated nginx config ynh_add_nginx_config @@ -85,7 +90,7 @@ ynh_add_nginx_config #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring php-fpm..." +ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 # Create a dedicated php-fpm config ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" @@ -95,7 +100,7 @@ ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencie #================================================= # CONFIGURE KIMAI2 #================================================= -ynh_script_progression --message="Configuring Kimai2..." +ynh_script_progression --message="Configuring Kimai2..." --weight=1 local_conf="$final_path/config/packages/local.yaml" # Configure registration @@ -119,7 +124,7 @@ if [ "$database" = "mysql" ]; then 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_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" else @@ -132,7 +137,7 @@ fi #================================================= # BUILD KIMAI2 #================================================= -ynh_script_progression --message="Building Kimai2..." +ynh_script_progression --message="Building Kimai2..." --weight=1 ynh_install_composer --phpversion="${YNH_PHP_VERSION}" --workdir="$final_path" --install_args="--optimize-autoloader" ynh_composer_exec --phpversion="${YNH_PHP_VERSION}" --workdir="$final_path" --commands="require laminas/laminas-ldap" @@ -144,7 +149,7 @@ popd #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_script_progression --message="Storing 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" @@ -155,30 +160,32 @@ ynh_store_file_checksum --file="$env_conf" #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." --weight=1 # Set permissions to app files -chown -R $app: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." --weight=1 ynh_permission_create --permission="teamlead" ynh_permission_create --permission="admin" -ynh_permission_create --permission="super_admin" --allowed "$admin" +ynh_permission_create --permission="super_admin" --allowed="$admin" # Make app public if necessary if [ $is_public -eq 1 ] then - ynh_permission_update --permission "main" --add "visitors" + ynh_permission_update --permission="main" --add="visitors" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 ynh_systemd_action --service_name=nginx --action=reload @@ -186,4 +193,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" --last