1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kresus_ynh.git synced 2024-09-03 19:36:10 +02:00

Migrate to packaging format version 2

This commit is contained in:
Éric Gaspar 2023-05-22 23:31:46 +02:00 committed by Nicolas Frandeboeuf
parent 303ff05310
commit 2c288cc279
23 changed files with 244 additions and 855 deletions

View file

@ -19,39 +19,14 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
Kresus is an open-source libre self-hosted personal finance manager. It allows you to safely track your banking history, check your overall balance and know exactly how you are spending money using categories! Kresus is an open-source libre self-hosted personal finance manager. It allows you to safely track your banking history, check your overall balance and know exactly how you are spending money using categories!
**Shipped version:** 0.19.4~ynh4 **Shipped version:** 0.19.4~ynh5
**Demo:** https://kresus.org/en/demo.html
## Screenshots ## Screenshots
![Screenshot of Kresus](./doc/screenshots/screenshot.png) ![Screenshot of Kresus](./doc/screenshots/screenshot.png)
## Disclaimers / important information
## Demo
* [Official demo](https://kresus.org/en/demo.html) Don't set up a connection to your bank accounts, or everybody would be able to look at your private bank information!
32 bits architectures are not supported because nodejs does not provide builds for 32 bits anymore.
## Limitations
* By default, all users have access to the accounts. The admin needs to manually select the authorised user through YunoHost Administration Panel.
## Roadmap
* works fine:
* [x] install/remove/backup/remove/upgrade with x86_64
* to be confirmed
* [x] ARM support
* to be added:
* [ ] URL cannot be changed
* [ ] Email support
* [ ] Improve log file and add logrotate
* [ ] Add user who will access the app (by default every one has access to the installed app)
## Documentation and resources ## Documentation and resources
* Official app website: <https://framagit.org/kresusapp/kresus> * Official app website: <https://framagit.org/kresusapp/kresus>

View file

@ -18,45 +18,21 @@ Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po
Kresus est un gestionnaire de finances personnelles gratuit et libre qui tourne sur votre serveur. Il récupère automatiquement et quotidiennement toutes vos nouvelles transactions bancaires et vous permet de les catégoriser, étudier via des graphiques, et établir un budget. Kresus est un gestionnaire de finances personnelles gratuit et libre qui tourne sur votre serveur. Il récupère automatiquement et quotidiennement toutes vos nouvelles transactions bancaires et vous permet de les catégoriser, étudier via des graphiques, et établir un budget.
**Version incluse :** 0.19.4~ynh4 **Version incluse :** 0.19.4~ynh5
**Démo :** https://kresus.org/en/demo.html
## Captures décran ## Captures décran
![Capture décran de Kresus](./doc/screenshots/screenshot.png) ![Capture décran de Kresus](./doc/screenshots/screenshot.png)
## Avertissements / informations importantes
## Démo
* [Démo officielle](https://kresus.org/fr/demo.html) Ne créez pas une connexion à vos comptes bancaires, ou bien tout le monde pourra voir vos données bancaires privées !
Les architectures 32 bits ne sont pas prises en charge car nodejs ne fournit plus d'archives pour systèmes 32 bits.
## Limitations
* Par défault, tous les utilisateurs ont accès aux comptes. L'administrateur doit manuellement sélectionner l'utilisateur autorisé via l'écran d'administration YunoHost.
## Feuille de route
* Fonctionne correctement :
* [x] installation/suppression/sauvegarde/mise à jour avec x86_64
* À confirmer
* [x] Prise en charge ARM
* À venir :
* [ ] l'URL ne peut pas être modifiée
* [ ] Prise en charge des emails
* [ ] Amélioraton des logs et de leur rotation
* [ ] Ajouter un utilisateur qui seul aura accès à l'application (par défaut tout le monde a accès à l'application)
## Documentations et ressources ## Documentations et ressources
* Site officiel de lapp : <https://framagit.org/kresusapp/kresus> * Site officiel de lapp : <https://framagit.org/kresusapp/kresus>
* Documentation officielle de ladmin : <https://kresus.org/en/doc.html> * Documentation officielle de ladmin : <https://kresus.org/en/doc.html>
* Dépôt de code officiel de lapp : <https://framagit.org/kresusapp/kresus> * Dépôt de code officiel de lapp : <https://framagit.org/kresusapp/kresus>
* YunoHost Store: <https://apps.yunohost.org/app/kresus> * YunoHost Store: <https://apps.yunohost.org/app/kresus>
* YunoHost Store: <https://apps.yunohost.org/app/kresus>
* Signaler un bug : <https://github.com/YunoHost-Apps/kresus_ynh/issues> * Signaler un bug : <https://github.com/YunoHost-Apps/kresus_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs

View file

@ -1,23 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
path="/path"
; Checks
pkg_linter=1
setup_sub_dir=1
setup_root=1
setup_nourl=0
setup_private=1
setup_public=0
upgrade=1
# 0.16.0~ynh4
#upgrade=1 from_commit=bd7259e916130f933f6ecdc8d6362e1fa7164d8f
# 0.18.1~ynh6
upgrade=1 from_commit=c5d4c9a728365771f5536bdac3830b86d75d895a
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=
Notification=none

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://framagit.org/kresusapp/kresus/-/archive/0.19.4/kresus-0.19.4.tar.bz2
SOURCE_SUM=c168beaa37194f9e89c5f89bb163ea77dec8d7ce13fd1517e5c8d2b00a6234a9
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.bz2
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -11,7 +11,7 @@
; Overriden by the KRESUS_DIR environment variable, if it's set. ; Overriden by the KRESUS_DIR environment variable, if it's set.
; Example: ; Example:
; datadir=/home/ben/.kresus ; datadir=/home/ben/.kresus
datadir=__FINALPATH__/data/ datadir=__DATA_DIR__
; A user id obtained from using the "kresus create-user" command. ; A user id obtained from using the "kresus create-user" command.
; This allows sharing a single database with several users. If your ; This allows sharing a single database with several users. If your
@ -45,7 +45,7 @@ host=127.0.0.1
; Overriden by the KRESUS_PYTHON_EXEC environment variable, if it's set. ; Overriden by the KRESUS_PYTHON_EXEC environment variable, if it's set.
; Example: ; Example:
; python_exec=python3 ; python_exec=python3
python_exec=__FINALPATH__/venv/bin/python python_exec=__INSTALL_DIR__/venv/bin/python
; The directory prefix in the URL, if Kresus is to be served from a ; The directory prefix in the URL, if Kresus is to be served from a
; subdirectory. For instance, if your website is hosted at example.com ; subdirectory. For instance, if your website is hosted at example.com
@ -118,7 +118,7 @@ sources_list=
; Overriden by the KRESUS_EMAIL_TRANSPORT environment variable, if it's set. ; Overriden by the KRESUS_EMAIL_TRANSPORT environment variable, if it's set.
; Example: ; Example:
; transport=smtp ; transport=smtp
transport=sendmail transport=smtp
; The path to the sendmail executable to use. If empty, indicates ; The path to the sendmail executable to use. If empty, indicates
; that the default sendmail executable will be used. ; that the default sendmail executable will be used.
@ -147,21 +147,21 @@ host=127.0.0.1
; Overriden by the KRESUS_EMAIL_PORT environment variable, if it's set. ; Overriden by the KRESUS_EMAIL_PORT environment variable, if it's set.
; Example: ; Example:
; port=465 ; port=465
port=465 port=25
; The username used during authentication to the SMTP server. If ; The username used during authentication to the SMTP server. If
; empty, indicates an anonymous connection will be used. ; empty, indicates an anonymous connection will be used.
; Overriden by the KRESUS_EMAIL_USER environment variable, if it's set. ; Overriden by the KRESUS_EMAIL_USER environment variable, if it's set.
; Example: ; Example:
; user=login ; user=login
user= user=__APP__
; The password used during authentication to the SMTP server. If ; The password used during authentication to the SMTP server. If
; empty, indicates no password will be used. ; empty, indicates no password will be used.
; Overriden by the KRESUS_EMAIL_PASSWORD environment variable, if it's set. ; Overriden by the KRESUS_EMAIL_PASSWORD environment variable, if it's set.
; Example: ; Example:
; password=hunter2 ; password=hunter2
password= password=__MAIL_PWD__
; If set to true, will force using a TLS connection. By default, ; If set to true, will force using a TLS connection. By default,
; emails are sent with STARTTLS, i.e. using TLS if available. ; emails are sent with STARTTLS, i.e. using TLS if available.
@ -192,7 +192,7 @@ appriseApiBaseUrl=
[logs] [logs]
; The path to the log file to use. If empty, defaults to kresus.log ; The path to the log file to use. If empty, defaults to kresus.log
; in datadir. ; in data_dir.
; Overriden by the KRESUS_LOG_FILE environment variable, if it's set. ; Overriden by the KRESUS_LOG_FILE environment variable, if it's set.
; Example: ; Example:
; log_file=/var/log/kresus.log ; log_file=/var/log/kresus.log

View file

@ -1,7 +1,6 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ { location __PATH__/ {
alias __INSTALL_DIR__/build/client/;
alias __FINALPATH__/build/client/;
try_files $uri $uri/index.html @__NAME__; try_files $uri $uri/index.html @__NAME__;
# Include SSOWAT user panel. # Include SSOWAT user panel.

View file

@ -1,15 +1,15 @@
[Unit] [Unit]
Description=__APP__ Description=__APP__: personal finance manager
After=syslog.target network.target After=syslog.target network.target
[Service] [Service]
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
Environment="__YNH_NODE_LOAD_PATH__" Environment="__YNH_NODE_LOAD_PATH__"
Environment=NODE_ENV=production Environment=NODE_ENV=production
ExecStart=__FINALPATH__/bin/kresus.js --config __FINALPATH__/config.ini ExecStart=__INSTALL_DIR__/bin/kresus.js --config __INSTALL_DIR__/config.ini
Restart=always Restart=always
StandardOutput=syslog StandardOutput=syslog
StandardError=syslog StandardError=syslog
@ -29,7 +29,8 @@ PrivateTmp=true
PrivateUsers=false PrivateUsers=false
ProtectClock=true ProtectClock=true
ProtectControlGroups=true ProtectControlGroups=true
ProtectHome=true # See https://github.com/systemd/systemd/issues/7153
ProtectHome=false
ProtectHostname=true ProtectHostname=true
ProtectKernelLogs=true ProtectKernelLogs=true
ProtectKernelModules=true ProtectKernelModules=true
@ -44,14 +45,7 @@ RestrictSUIDSGID=true
SystemCallArchitectures=native SystemCallArchitectures=native
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
SystemCallErrorNumber=EPERM SystemCallErrorNumber=EPERM
ReadWritePaths=__DATA_DIR__
# to allow this systemd service to use sendmail.
# references:
# https://bugs.archlinux.org/task/57721
# https://linux.m2osw.com/snapwebsites-postfixpostdrop18189-warning-mailqueueenter-create-file-maildrop25937318189-permission
# Future wait for this ticket to be resolved: https://github.com/YunoHost/issues/issues/947
SupplementaryGroups=postdrop
ReadWritePaths=__FINALPATH__/config.ini __FINALPATH__/data/ /var/spool/postfix/maildrop/
[Install] [Install]

10
doc/ADMIN.md Normal file
View file

@ -0,0 +1,10 @@
## Limitations
* By default, all users have access to the accounts. The admin needs to manually select the authorised user through YunoHost Administration Panel.
## Roadmap
* to be added:
* [ ] URL cannot be changed
* [ ] Improve log file and add logrotate
* [ ] Add user who will access the app (by default every one has access to the installed app)

10
doc/ADMIN_fr.md Normal file
View file

@ -0,0 +1,10 @@
## Limitations
* Par défaut, tous les utilisateurs ont accès aux comptes. L'administrateur doit manuellement sélectionner l'utilisateur autorisé via l'écran d'administration YunoHost.
## Feuille de route
* À venir :
* [ ] l'URL ne peut pas être modifiée
* [ ] Amélioration des logs et de leur rotation
* [ ] Ajouter un utilisateur qui seul aura accès à l'application (par défaut tout le monde a accès à l'application)

View file

@ -1,24 +0,0 @@
## Demo
* [Official demo](https://kresus.org/en/demo.html) Don't set up a connection to your bank accounts, or everybody would be able to look at your private bank information!
32 bits architectures are not supported because nodejs does not provide builds for 32 bits anymore.
## Limitations
* By default, all users have access to the accounts. The admin needs to manually select the authorised user through YunoHost Administration Panel.
## Roadmap
* works fine:
* [x] install/remove/backup/remove/upgrade with x86_64
* to be confirmed
* [x] ARM support
* to be added:
* [ ] URL cannot be changed
* [ ] Email support
* [ ] Improve log file and add logrotate
* [ ] Add user who will access the app (by default every one has access to the installed app)

View file

@ -1,24 +0,0 @@
## Démo
* [Démo officielle](https://kresus.org/fr/demo.html) Ne créez pas une connexion à vos comptes bancaires, ou bien tout le monde pourra voir vos données bancaires privées !
Les architectures 32 bits ne sont pas prises en charge car nodejs ne fournit plus d'archives pour systèmes 32 bits.
## Limitations
* Par défault, tous les utilisateurs ont accès aux comptes. L'administrateur doit manuellement sélectionner l'utilisateur autorisé via l'écran d'administration YunoHost.
## Feuille de route
* Fonctionne correctement :
* [x] installation/suppression/sauvegarde/mise à jour avec x86_64
* À confirmer
* [x] Prise en charge ARM
* À venir :
* [ ] l'URL ne peut pas être modifiée
* [ ] Prise en charge des emails
* [ ] Amélioraton des logs et de leur rotation
* [ ] Ajouter un utilisateur qui seul aura accès à l'application (par défaut tout le monde a accès à l'application)

9
doc/POST_INSTALL.md Normal file
View file

@ -0,0 +1,9 @@
Domain: __DOMAIN__
Path : __PATH__
Config: __INSTALL_DIR__/config.ini
Please remember the default behavior of YunoHost when installing a new app is: everyone has access to the app.
This may be an issue for Kresus as it is a personal tool. Please remember to edit access rights in the YunoHost web administration panel or using command line interface.
Note about config.ini: this package will regenerate the config file on upgrade.
If you changed it manually and upgraded Kresus, you'll find a backup in __INSTALL_DIR__.

9
doc/POST_UPGRADE.md Normal file
View file

@ -0,0 +1,9 @@
Domain: __DOMAIN__
Path : __PATH__
Config: __INSTALL_DIR__/config.ini
Please remember the default behavior of YunoHost when installing a new app is: everyone has access to the app.
This may be an issue for Kresus as it is a personal tool. Please remember to edit access rights in the YunoHost web administration panel or using command line interface.
Note about config.ini: this package will regenerate the config file on upgrade.
If you changed it manually and upgraded Kresus, you'll find a backup in __INSTALL_DIR__.

View file

@ -1,49 +0,0 @@
{
"name": "Kresus",
"id": "kresus",
"packaging_format": 1,
"description": {
"en": "Personal finance manager",
"fr": "Outil personnel de gestion de finances"
},
"version": "0.19.4~ynh4",
"url": "https://framagit.org/kresusapp/kresus",
"upstream": {
"license": "AGPL-3.0-only",
"website": "https://framagit.org/kresusapp/kresus",
"admindoc": "https://kresus.org/en/doc.html",
"code": "https://framagit.org/kresusapp/kresus"
},
"license": "AGPL-3.0-only",
"maintainer": {
"name": "Nicolas <nicofrand> Frandeboeuf",
"email": "mail@nicofrand.eu"
},
"previous_maintainers": [
{
"name": "Jean-Baptiste Holcroft",
"email": "jean-baptiste@holcroft.fr"
}
],
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": true,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "path",
"type": "path",
"example": "/kresus",
"default": "/kresus"
}
]
}
}

