From 30fcd02fa2b5687421b9cd0942cdfc273aeb03d7 Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Tue, 11 May 2021 03:03:15 +0200 Subject: [PATCH 01/12] [autopatch] Update issue and PR templates --- issue_template.md | 46 ---------------------------------------- pull_request_template.md | 18 ---------------- 2 files changed, 64 deletions(-) delete mode 100644 issue_template.md delete mode 100644 pull_request_template.md diff --git a/issue_template.md b/issue_template.md deleted file mode 100644 index a12d565..0000000 --- a/issue_template.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -name: Bug report -about: Create a report to help us debug, it would be nice to fill the template as much as you can to help us, help you and help us all. - ---- - -**How to post a meaningful bug report** -1. *Read this whole template first.* -2. *Determine if you are on the right place:* - - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!* - - *Otherwise, the issue may be due to Invoice Ninja itself. Refer to its documentation or repository for help.* - - *If you have a doubt, post here, we will figure it out together.* -3. *Delete the italic comments as you write over them below, and remove this guide.* ---- - -**Describe the bug** -*A clear and concise description of what the bug is.* - -**Versions** -- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* -- YunoHost version: x.x.x -- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* -- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes* - - If yes, please explain: -- Using, or trying to install package version/branch: -- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* - -**To Reproduce** -*Steps to reproduce the behavior.* -- *If you performed a command from the CLI, the command itself is enough. For example:* - ```sh - sudo yunohost app install invoiceninja - ``` -- *If you used the webadmin, please perform the equivalent command from the CLI first.* -- *If the error occurs in your browser, explain what you did:* - 1. *Go to '...'* - 2. *Click on '....'* - 3. *Scroll down to '....'* - 4. *See error* - -**Expected behavior** -*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* - -**Logs** -*After a failed command, YunoHost makes the log available to you, but also to others, thanks to `yunohost log display [log name] --share`. The actual command, with the correct log name, is displayed at the end of the failed attempt in the CLI. Execute it and copy here the share link it outputs.* -*If applicable and useful, add screenshots to help explain your problem.* diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index eb14a79..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,18 +0,0 @@ -## Problem -- *Description of why you made this PR* - -## Solution -- *And how do you fix that problem* - -## PR Status -- [ ] Code finished. -- [ ] Tested with Package_check. -- [ ] Fix or enhancement tested. -- [ ] Upgrade from last version tested. -- [ ] Can be reviewed and tested. - -## Package_check results ---- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/invoiceninja_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/invoiceninja_ynh%20PR-NUM-%20(USERNAME)/) From 5f77391e89b6b4cbdbfa52146cbe98c3f966207c Mon Sep 17 00:00:00 2001 From: Yunohost-Bot <> Date: Thu, 13 May 2021 17:48:08 +0200 Subject: [PATCH 02/12] [autopatch] Update issue and PR templates --- .github/ISSUE_TEMPLATE.md | 55 ++++++++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 16 ++++++++++ 2 files changed, 71 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) From 583cf364d9a87cde0a94605f18e8a49c37ec66cc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 16 May 2021 15:21:44 +0200 Subject: [PATCH 03/12] Update LICENSE --- LICENSE | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index f3cff84..9e11720 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,47 @@ -File containing the license of your package. +Copyright (c) 2018 by Hillel Coren +Invoice Ninja * https://www.invoiceninja.com +"CREATE. SEND. GET PAID" -More information here: -https://github.com/YunoHost/doc/blob/master/packaging_apps_guidelines_fr.md#yep-13---indiquer-la-licence-associ%C3%A9e-au-paquet---brouillon--auto--working- +All Rights Reserved +ATTRIBUTION ASSURANCE LICENSE (adapted from the original BSD license) +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the conditions below are met. +These conditions require a modest attribution to InvoiceNinja.com (the +"Author"), who hopes that its promotional value may help justify the +thousands of dollars in otherwise billable time invested in writing +this and other freely available, open-source software. + +1. Redistributions of source code, in whole or part and with or without +modification (the "Code"), must prominently display this GPG-signed +text in verifiable form. +2. Redistributions of the Code in binary form must be accompanied by +this GPG-signed text in any documentation and, each time the resulting +executable program or a program dependent thereon is launched, a +prominent display (e.g., splash screen or banner text) of the Author's +attribution information, which includes: +(a) Name ("Hillel Coren"), +(b) Professional identification ("Invoice Ninja"), and +(c) URL ("https://www.invoiceninja.com"). +3. Neither the name nor any trademark of the Author may be used to +endorse or promote products derived from this software without specific +prior written permission. +4. Users are entirely responsible, to the exclusion of the Author and +any other persons, for compliance with (1) regulations set by owners or +administrators of employed equipment, (2) licensing terms of any other +software, and (3) local regulations regarding use, including those +regarding import, export, and use of encryption software. + +THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS; +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. From 8b0d4c782f5c7727c739b2d64ca0628d3da2d0fb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 16 May 2021 15:47:40 +0200 Subject: [PATCH 04/12] Apply last example_ynh --- README.md | 2 +- check_process | 22 ++-- {sources/extra_files/app => conf}/.env | 0 conf/app.src | 6 +- conf/nginx.conf | 2 +- conf/php-fpm.conf | 2 +- conf/systemd.service | 13 --- manifest.json | 16 +-- scripts/backup | 2 +- scripts/change_url | 20 ++-- scripts/install | 73 +++++--------- scripts/remove | 8 +- scripts/restore | 37 +++---- scripts/upgrade | 134 ++++++++++--------------- 14 files changed, 123 insertions(+), 214 deletions(-) rename {sources/extra_files/app => conf}/.env (100%) delete mode 100644 conf/systemd.service diff --git a/README.md b/README.md index 19e58fa..f797431 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview Invoice Ninja is the #1 open-source platform to create & email invoices, track payments and expenses, and time billable tasks & projects for clients. -**Shipped version:** v4.5.18 +**Shipped version:** v5.1.62 ## Screenshots diff --git a/check_process b/check_process index 06cffda..8de3a05 100644 --- a/check_process +++ b/check_process @@ -1,13 +1,8 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - admin="john" (USER) + domain="domain.tld" + path="/path" + admin="john" language="fr" ; Checks pkg_linter=1 @@ -17,18 +12,15 @@ setup_private=0 setup_public=0 upgrade=1 - #upgrade=1 from_commit=CommitHash + # 4.5.18~ynh1 + upgrade=1 from_commit=572f98be58975399c5e7fc7d435a4ac5b78765da backup_restore=1 multi_instance=1 port_already_use=0 change_url=1 -;;; Levels - # If the level 5 (Package linter) is forced to 1. Please add justifications here. - Level 5=auto ;;; Options Email= Notification=none ;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& + ; commit=572f98be58975399c5e7fc7d435a4ac5b78765da + name=4.5.18~ynh1 diff --git a/sources/extra_files/app/.env b/conf/.env similarity index 100% rename from sources/extra_files/app/.env rename to conf/.env diff --git a/conf/app.src b/conf/app.src index c5122f1..a5c9c3a 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://download.invoiceninja.com/ninja-v4.5.18.zip -SOURCE_SUM=f633d841df4bfbcedeea07c846749444ecd5c080fa93009846c62cf193f1bb93 +SOURCE_URL=https://github.com/invoiceninja/invoiceninja/releases/download/v5.1.62-release/invoiceninja.zip +SOURCE_SUM=3b66664ab24888e2487fc59056ec659fb32c1eec88d51edabb7e005372f69e7c SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=ninja-v4.5.18.zip \ No newline at end of file +SOURCE_FILENAME=invoiceninja-v5.1.62.zip \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index 559b4a2..a0c8abf 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -28,7 +28,7 @@ location ^~ __PATH__/ { location ~ ^__PATH__/index\.php(/.*|)$ { fastcgi_split_path_info ^(.+?\.php)(/.*|)$; set $path_info $fastcgi_path_info; - fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index ab5dca9..ab1a471 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -33,7 +33,7 @@ group = __USER__ ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) diff --git a/conf/systemd.service b/conf/systemd.service deleted file mode 100644 index 76cdf64..0000000 --- a/conf/systemd.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Small description of the service -After=network.target - -[Service] -Type=simple -User=__APP__ -Group=__APP__ -WorkingDirectory=__FINALPATH__/ -ExecStart=__FINALPATH__/script >> /var/log/__APP__/__APP__.log 2>&1 - -[Install] -WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index 72d70c2..c4e9f51 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Create and email invoices, track payments and expenses, and time tasks" }, - "version": "4.5.18~ynh1", + "version": "5.1.62~ynh1", "url": "https://invoiceninja.org", "license": "AAL", "maintainer": { @@ -19,7 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.0-fpm", + "php7.3-fpm", "mysql" ], "arguments": { @@ -27,29 +27,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for ynhexample", - "fr": "Choisissez un nom de domaine pour ynhexample" - }, "example": "example.com" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for ynhexample", - "fr": "Choisissez un chemin pour ynhexample" - }, "example": "/invoiceninja", "default": "/invoiceninja" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, "example": "johndoe" }, { diff --git a/scripts/backup b/scripts/backup index 73cf595..c4314ac 100755 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers diff --git a/scripts/change_url b/scripts/change_url index 27cd9a0..d1f6934 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,9 +35,9 @@ db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -45,7 +45,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -73,23 +73,23 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# Change the path in the NGINX config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -119,7 +119,7 @@ ynh_store_file_checksum --file="$config" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index d3df91d..9f43c0a 100755 --- a/scripts/install +++ b/scripts/install @@ -61,6 +61,12 @@ ynh_app_setting_set --app=$app --key=mail_from_name --value="$(ynh_user_get_info #================================================= # STANDARD MODIFICATIONS #================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # CREATE A MYSQL DATABASE @@ -81,56 +87,38 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring php-fpm..." +ynh_script_progression --message="Configuring PHP-FPM..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC SETUP #================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Adding a configuration file..." -config="$final_path/.env" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$config" +ynh_add_config --template="../conf/.env" --destination="$final_path/.env" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" -ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" -ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$config" - -ynh_replace_string --match_string="__API_SECRET__" --replace_string="$(ynh_app_setting_get --app=$app --key=api_secret)" --target_file="$config" -ynh_replace_string --match_string="__APP_KEY__" --replace_string="$(ynh_app_setting_get --app=$app --key=app_key)" --target_file="$config" -ynh_replace_string --match_string="__PHANTOMJS_KEY__" --replace_string="$(ynh_app_setting_get --app=$app --key=phantomjs_jey)" --target_file="$config" - -ynh_replace_string --match_string="__MAIL_FROM_ADDRESS__" --replace_string="$(ynh_app_setting_get --app=$app --key=mail_from_address)" --target_file="$config" -ynh_replace_string --match_string="__MAIL_FROM_NAME__" --replace_string="$(ynh_app_setting_get --app=$app --key=mail_from_name)" --target_file="$config" - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$config" +chmod 400 "$final_path/.env" +chown $app:$app "$final_path/.env" #================================================= # BUILD THE APPLICATION @@ -148,32 +136,17 @@ popd #================================================= ynh_script_progression --message="Adding a cron job..." -cron_path="/etc/cron.d/$app" -cp -a ../conf/invoiceninja.cron "$cron_path" -chown root: "$cron_path" -chmod 644 "$cron_path" +ynh_add_config --template="../conf/invoiceninja.cron" --destination="/etc/cron.d/$app" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$cron_path" -ynh_replace_string --match_string="__DESTDIR__" --replace_string="$final_path" --target_file="$cron_path" -ynh_replace_string --match_string="__YNH_PHP_VERSION__" --replace_string="$YNH_PHP_VERSION" --target_file="$cron_path" +chmod 644 "/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R root: $final_path - -chmod -R 755 $final_path/storage -chown -R $app: $final_path/storage $final_path/bootstrap $final_path/public/logo $final_path/.env - #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index adfc93a..931c0da 100755 --- a/scripts/remove +++ b/scripts/remove @@ -43,17 +43,17 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Removing php-fpm configuration..." +ynh_script_progression --message="Removing PHP-FPM configuration..." -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= diff --git a/scripts/restore b/scripts/restore index 9005ecc..7508b32 100755 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -48,10 +48,18 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the nginx configuration..." +ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir=$final_path + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -59,29 +67,14 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chown -R root: $final_path - -chmod -R 755 $final_path/storage -chown -R $app: $final_path/storage $final_path/bootstrap $final_path/public/logo $final_path/.env +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring PHP-FPM configuration..." +ynh_script_progression --message="Restoring the PHP-FPM configuration..." ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" @@ -106,7 +99,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 46ac006..20f92d1 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,9 +28,26 @@ db_user=$db_name #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -48,56 +65,12 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -# N.B. : this is for app installations before YunoHost 2.7 -# where this value might be something like /foo/ or foo/ -# instead of /foo .... -# If nobody installed your app before 2.7, then you may -# safely remove this line -path_url=$(ynh_normalize_url_path --path_url=$path_url) - -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= - -config="$final_path/.env" -ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" - -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." - - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_app_setting_delete --app=$app --key=is_public fi - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." - -# Create a dedicated nginx config -ynh_add_nginx_config -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # CREATE DEDICATED USER #================================================= @@ -106,41 +79,53 @@ ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_script_progression --message="Upgrading source files..." + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading NGINX web server configuration..." + +# Create a dedicated NGINX config +ynh_add_nginx_config +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) + #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading php-fpm configuration..." +ynh_script_progression --message="Upgrading PHP-FPM configuration..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config #================================================= # SPECIFIC UPGRADE #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Modifying a config file..." + ynh_script_progression --message="Updating a configuration file..." - ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$config" + ynh_add_config --template="../conf/.env" --destination="$final_path/.env" - ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" - ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$config" - ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" - ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_user" --target_file="$config" - ynh_replace_string --match_string="__DB_PASS__" --replace_string="$db_pwd" --target_file="$config" - - ynh_replace_string --match_string="__API_SECRET__" --replace_string="$(ynh_app_setting_get --app=$app --key=api_secret)" --target_file="$config" - ynh_replace_string --match_string="__APP_KEY__" --replace_string="$(ynh_app_setting_get --app=$app --key=app_key)" --target_file="$config" - ynh_replace_string --match_string="__PHANTOMJS_KEY__" --replace_string="$(ynh_app_setting_get --app=$app --key=phantomjs_jey)" --target_file="$config" - - ynh_replace_string --match_string="__MAIL_FROM_ADDRESS__" --replace_string="$(ynh_app_setting_get --app=$app --key=mail_from_address)" --target_file="$config" - ynh_replace_string --match_string="__MAIL_FROM_NAME__" --replace_string="$(ynh_app_setting_get --app=$app --key=mail_from_name)" --target_file="$config" - - # Calculate and store the config file checksum into the app settings - ynh_store_file_checksum --file="$config" + chmod 400 "$final_path/.env" + chown $app:$app "$final_path/.env" fi #================================================= @@ -164,20 +149,11 @@ pushd "$final_path" popd #================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R root: $final_path - -chmod -R 755 $final_path/storage -chown -R $app: $final_path/storage $final_path/bootstrap $final_path/public/logo $final_path/.env - +# GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload From 2aff1d2d802f1f5ce4a256cd01f84c6e3b9dd7f6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 18 May 2021 02:53:36 +0200 Subject: [PATCH 05/12] Fix variables --- manifest.json | 2 +- scripts/install | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index c4e9f51..7fa8f83 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "url": "https://github.com/YunoHost-Apps/invoiceninja_ynh/" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 4.1.0" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 9f43c0a..49fa5e7 100755 --- a/scripts/install +++ b/scripts/install @@ -30,6 +30,12 @@ language=$YNH_APP_ARG_LANGUAGE app=$YNH_APP_INSTANCE_NAME +api_secret="$(ynh_string_random --length=32)" +app_key="$(ynh_string_random --length=32)" +phantomjs_key=$(ynh_string_random --length=32) +mail_from_address="$(ynh_user_get_info $admin mail)" +mail_from_name="$(ynh_user_get_info $admin firstname) $(ynh_user_get_info $admin lastname)" + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -51,12 +57,12 @@ 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=language --value=$language -ynh_app_setting_set --app=$app --key=api_secret --value="$(ynh_string_random --length=32)" -ynh_app_setting_set --app=$app --key=app_key --value="$(ynh_string_random --length=32)" -ynh_app_setting_set --app=$app --key=phantomjs_key --value="$(ynh_string_random --length=32)" +ynh_app_setting_set --app=$app --key=api_secret --value=$api_secret +ynh_app_setting_set --app=$app --key=app_key --value=$app_key +ynh_app_setting_set --app=$app --key=phantomjs_key --value=$phantomjs_key -ynh_app_setting_set --app=$app --key=mail_from_address --value="$(ynh_user_get_info $admin mail)" -ynh_app_setting_set --app=$app --key=mail_from_name --value="$(ynh_user_get_info $admin firstname) $(ynh_user_get_info $admin lastname)" +ynh_app_setting_set --app=$app --key=mail_from_address --value=$mail_from_address +ynh_app_setting_set --app=$app --key=mail_from_name --value=$mail_from_name #================================================= # STANDARD MODIFICATIONS From 2cef3f3514968d301a7a2d3343d452a3ba6ee704 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 18 May 2021 04:28:12 +0200 Subject: [PATCH 06/12] Fix missing __DB_PASS__ --- conf/.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/.env b/conf/.env index f36d9e7..6e3f144 100644 --- a/conf/.env +++ b/conf/.env @@ -14,7 +14,7 @@ DB_TYPE=mysql DB_HOST=localhost DB_DATABASE=__DB_NAME__ DB_USERNAME=__DB_USER__ -DB_PASSWORD=__DB_PASS__ +DB_PASSWORD=__DB_PWD__ MAIL_DRIVER=mail MAIL_PORT=25 From 5e19d80d43cb421ebbfe37153303c385c06fd892 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 19 May 2021 00:56:47 +0200 Subject: [PATCH 07/12] Try to fix install --- scripts/_common.sh | 2 ++ scripts/install | 4 ++-- scripts/upgrade | 10 +++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index ecd263f..2e5c821 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,6 +7,8 @@ # dependencies used by the app pkg_dependencies="" +YNH_PHP_VERSION="7.3" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 49fa5e7..ff8a5a3 100755 --- a/scripts/install +++ b/scripts/install @@ -133,8 +133,8 @@ ynh_script_progression --message="Building the application..." pushd "$final_path" # Run the database migrations and initially fill the db - php$phpversion artisan migrate --no-interaction --verbose --force - php$phpversion artisan db:seed --force --no-interaction --verbose + php$phpversion artisan migrate --force + php$phpversion artisan db:seed --force popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 20f92d1..0af4089 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -135,17 +135,17 @@ ynh_script_progression --message="Upgrading the database..." pushd "$final_path" # Put the application into maintenance mode - php$phpversion artisan down --no-interaction --verbose + php$phpversion artisan down # Optimize the framework for better performance - php$phpversion artisan optimize --force --no-interaction --verbose + php$phpversion artisan optimize --force # Run the database migrations - php$phpversion artisan migrate --no-interaction --verbose - php$phpversion artisan db:seed --class=UpdateSeeder --force --no-interaction --verbose + php$phpversion artisan migrate --force + php$phpversion artisan db:seed --class=UpdateSeeder --force # Bring the application out of maintenance mode - php$phpversion artisan up --no-interaction --verbose + php$phpversion artisan up popd #================================================= From e35e7bd4197ac25a46c6824f4e7709980193afc2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 19 May 2021 20:52:09 +0200 Subject: [PATCH 08/12] Upgrade to 4.5.19 --- README.md | 2 +- conf/app.src | 6 +++--- manifest.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f797431..269b061 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview Invoice Ninja is the #1 open-source platform to create & email invoices, track payments and expenses, and time billable tasks & projects for clients. -**Shipped version:** v5.1.62 +**Shipped version:** v4.5.19 ## Screenshots diff --git a/conf/app.src b/conf/app.src index a5c9c3a..27e1a0b 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ -SOURCE_URL=https://github.com/invoiceninja/invoiceninja/releases/download/v5.1.62-release/invoiceninja.zip -SOURCE_SUM=3b66664ab24888e2487fc59056ec659fb32c1eec88d51edabb7e005372f69e7c +SOURCE_URL=https://download.invoiceninja.com/ninja-v4.5.19.zip +SOURCE_SUM=5a3ec7ab747bb371e7788b215be290eb489b11dea2ba1e1bff7516e7c077364e SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=zip SOURCE_IN_SUBDIR=true -SOURCE_FILENAME=invoiceninja-v5.1.62.zip \ No newline at end of file +SOURCE_FILENAME=invoiceninja-v4.5.19.zip diff --git a/manifest.json b/manifest.json index 7fa8f83..e4fbcb0 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Create and email invoices, track payments and expenses, and time tasks" }, - "version": "5.1.62~ynh1", + "version": "4.5.19~ynh1", "url": "https://invoiceninja.org", "license": "AAL", "maintainer": { From 072ea942a8af00b211fbf32b7c05621edee9fff3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 19 May 2021 20:58:13 +0200 Subject: [PATCH 09/12] Adding information for InvoiceNinja 5 --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 269b061..ea4341a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Invoice Ninja for YunoHost +# Invoice Ninja 4 for YunoHost + +:warning: You are invited to look at [InvoiceNinja 5](https://github.com/YunoHost-Apps/invoiceninja5_ynh) :warning: [![Integration level](https://dash.yunohost.org/integration/invoiceninja.svg)](https://dash.yunohost.org/appci/app/invoiceninja) ![](https://ci-apps.yunohost.org/ci/badges/invoiceninja.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/invoiceninja.maintain.svg) [![Install Invoice Ninja with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=invoiceninja) From 5b9a2915fb8ad251054604fca247c3ab7c80beec Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 20 May 2021 04:36:40 +0200 Subject: [PATCH 10/12] Fix cron --- conf/invoiceninja.cron | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/invoiceninja.cron b/conf/invoiceninja.cron index 14ded0d..0ea7510 100644 --- a/conf/invoiceninja.cron +++ b/conf/invoiceninja.cron @@ -1,3 +1,3 @@ -0 8 * * * __USER__ /usr/bin/php__YNH_PHP_VERSION__ __DESTDIR__/artisan ninja:send-invoices -q -0 8 * * * __USER__ /usr/bin/php__YNH_PHP_VERSION__ __DESTDIR__/artisan ninja:send-reminders -q +0 8 * * * __APP__ /usr/bin/php__YNH_PHP_VERSION__ __FINALPATH__/artisan ninja:send-invoices -q +0 8 * * * __APP__ /usr/bin/php__YNH_PHP_VERSION__ __FINALPATH__/artisan ninja:send-reminders -q From 33b1e506f3a47cb8ed7b8e5d806e16a9bc50498c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 28 May 2021 01:12:17 +0200 Subject: [PATCH 11/12] Fix install --- conf/invoiceninja.cron | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/invoiceninja.cron b/conf/invoiceninja.cron index 0ea7510..ac599a8 100644 --- a/conf/invoiceninja.cron +++ b/conf/invoiceninja.cron @@ -1,3 +1,3 @@ -0 8 * * * __APP__ /usr/bin/php__YNH_PHP_VERSION__ __FINALPATH__/artisan ninja:send-invoices -q -0 8 * * * __APP__ /usr/bin/php__YNH_PHP_VERSION__ __FINALPATH__/artisan ninja:send-reminders -q +0 8 * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/artisan ninja:send-invoices -q +0 8 * * * __APP__ /usr/bin/php__PHPVERSION__ __FINALPATH__/artisan ninja:send-reminders -q From aa704dd90c1126c926b6d68fd119080ad8a69d8c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 16 Jun 2021 21:40:19 +0200 Subject: [PATCH 12/12] Fix missing var --- scripts/upgrade | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0af4089..eefce3f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,8 +22,13 @@ admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) db_user=$db_name +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +api_secret=$(ynh_app_setting_get --app=$app --key=api_secret) +app_key=$(ynh_app_setting_get --app=$app --key=app_key) +phantomjs_key=$(ynh_app_setting_get --app=$app --key=phantomjs_key) +mail_from_address=$(ynh_app_setting_get --app=$app --key=mail_from_address) +mail_from_name=$(ynh_app_setting_get --app=$app --key=mail_from_name) #================================================= # CHECK VERSION