1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/invoiceninja5_ynh.git synced 2024-09-03 19:26:23 +02:00

Merge pull request #27 from YunoHost-Apps/testing

Testing
This commit is contained in:
Sebastian Gumprich 2022-07-28 17:47:01 +00:00 committed by GitHub
commit 382e2e29dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 181 additions and 19 deletions

View file

@ -17,7 +17,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Create and email invoices, track payments, expenses, and time tasks Create and email invoices, track payments, expenses, and time tasks
**Shipped version:** 5.3.60~ynh1 **Shipped version:** 5.5.2~ynh1
**Demo:** https://app.invoiceninja.com/dashboard **Demo:** https://app.invoiceninja.com/dashboard

View file

@ -17,7 +17,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
Créer et envoyer des factures par e-mail, suivre les paiements, les dépenses et les tâches horaires Créer et envoyer des factures par e-mail, suivre les paiements, les dépenses et les tâches horaires
**Version incluse :** 5.3.60~ynh1 **Version incluse :** 5.5.2~ynh1
**Démo :** https://app.invoiceninja.com/dashboard **Démo :** https://app.invoiceninja.com/dashboard

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/invoiceninja/invoiceninja/releases/download/v5.3.60/invoiceninja.zip SOURCE_URL=https://github.com/invoiceninja/invoiceninja/releases/download/v5.5.2/invoiceninja.zip
SOURCE_SUM=7c1fc193a6bcca35a6af684694418836baec8e16049fd251ff68837a0d6ce4d2 SOURCE_SUM=64647f6960b64ac42633b65c6b8c108544e2dc845117d3c9f921792474df4ef9
SOURCE_SUM_PRG=sha256sum SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=zip SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=false SOURCE_IN_SUBDIR=false

12
conf/msg_install Normal file
View file

@ -0,0 +1,12 @@
__APP__ was successfully installed :)
Please open your __APP__ domain: https://__DOMAIN____PATH_URL__
The username is: __EMAIL__
The password is the administrator one you filled during the installation
The secret is: __API_SECRET__
Please note that if you did NOT install the application in public mode, you should go to the Yunohost login portal first to authenticate yourself in order to access to the application.
If you are facing any problems, head to the forums: https://forum.yunohost.org/
If you want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/invoiceninja5_ynh/issues

View file

@ -6,7 +6,7 @@
"en": "Create and email invoices, track payments, expenses, and time tasks", "en": "Create and email invoices, track payments, expenses, and time tasks",
"fr": "Créer et envoyer des factures par e-mail, suivre les paiements, les dépenses et les tâches horaires" "fr": "Créer et envoyer des factures par e-mail, suivre les paiements, les dépenses et les tâches horaires"
}, },
"version": "5.3.60~ynh1", "version": "5.5.2~ynh1",
"url": "https://invoiceninja.org", "url": "https://invoiceninja.org",
"upstream": { "upstream": {
"license": "Elastic-2.0", "license": "Elastic-2.0",
@ -31,7 +31,7 @@
"mysql" "mysql"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
@ -47,17 +47,20 @@
"en": "Choose the application language", "en": "Choose the application language",
"fr": "Choisissez la langue de l'application" "fr": "Choisissez la langue de l'application"
}, },
"choices": ["fr", "en"], "choices": [
"fr",
"en"
],
"default": "en" "default": "en"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"default": true, "default": true,
"help": { "help": {
"en": "Since your clients should have the possibility to access your invoices, the app is public. If you only want to send invoices via mail (or not at all), deactivate public access", "en": "Since your clients should have the possibility to access your invoices, the app is public. If you only want to send invoices via mail (or not at all), deactivate public access",
"fr": "Puisque vos clients doivent avoir la possibilité d'accéder à vos factures, l'application est publique. Si vous souhaitez uniquement envoyer des factures par courrier (ou pas du tout), désactivez l'accès public" "fr": "Puisque vos clients doivent avoir la possibilité d'accéder à vos factures, l'application est publique. Si vous souhaitez uniquement envoyer des factures par courrier (ou pas du tout), désactivez l'accès public"
} }
}, },
{ {
"name": "password", "name": "password",

View file

@ -4,11 +4,11 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
YNH_PHP_VERSION="7.4" YNH_PHP_VERSION="8.1"
# dependencies used by the app # dependencies used by the app
pkg_dependencies="php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-fileinfo php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pdo php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mysql libnss3-dev libatk1.0-0 libatk-bridge2.0-0 libxcomposite1 libxrandr2 libasound2 libgbm1" pkg_dependencies="php${YNH_PHP_VERSION}-bcmath php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-fileinfo php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pdo php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mysql libnss3-dev libatk1.0-0 libatk-bridge2.0-0 libxcomposite1 libxrandr2 libasound2"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS

View file

@ -6,6 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source ynh_send_readme_to_admin__2
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -182,6 +183,13 @@ ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
ynh_script_progression --message="Sending a readme for the admin..."
ynh_send_readme_to_admin --app_message="../conf/msg_install" --recipients=$email --type='install'
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -21,7 +21,7 @@ path_url=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language) language=$(ynh_app_setting_get --app=$app --key=language)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$YNH_PHP_VERSION
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
@ -131,17 +131,27 @@ fi
ynh_script_progression --message="Upgrading the database..." ynh_script_progression --message="Upgrading the database..."
pushd "$final_path" pushd "$final_path"
# Put the application into maintenance mode # Clear caches
php$phpversion artisan down --no-interaction --verbose # https://github.com/invoiceninja/invoiceninja/issues/7397
ynh_secure_remove --file=$final_path/bootstrap/cache/
ynh_secure_remove --file=$final_path/storage/framework/cache/
ynh_secure_remove --file=$final_path/storage/framework/sessions/
# Optimize the framework for better performance mkdir -p $final_path/bootstrap/cache/ $final_path/storage/framework/cache/ $final_path/storage/framework/sessions/
php$phpversion artisan optimize --no-interaction --verbose
# clear cached stuff under /app/data/storage/framework (https://github.com/laravel/framework/issues/17377)
php$phpversion artisan view:clear
php$phpversion artisan cache:clear
# Run the database migrations # Run the database migrations
php$phpversion artisan migrate --force --no-interaction --verbose php$phpversion artisan migrate --force --no-interaction --verbose
# Bring the application out of maintenance mode # Optimize the framework for better performance
php$phpversion artisan up --no-interaction --verbose php$phpversion artisan optimize --no-interaction --verbose
# clear cached stuff under /app/data/storage/framework (https://github.com/laravel/framework/issues/17377)
php$phpversion artisan view:clear
php$phpversion artisan cache:clear
popd popd
chmod 750 "$final_path" chmod 750 "$final_path"

View file

@ -0,0 +1,129 @@
#!/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'
#
# Requires YunoHost version 4.1.0 or higher.
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
ynh_add_config --template="$app_message" --destination="../conf/msg__to_send"
ynh_delete_file_checksum --file="../conf/msg__to_send"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$(cat "../conf/msg__to_send")"
# 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 "$" "<br>" mail_to_send
# Insert starting HTML tags
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
# Keep tabulations
ynh_replace_string " " "\&#160;\&#160;" mail_to_send
ynh_replace_string "\t" "\&#160;\&#160;" mail_to_send
# Insert url links tags
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
# Insert finishing HTML tags
echo -e "\n</body>\n</html>" >> 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
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"
}