65
manifest.toml Normal file
View file

@ -0,0 +1,65 @@
packaging_format = 2
id = "kresus"
name = "Kresus"
description.en = "Personal finance manager"
description.fr = "Outil personnel de gestion de finances"
version = "0.19.4~ynh5"
maintainers = ["Nicolas <nicofrand> Frandeboeuf"]
[upstream]
license = "AGPL-3.0-only"
website = "https://framagit.org/kresusapp/kresus"
demo = "https://kresus.org/en/demo.html"
admindoc = "https://kresus.org/en/doc.html"
code = "https://framagit.org/kresusapp/kresus"
[integration]
yunohost = ">= 11.2"
architectures = ["amd64", "arm64"]
multi_instance = true
ldap = false
sso = false
disk = "50M"
ram.build = "50M"
ram.runtime = "50M"
[install]
[install.domain]
type = "domain"
[install.path]
type = "path"
default = "/kresus"
[install.init_main_permission]
type = "group"
default = "all_users"
[resources]
[resources.sources.main]
url = "https://framagit.org/kresusapp/kresus/-/archive/0.19.4/kresus-0.19.4.tar.bz2"
sha256 = "c168beaa37194f9e89c5f89bb163ea77dec8d7ce13fd1517e5c8d2b00a6234a9"
[resources.ports]
[resources.system_user]
allow_email = true
[resources.install_dir]
[resources.data_dir]
[resources.permissions]
main.url = "/"
[resources.apt]
packages = "locales, git, python3, python3-dev, python3-pip, python3-selenium, python3-josepy, libffi-dev, libxml2-dev, libxslt-dev, libyaml-dev, libtiff-dev, libjpeg-dev, libopenjp2-7-dev, zlib1g-dev, libfreetype6-dev, libwebp-dev, build-essential, gcc, g++, wget, unzip, mupdf-tools, libnss3-tools, python3-nss, virtualenv, postgresql"
extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main"
extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
extras.yarn.packages = "yarn"
[resources.database]
type = "postgresql"

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app (must be on a single line)
pkg_dependencies="locales git python3 python3-dev python3-pip python3-selenium python3-josepy libffi-dev libxml2-dev libxslt-dev libyaml-dev libtiff-dev libjpeg-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev libwebp-dev build-essential gcc g++ wget unzip mupdf-tools libnss3-tools python3-nss virtualenv postgresql"
nodejs_version=16 nodejs_version=16
#================================================= #=================================================
@ -20,60 +17,3 @@ nodejs_version=16
#================================================= #=================================================
# FUTURE OFFICIAL HELPERS # FUTURE OFFICIAL HELPERS
#================================================= #=================================================
# Send an email to inform the administrator
#
# usage: ynh_send_readme_to_admin app_message [recipients]
# | arg: app_message - The message to send to the administrator.
# | arg: 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"
ynh_send_readme_to_admin() {
local app_message="${1:-...No specific information...}"
local recipients="${2:-root}"
# 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")
local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!"
local mail_message="This is an automated message from your beloved YunoHost server.
Specific information for the application $app.
$app_message"
# 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
# Send the email to the recipients
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
}

