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 2022-03-12 16:02:21 +01:00
parent 6b3ab38a5b
commit 7faeb40015
No known key found for this signature in database
GPG key ID: 574F281483054D44
12 changed files with 35 additions and 149 deletions

View file

@ -1,36 +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 a MySQL database, use: "mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=10.2.12&charset=utf8"
# For a MariaDB database, use: "mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=mariadb-10.2.12"
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data/kimai.sqlite"
# IMPORTANT: You MUST configure your server version, either here or 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__

7
conf/app.src Normal file
View file

@ -0,0 +1,7 @@
SOURCE_URL=https://github.com/kevinpapst/kimai2/archive/1.18.2.tar.gz
SOURCE_SUM=76e9f5fa19a6416d794c82419926adfadae365d838f46df7f8455ab9a4bc8849
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/kevinpapst/kimai2/archive/1.17.1.tar.gz
SOURCE_SUM=ceff0573591d2e5c70a679301caabe626d8545af5e987443c8155f633babcd0e
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/kevinpapst/kimai2/archive/1.13.tar.gz
SOURCE_SUM=caab9910a85b16772af678ee8519a8030cd8496aa94ce0a0027fffa6a91f3fef
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -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.18.2~ynh1",
"url": "https://www.kimai.org",
"upstream": {
"license": "MIT",
@ -29,7 +29,7 @@
"multi_instance": true,
"services": [
"nginx",
"php7.3-fpm",
"php8.0-fpm",
"mysql"
],
"arguments": {

View file

@ -4,14 +4,11 @@
# COMMON VARIABLES
#=================================================
# dependencies used by the app
pkg_dependencies=""
YNH_PHP_VERSION="8.0"
YNH_PHP_VERSION="7.3"
YNH_COMPOSER_VERSION="2.2.7"
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"
pkg_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-intl 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"
#=================================================
# PERSONAL HELPERS

View file

@ -31,7 +31,6 @@ 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)
database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
@ -59,11 +58,9 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
if [ "$database" = "mysql" ]; then
ynh_print_info --message="Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
fi
ynh_mysql_dump_db --database="$db_name" > db.sql
#=================================================
# END OF SCRIPT

View file

@ -28,8 +28,8 @@ path_url="/"
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
registration=$YNH_APP_ARG_REGISTRATION
database="mysql"
random_key=$(ynh_string_random 32)
phpversion=$YNH_PHP_VERSION
app=$YNH_APP_INSTANCE_NAME
@ -53,7 +53,6 @@ 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=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
#=================================================
@ -78,12 +77,10 @@ ynh_system_user_create --username=$app --home_dir=$final_path
#=================================================
ynh_script_progression --message="Creating a MySQL database..."
if [ "$database" = "mysql" ]; then
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
fi
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
@ -114,7 +111,7 @@ ynh_add_nginx_config
ynh_script_progression --message="Configuring PHP-FPM..."
# 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)
#=================================================
@ -151,7 +148,7 @@ chmod 400 "$final_path/config/packages/local.yaml"
chown $app:$app "$final_path/config/packages/local.yaml"
# Configure environement
ynh_add_config --template="../conf/.env.$database" --destination="$final_path/.env"
ynh_add_config --template="../conf/.env.example" --destination="$final_path/.env"
chmod 400 "$final_path/.env"
chown $app:$app "$final_path/.env"
@ -161,13 +158,13 @@ chown $app:$app "$final_path/.env"
#=================================================
ynh_script_progression --message="Installing Kimai2..."
update-alternatives --set php /usr/bin/php$phpversion
#update-alternatives --set php /usr/bin/php$phpversion
pushd "$final_path"
ynh_exec_as $app php$phpversion bin/console kimai:install -n
popd
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
#update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
#=================================================
# GENERIC FINALIZATION
@ -183,8 +180,6 @@ ynh_permission_create --permission="super_admin" --allowed "$admin"
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi

View file

@ -20,20 +20,16 @@ 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)
database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Removing the MySQL database..."
if [ "$database" = "mysql" ]; then
ynh_script_progression --message="Removing the MySQL database..."
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
fi
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR

View file

@ -33,7 +33,6 @@ 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)
database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -82,7 +81,7 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..."
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"
ynh_add_fpm_config
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
@ -98,13 +97,11 @@ ynh_install_app_dependencies $pkg_dependencies
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
if [ "$database" = "mysql" ]; then
ynh_script_progression --message="Restoring the MySQL database..."
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_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
fi
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_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#=================================================
# GENERIC FINALIZATION

View file

@ -24,13 +24,11 @@ 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)
registration=$(ynh_app_setting_get --app=$app --key=registration)
database=$(ynh_app_setting_get --app=$app --key=database)
random_key=$(ynh_app_setting_get --app=$app --key=random_key)
#=================================================
# CHECK VERSION
#=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
@ -96,35 +94,8 @@ 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" --keep="$final_path/config/packages/local.yaml $final_path/var/invoices $final_path/var/data $final_path/.env"
fi
chmod 750 "$final_path"
@ -154,8 +125,7 @@ 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"
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
@ -173,41 +143,18 @@ 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/"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
if [ $registration -eq 1 ]
then
registration="true"
else
registration="false"
fi
ynh_add_config --template="../conf/local.yaml" --destination="$final_path/config/packages/local.yaml"
chmod 400 "$final_path/config/packages/local.yaml"
chown $app:$app "$final_path/config/packages/local.yaml"
# Configure environement
ynh_add_config --template="../conf/.env.$database" --destination="$final_path/.env"
chmod 400 "$final_path/.env"
chown $app:$app "$final_path/.env"
#=================================================
# INSTALL KIMAI2
#=================================================
ynh_script_progression --message="Installing Kimai2..."
update-alternatives --set php /usr/bin/php$phpversion
#update-alternatives --set php /usr/bin/php$phpversion
pushd "$final_path"
ynh_exec_as $app php$phpversion bin/console kimai:update -n
popd
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
#update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
#=================================================
# GENERIC FINALIZATION