diff --git a/README.md b/README.md
index 811ea6f..6b234bc 100644
--- a/README.md
+++ b/README.md
@@ -26,7 +26,6 @@ Shipped Version: **1.8**
1. Require dedicated domain like **kimai.domain.tld**.
1. This app is multi-instance (you can have more then one Kimai instance running on a YunoHost server)
- 1. Login details will be sent to the admin email.
## Documentation
diff --git a/conf/message b/conf/message
deleted file mode 100644
index a5b743c..0000000
--- a/conf/message
+++ /dev/null
@@ -1,8 +0,0 @@
-__APP__ was successfully installed :)
-
-Please open your __APP__ domain: https://__DOMAIN____PATH_URL__
-
-The admin username is: __ADMIN_EMAIL__
-The admin password is: __ADMIN_PASS__
-
-If you facing any issue or want to improve the app, please open a new issue on the project page: https://github.com/YunoHost-Apps/kimai2_yn
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index 52f5c83..c593b13 100644
--- a/manifest.json
+++ b/manifest.json
@@ -33,8 +33,8 @@
"ask": {
"en": "Choose a domain name for Kimai2",
"fr": "Choisissez un nom de domaine pour Kimai2",
- "de": "Wählen Sie einen Domainnamen für Kimai 2",
- "cs": "Zvolte doménu pro Kimai 2"
+ "de": "Wählen Sie einen Domainnamen für Kimai2",
+ "cs": "Zvolte doménu pro Kimai2"
},
"example": "kimai2.example.com"
},
diff --git a/scripts/_common.sh b/scripts/_common.sh
index dee186b..e40ce05 100644
--- a/scripts/_common.sh
+++ b/scripts/_common.sh
@@ -8,7 +8,6 @@
pkg_dependencies=""
extra_pkg_dependencies="php7.3-gd php7.3-intl php7.3-json php7.3-mbstring php7.3-pdo php7.3-zip php7.3-xml php7.3-xsl php7.3-ldap php7.3-mysql php7.3-sqlite3"
-# php7.3-ctype php7.3-iconv php7.3-cli php7.3-simplexml php7.3-tokenizer php7.3-common php7.3-curl
#=================================================
# PERSONAL HELPERS
diff --git a/scripts/backup b/scripts/backup
index 6641144..203a532 100755
--- a/scripts/backup
+++ b/scripts/backup
@@ -18,7 +18,6 @@ ynh_print_info --message="Managing script failure..."
ynh_clean_setup () {
true
}
-
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@@ -61,6 +60,7 @@ ynh_backup --src_path="/etc/php/7.3/fpm/pool.d/$app.conf"
#=================================================
if [ "$database" = "mysql" ]; then
+ ynh_print_info --message="Backing up the MySQL database..."
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
ynh_mysql_dump_db --database="$db_name" > db.sql
diff --git a/scripts/install b/scripts/install
index d90e626..7104748 100755
--- a/scripts/install
+++ b/scripts/install
@@ -10,7 +10,6 @@ source _common.sh
source ynh_add_extra_apt_repos__3
source ynh_install_php__3
source ynh_composer__2
-source ynh_send_readme_to_admin__2
source /usr/share/yunohost/helpers
#=================================================
@@ -35,9 +34,7 @@ admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC
registration=$YNH_APP_ARG_REGISTRATION
database=$YNH_APP_ARG_DATABASE
-admin_pass=$(ynh_string_random 24)
random_key=$(ynh_string_random 32)
-admin_email=$(ynh_user_get_info $admin 'mail')
app=$YNH_APP_INSTANCE_NAME
@@ -61,15 +58,16 @@ 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=random_key --value=$random_key
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
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# INSTALL PHP7.3
#=================================================
+ynh_print_info --message="Installing PHP7.3..."
if [ "$(lsb_release --codename --short)" = "buster" ]; then
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
@@ -113,45 +111,46 @@ ynh_system_user_create --username=$app
#=================================================
# SPECIFIC SETUP
#=================================================
-# CONFIGURE KIMAI 2
+# CONFIGURE KIMAI2
#=================================================
-ynh_print_info --message="Configuring Kimai 2..."
+ynh_print_info --message="Configuring Kimai2..."
+local_conf="$final_path/config/packages/local.yaml"
# Configure registration
-sudo cp ../conf/local.yaml $final_path/config/packages/local.yaml
-ynh_replace_string "__APP__" "$app" "$final_path/config/packages/local.yaml"
+sudo cp ../conf/local.yaml $local_conf
+ynh_replace_string --match_string="__APP__" "$app" --target_file="$local_conf"
if [ $registration -eq 1 ]
then
- ynh_replace_string "__REGISTRATION__" "true" "$final_path/config/packages/local.yaml"
+ ynh_replace_string --match_string="__REGISTRATION__" --replace_string="true" --target_file="$local_conf"
else
- ynh_replace_string "__REGISTRATION__" "false" "$final_path/config/packages/local.yaml"
+ ynh_replace_string --match_string="__REGISTRATION__" --replace_string="false" --target_file="$local_conf"
fi
-env_conf=$final_path/.env
+env_conf="$final_path/.env"
# Configure environement
if [ "$database" = "mysql" ]; then
# setup application config
sudo cp ../conf/.env.mysql $env_conf
- db_name=$(ynh_sanitize_dbid $app)
- ynh_app_setting_set $app db_name $db_name
- ynh_mysql_setup_db $db_name $db_name
-
- ynh_replace_string "__RANDOM_KEY__" "$random_key" "$env_conf"
- ynh_replace_string "__DOMAIN__" "$domain" "$env_conf"
- ynh_replace_string "__DB_PASSWORD__" "$db_pwd" "$env_conf"
- ynh_replace_string "__DB_USER__" "$db_name" "$env_conf"
- ynh_replace_string "__DB_NAME__" "$db_name" "$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_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"
else
# setup application config
sudo cp ../conf/.env.sqlite $env_conf
- ynh_replace_string "__RANDOM_KEY__" "$random_key" "$env_conf"
- ynh_replace_string "__DOMAIN__" "$domain" "$env_conf"
+ 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"
fi
#=================================================
-# BUILD KIMAI 2
+# BUILD KIMAI2
#=================================================
-ynh_print_info --message="Building Kimai 2..."
+ynh_print_info --message="Building Kimai2..."
ynh_install_composer --phpversion="7.3" --workdir="$final_path" --install_args="--optimize-autoloader"
ynh_composer_exec --phpversion="7.3" --workdir="$final_path" --commands="require laminas/laminas-ldap"
@@ -166,6 +165,7 @@ popd
ynh_print_info --message="Storing the config file checksum..."
# 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"
#=================================================
@@ -209,19 +209,6 @@ ynh_print_info --message="Reloading nginx web server..."
ynh_systemd_action --service_name=nginx --action=reload
-#=================================================
-# SEND A README FOR THE ADMIN
-#=================================================
-ynh_print_info --message="Sending a readme for the admin..."
-
-ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="../conf/message"
-ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message"
-ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message"
-ynh_replace_string --match_string="__ADMIN_EMAIL__" --replace_string="$admin_email" --target_file="../conf/message"
-ynh_replace_string --match_string="__ADMIN_PASS__" --replace_string="$admin_pass" --target_file="../conf/message"
-
-ynh_send_readme_to_admin --app_message="../conf/message" --recipients=$admin_email --type='install'
-
#=================================================
# END OF SCRIPT
#=================================================
diff --git a/scripts/remove b/scripts/remove
index d7f7903..fb9f6ae 100755
--- a/scripts/remove
+++ b/scripts/remove
@@ -37,7 +37,7 @@ if [ "$database" = "mysql" ]; then
fi
#=================================================
-# REMOVE PHP
+# REMOVE PHP7.3
#=================================================
if [ "$(lsb_release --codename --short)" != "buster" ]; then
diff --git a/scripts/restore b/scripts/restore
index 77406ab..3701844 100755
--- a/scripts/restore
+++ b/scripts/restore
@@ -82,6 +82,7 @@ chown -R $app: $final_path
#=================================================
# REINSTALL PHP7.3
#=================================================
+ynh_print_info --message="Reinstall PHP7.3..."
if [ "$(lsb_release --codename --short)" = "buster" ]; then
pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies"
diff --git a/scripts/upgrade b/scripts/upgrade
index 04a09f0..6f9aad7 100755
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -24,7 +24,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin)
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-database=$(ynh_app_setting_get $app database)
+database=$(ynh_app_setting_get --app=$app --key=database)
random_key=$(ynh_app_setting_get --app=$app --key=random_key)
#=================================================
@@ -48,7 +48,6 @@ elif [ "$is_public" = "No" ]; then
is_public=0
fi
-
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
@@ -162,39 +161,49 @@ ynh_add_fpm_config --phpversion="7.3"
#=================================================
# SPECIFIC UPGRADE
#=================================================
-# CONFIGURE KIMAI 2
+# CONFIGURE KIMAI2
#=================================================
-ynh_print_info --message="Configuring Kimai 2..."
+ynh_print_info --message="Configuring Kimai2..."
+
+local_conf="$final_path/config/packages/local.yaml"
+ynh_backup_if_checksum_is_different "$local_conf"
+sudo cp ../conf/local.yaml $local_conf
+ynh_replace_string --match_string="__APP__" "$app" --target_file="$local_conf"
+if [ $registration -eq 1 ]
+then
+ ynh_replace_string --match_string="__REGISTRATION__" --replace_string="true" --target_file="$local_conf"
+else
+ ynh_replace_string --match_string="__REGISTRATION__" --replace_string="false" --target_file="$local_conf"
+fi
+ynh_store_file_checksum "$local_conf"
env_conf=$final_path/.env
-
-# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$env_conf"
-
# Configure environement
if [ "$database" = "mysql" ]; then
# setup application config
sudo cp ../conf/.env.mysql $env_conf
- db_name=$(ynh_sanitize_dbid $app)
- ynh_app_setting_set $app db_name $db_name
- ynh_mysql_setup_db $db_name $db_name
+ 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 "__RANDOM_KEY__" "$random_key" "$env_conf"
- ynh_replace_string "__DOMAIN__" "$domain" "$env_conf"
- ynh_replace_string "__DB_PASSWORD__" "$db_pwd" "$env_conf"
- ynh_replace_string "__DB_USER__" "$db_name" "$env_conf"
- ynh_replace_string "__DB_NAME__" "$db_name" "$env_conf"
+ 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"
else
# setup application config
sudo cp ../conf/.env.sqlite $env_conf
- ynh_replace_string "__RANDOM_KEY__" "$random_key" "$env_conf"
- ynh_replace_string "__DOMAIN__" "$domain" "$env_conf"
+ 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"
fi
+ynh_store_file_checksum "$env_conf"
#=================================================
-# UPGRADE KIMAI 2
+# UPGRADE KIMAI2
#=================================================
-ynh_print_info --message="Upgrading Kimai 2..."
+ynh_print_info --message="Upgrading Kimai2..."
ynh_install_composer --phpversion="7.3" --workdir="$final_path" --install_args="--optimize-autoloader"
ynh_composer_exec --phpversion="7.3" --workdir="$final_path" --commands="require laminas/laminas-ldap"
@@ -203,15 +212,6 @@ pushd "$final_path"
php7.3 bin/console kimai:update
popd
-#=================================================
-# STORE THE CONFIG FILE CHECKSUM
-#=================================================
-ynh_print_info --message="Storing the config file checksum..."
-
-
-# Recalculate and store the config file checksum into the app settings
-ynh_store_file_checksum "$env_conf"
-
#=================================================
# GENERIC FINALIZATION
#=================================================
@@ -227,6 +227,8 @@ chown -R $app: $final_path
#=================================================
ynh_print_info --message="Upgrading SSOwat configuration..."
+ynh_permission_create --permission="teamlead"
+ynh_permission_create --permission="admin"
ynh_permission_create --permission="super_admin" --allowed "$admin"
# Make app public if necessary
diff --git a/scripts/ynh_send_readme_to_admin__2 b/scripts/ynh_send_readme_to_admin__2
deleted file mode 100644
index 06cff8c..0000000
--- a/scripts/ynh_send_readme_to_admin__2
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/bin/bash
-
-# Send an email to inform the administrator
-#
-# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
-# | arg: -m --app_message= - The file with the content to send to the administrator.
-# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
-# example: "root admin@domain"
-# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
-# example: "root admin@domain user1 user2"
-# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
-ynh_send_readme_to_admin() {
- # Declare an array to define the options of this helper.
- declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
- local app_message
- local recipients
- local type
- # Manage arguments with getopts
-
- ynh_handle_getopts_args "$@"
- app_message="${app_message:-}"
- recipients="${recipients:-root}"
- type="${type:-install}"
-
- # Get the value of admin_mail_html
- admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
- admin_mail_html="${admin_mail_html:-0}"
-
- # Retrieve the email of users
- find_mails () {
- local list_mails="$1"
- local mail
- local recipients=" "
- # Read each mail in argument
- for mail in $list_mails
- do
- # Keep root or a real email address as it is
- if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@"
- then
- recipients="$recipients $mail"
- else
- # But replace an user name without a domain after by its email
- if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null)
- then
- recipients="$recipients $mail"
- fi
- fi
- done
- echo "$recipients"
- }
- recipients=$(find_mails "$recipients")
-
- # Subject base
- local mail_subject="☁️🆈🅽🅷☁️: \`$app\`"
-
- # Adapt the subject according to the type of mail required.
- if [ "$type" = "backup" ]; then
- mail_subject="$mail_subject has just been backup."
- elif [ "$type" = "change_url" ]; then
- mail_subject="$mail_subject has just been moved to a new URL!"
- elif [ "$type" = "remove" ]; then
- mail_subject="$mail_subject has just been removed!"
- elif [ "$type" = "restore" ]; then
- mail_subject="$mail_subject has just been restored!"
- elif [ "$type" = "upgrade" ]; then
- mail_subject="$mail_subject has just been upgraded!"
- else # install
- mail_subject="$mail_subject has just been installed!"
- fi
-
- local mail_message="This is an automated message from your beloved YunoHost server.
-
-Specific information for the application $app.
-
-$(if [ -n "$app_message" ]
-then
- cat "$app_message"
-else
- echo "...No specific information..."
-fi)
-
----
-Automatic diagnosis data from YunoHost
-
-__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__"
-
- # Store the message into a file for further modifications.
- echo "$mail_message" > mail_to_send
-
- # If a html email is required. Apply html tags to the message.
- if [ "$admin_mail_html" -eq 1 ]
- then
- # Insert 'br' tags at each ending of lines.
- ynh_replace_string "$" "
" mail_to_send
-
- # Insert starting HTML tags
- sed --in-place '1s@^@\n\n
" mail_to_send - ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send - - # Insert finishing HTML tags - echo -e "\n\n" >> mail_to_send - - # Otherwise, remove tags to keep a plain text. - else - # Remove URL tags - ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send - ynh_replace_string "__URL_TAG2__" ": " mail_to_send - - # Remove PRE tags - ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send - fi - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - if [ "$admin_mail_html" -eq 1 ] - then - content_type="text/html" - else - content_type="text/plain" - fi - - # Send the email to the recipients - cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" -}