View file

@ -10,27 +10,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
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)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -40,7 +19,13 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$data_dir" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -9,66 +9,6 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN
new_path=$YNH_APP_NEW_PATH
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
port=$(ynh_app_setting_get --app=$app --key=port)
salt=$(ynh_app_setting_get --app=$app --key=salt)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
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
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# CHECK WHICH PARTS SHOULD BE CHANGED
#=================================================
change_domain=0
if [ "$old_domain" != "$new_domain" ]
then
change_domain=1
fi
change_path=0
if [ "$old_path" != "$new_path" ]
then
change_path=1
fi
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
#================================================= #=================================================
@ -83,29 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
# 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
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#================================================= #=================================================
# SPECIFIC MODIFICATIONS # SPECIFIC MODIFICATIONS
@ -116,10 +34,10 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
domain=$new_domain domain=$new_domain
path=$new_path path=$new_path
ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
chmod 400 "$final_path/config.ini" chmod 400 "$install_dir/config.ini"
chown $app:$app "$final_path/config.ini" chown $app:$app "$install_dir/config.ini"
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
@ -131,13 +49,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -9,107 +9,30 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
app=$YNH_APP_INSTANCE_NAME
salt=$(ynh_string_random --length=40) salt=$(ynh_string_random --length=40)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
# Check machine architecture (in particular, we don't support ARM and 32bit machines)
if [ $YNH_ARCH == "i386" ];
then
ynh_die --message="Sorry, because of nodejs framework, this app can't be installed on i386 (32 bits) machine."
fi
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=salt --value=$salt ynh_app_setting_set --app=$app --key=salt --value=$salt
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=9876)
ynh_app_setting_set --app=$app --key=port --value=$port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=1 ynh_script_progression --message="Installing dependencies..." --weight=1
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# CREATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=1 ynh_script_progression --message="Setting up source files..." --weight=1
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
mkdir -p "$final_path/data" chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
@ -119,6 +42,18 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
yunohost service add $app --description="Personal finance manager" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
@ -128,74 +63,45 @@ ynh_script_progression --message="Installing woob..." --weight=1
locale-gen C.UTF-8 locale-gen C.UTF-8
update-locale C.UTF-8 update-locale C.UTF-8
ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${final_path}/venv" ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${install_dir}/venv"
( (
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${install_dir}/venv/bin/activate"
set -o nounset set -o nounset
ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal' ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal'
export PATH="$final_path/.cargo/bin:$PATH" export PATH="$install_dir/.cargo/bin:$PATH"
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade setuptools ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade setuptools
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow --ignore-installed ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow --ignore-installed
ynh_secure_remove --file="$final_path/.cargo" ynh_secure_remove --file="$install_dir/.cargo"
ynh_secure_remove --file="$final_path/.rustup" ynh_secure_remove --file="$install_dir/.rustup"
ynh_secure_remove --file="$final_path/.cache" ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$final_path/.local" ynh_secure_remove --file="$install_dir/.local"
) )
#================================================= #=================================================
# INSTALL KRESUS WITH NPM # INSTALL KRESUS WITH NPM
#================================================= #=================================================
ynh_script_progression --message="Installing app..." --weight=1 ynh_script_progression --message="Installing $app..." --weight=1
ynh_use_nodejs pushd $install_dir
( ynh_use_nodejs
cd "$final_path" ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all
ynh_secure_remove --file="$final_path/.cache" ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$final_path/.yarn" ynh_secure_remove --file="$install_dir/.yarn"
) popd
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
chmod 400 "$final_path/config.ini" chmod 400 "$install_dir/config.ini"
chown $app:$app "$final_path/config.ini" chown $app:$app "$install_dir/config.ini"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1
mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/"
# Use logrotate to manage application logfile(s)
ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -205,34 +111,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND README TO ADMIN
#=================================================
ynh_script_progression --message="Sending ReadMe to admin..." --weight=1
message="
Domain: $domain
Path : $path_url
Config: $final_path/config.ini
Please remember the default behavior of YunoHost when installing a new app is: everyone has access to the app.
This may be an issue for Kresus as it is a personal tool. Please remember to edit access rights in the YunoHost web administration panel or using command line interface.
Note about config.ini: this package will regenerate the config file on upgrade.
If you changed it manually and upgrade Kresus, you'll find a backup in $final_path.
Are you facing an issue, want to improve this app or say thank you?
Please open a new issue in this project: https://github.com/YunoHost-Apps/kresus_ynh
"
ynh_send_readme_to_admin "$message"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,23 +10,11 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # REMOVE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 # REMOVE SYSTEMD SERVICE
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
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)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null if ynh_exec_warn_less yunohost service status $app >/dev/null
@ -35,75 +23,21 @@ then
yunohost service remove $app yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=1
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_nodejs ynh_remove_nodejs
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
ynh_script_progression --message="Removing various files..." --weight=1
# Remove the log files # Remove the log files
ynh_secure_remove --file="/var/log/$app" ynh_secure_remove --file="/var/log/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -10,68 +10,28 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
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
salt=$(ynh_app_setting_get --app=$app --key=salt)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=1
architecture=$YNH_ARCH
# Check machine architecture (in particular, we don't support ARM and 32bit machines)
if [ $YNH_ARCH == "i386" ]
then
ynh_die --message="Sorry, because of nodejs framework, this app can't be installed on i386 (32 bits) machine."
fi
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R $app:www-data "$install_dir"
chown -R $app:www-data "$final_path"
chmod 400 "$final_path/config.ini" chmod 400 "$install_dir/config.ini"
chown $app:$app "$final_path/config.ini" chown $app:$app "$install_dir/config.ini"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_dir" --not_mandatory
# (Same as for install dir)
chown -R $app:www-data "$data_dir"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -80,52 +40,33 @@ chown $app:$app "$final_path/config.ini"
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=1 ynh_script_progression --message="Reinstalling dependencies..." --weight=1
# Define and install dependencies
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
ynh_psql_test_if_first_run ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 # RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable $app.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
mkdir -p "/var/log/$app/" mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log" touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/" chown -R $app:$app "/var/log/$app/"
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= yunohost service add $app --description="Personal finance manager" --log="/var/log/$app/$app.log"
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -134,13 +75,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================

View file

@ -9,43 +9,12 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
salt=$(ynh_app_setting_get --app=$app --key=salt)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..." --weight=1
upgrade_type=$(ynh_check_app_version_changed) 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)..." --weight=1
# 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 # STANDARD UPGRADE STEPS
#================================================= #=================================================
@ -60,43 +29,17 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# Previous versions did not set the DB name as a setting, so we need to set it now (will be used on if [ -d "/home/ynh$app" ]; then
# remove). mv "/home/ynh$app/data" "$install_dir/data"
if [ -z "$db_name" ]
then
db_name=$(ynh_sanitize_dbid --db_name=$app)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
db_user=$db_name
fi
# If final_path doesn't exist, create it
if [ -z "$final_path" ]
then
final_path=/var/www/$app
ynh_app_setting_set "$app" final_path "$final_path"
fi
if [ -d "/home/ynh$app" ]
then
mv "/home/ynh$app/data" "$final_path/data"
ynh_secure_remove --file="/home/ynh$app" ynh_secure_remove --file="/home/ynh$app"
fi fi
if [ -z "$salt" ] if [ -z "${salt:-}" ]; then
then
salt=$(ynh_string_random 40) salt=$(ynh_string_random 40)
ynh_app_setting_set "$app" salt "$salt" ynh_app_setting_set --app=$app --key=salt --value=$salt
fi fi
usermod -d $final_path $app usermod -d $install_dir $app
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -106,49 +49,40 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then then
ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=1
tmpdir="$(mktemp -d)"
cp "$final_path/config.ini" "$tmpdir/config.ini"
ynh_secure_remove --file="$final_path"
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir" --keep="config.ini"
cp "$tmpdir/config.ini" "$final_path/config.ini"
ynh_secure_remove --file="$tmpdir"
mkdir -p "$final_path/data"
fi fi
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R $app:www-data "$install_dir"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=1 ynh_script_progression --message="Upgrading dependencies..." --weight=1
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
# Now that postgresql is installed, check the db exists and the user is set up
if [ -z "$db_pwd" ]
then
ynh_script_progression --message="Setting up database"
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
fi
#================================================= #=================================================
# NGINX CONFIGURATION # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
yunohost service add $app --description="Personal finance manager" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
@ -158,22 +92,22 @@ ynh_script_progression --message="Installing woob..." --weight=1
locale-gen C.UTF-8 locale-gen C.UTF-8
update-locale C.UTF-8 update-locale C.UTF-8
ynh_secure_remove --file="${final_path}/venv" ynh_secure_remove --file="${install_dir}/venv"
ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${final_path}/venv" ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${install_dir}/venv"
( (
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${install_dir}/venv/bin/activate"
set -o nounset set -o nounset
ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal' ynh_exec_warn_less ynh_exec_as $app RUSTUP_HOME="$install_dir"/.rustup CARGO_HOME="$install_dir"/.cargo bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -q -y --default-toolchain=stable --profile=minimal'
export PATH="$final_path/.cargo/bin:$PATH" export PATH="$install_dir/.cargo/bin:$PATH"
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade pip
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade setuptools ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install --upgrade setuptools
ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow --ignore-installed ynh_exec_warn_less ynh_exec_as $app env PATH=$PATH pip install woob simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six Pillow --ignore-installed
ynh_secure_remove --file="$final_path/.cargo" ynh_secure_remove --file="$install_dir/.cargo"
ynh_secure_remove --file="$final_path/.rustup" ynh_secure_remove --file="$install_dir/.rustup"
ynh_secure_remove --file="$final_path/.cache" ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$final_path/.local" ynh_secure_remove --file="$install_dir/.local"
) )
#================================================= #=================================================
@ -181,57 +115,28 @@ ynh_exec_as $app virtualenv --python=python3 --system-site-packages "${final_pat
#================================================= #=================================================
ynh_script_progression --message="Installing app..." --weight=1 ynh_script_progression --message="Installing app..." --weight=1
ynh_use_nodejs pushd $install_dir
( ynh_use_nodejs
cd "$final_path"
# In case of nodejs upgrade, remove the current node_modules to make sure there are no errors # In case of nodejs upgrade, remove the current node_modules to make sure there are no errors
# linked to modules compiled for the previous version. # linked to modules compiled for the previous version.
ynh_secure_remove --file="$final_path/node_modules" ynh_secure_remove --file="$install_dir/node_modules"
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn install --production
ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH yarn cache clean --all
ynh_secure_remove --file="$final_path/.cache" ynh_secure_remove --file="$install_dir/.cache"
ynh_secure_remove --file="$final_path/.yarn" ynh_secure_remove --file="$install_dir/.yarn"
) popd
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini" ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
chmod 400 "$final_path/config.ini" chmod 400 "$install_dir/config.ini"
chown $app:$app "$final_path/config.ini" chown $app:$app "$install_dir/config.ini"
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config
ynh_add_systemd_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
mkdir -p "/var/log/$app/"
touch "/var/log/$app/$app.log"
chown -R $app:$app "/var/log/$app/"
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
@ -240,33 +145,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready" ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Server is ready"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# SEND README TO ADMIN
#=================================================
ynh_script_progression --message="Sending ReadMe to admin..." --weight=1
message="
Kresus was successfully updated!
Domain: $domain
Path : $path_url
Config: $final_path/config.ini
Note about config.ini: this package will regenerate the config file on upgrade.
If you changed it manually and upgrade Kresus, you'll find a backup in $final_path.
Are you facing an issue, want to improve this app or say thank you?
Please open a new issue in this project: https://github.com/YunoHost-Apps/kresus_ynh
"
ynh_send_readme_to_admin "$message"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

9
tests.toml Normal file
View file

@ -0,0 +1,9 @@
test_format = 1.0
[default]
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.c5d4c9a728365771f5536bdac3830b86d75d895a.name = "Upgrade from 0.18.1~ynh6"