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

Merge pull request #123 from YunoHost-Apps/upgrade

Upgrade
This commit is contained in:
yalh76 2022-06-19 03:05:05 +02:00 committed by GitHub
commit 4693050608
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 60 additions and 56 deletions

View file

@ -18,7 +18,7 @@ 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!
**Shipped version:** 0.18.1~ynh1
**Shipped version:** 0.18.1~ynh2
## Screenshots

View file

@ -17,7 +17,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour
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.18.1~ynh1
**Version incluse :** 0.18.1~ynh2
## Captures d'écran

View file

@ -19,4 +19,3 @@
;;; Options
Email=
Notification=all
;;; Upgrade options

View file

@ -6,16 +6,20 @@ After=syslog.target network.target
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
Environment="PATH=__YNH_NODE_LOAD_PATH__"
WorkingDirectory=__FINALPATH__/
Environment="__YNH_NODE_LOAD_PATH__"
Environment=NODE_ENV=production
ExecStart=__FINALPATH__/bin/kresus.js --config __FINALPATH__/config.ini
Restart=always
NoNewPrivileges=true
PrivateDevices=true
PrivateTmp=true
ProtectHome=true
ProtectSystem=strict
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=__APP__
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectHome=yes
ProtectSystem=full
ProtectControlGroups=yes
ProtectKernelModules=yes
# to allow this systemd service to use sendmail.
@ -26,9 +30,6 @@ ProtectKernelModules=yes
SupplementaryGroups=postdrop
ReadWritePaths=__FINALPATH__/config.ini __FINALPATH__/data/ /var/spool/postfix/maildrop/
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=__APP__
[Install]
WantedBy=multi-user.target

View file

@ -6,7 +6,7 @@
"en": "Personal finance manager",
"fr": "Outil personnel de gestion de finances"
},
"version": "0.18.1~ynh1",
"version": "0.18.1~ynh2",
"url": "https://framagit.org/kresusapp/kresus",
"upstream": {
"license": "free",

View file

@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors

View file

@ -29,6 +29,8 @@ architecture=$YNH_ARCH
app=$YNH_APP_INSTANCE_NAME
salt=$(ynh_string_random --length=40)
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
@ -53,6 +55,7 @@ ynh_script_progression --message="Storing installation settings..."
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
#=================================================
# STANDARD MODIFICATIONS
@ -61,12 +64,10 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
#=================================================
ynh_script_progression --message="Finding an available port..."
# Find an available port
port=$(ynh_find_port --port=9876)
ynh_app_setting_set --app=$app --key=port --value=$port
salt=$(ynh_string_random --length=40)
ynh_app_setting_set --app=$app --key=salt --value=$salt
#=================================================
# INSTALL DEPENDENCIES
#=================================================
@ -104,7 +105,7 @@ 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"
mkdir "$final_path/data"
mkdir -p "$final_path/data"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
@ -134,6 +135,7 @@ virtualenv --python=python3 --system-site-packages "${final_path}/venv"
pip install --upgrade pip
pip install woob html2text simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six --ignore-installed
)
chown -R $app:www-data "$final_path"
#=================================================
# INTSALL KRESUS WITH NPM
@ -143,10 +145,9 @@ ynh_script_progression --message="Installing app..."
ynh_use_nodejs
(
cd "$final_path"
chown -R "$app": "$final_path"
ynh_exec_warn_less $ynh_npm install --production --unsafe-perm
)
chown -R $app:www-data "$final_path"
#=================================================
# ADD A CONFIGURATION

View file

@ -81,8 +81,8 @@ ynh_remove_nginx_config
ynh_script_progression --message="Removing dependencies..."
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE

View file

@ -14,6 +14,9 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -29,7 +32,6 @@ 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
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
salt=$(ynh_app_setting_get --app=$app --key=salt)
#=================================================
@ -49,13 +51,6 @@ test ! -d $final_path \
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
@ -89,15 +84,21 @@ ynh_script_progression --message="Reinstalling dependencies..."
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..."
ynh_psql_test_if_first_run
ynh_print_OFF
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_print_ON
ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name
#=================================================

View file

@ -40,6 +40,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
@ -117,14 +118,6 @@ 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
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
@ -142,6 +135,14 @@ then
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#=================================================
@ -159,6 +160,7 @@ virtualenv --python=python3 --system-site-packages "${final_path}/venv"
pip install --upgrade pip
pip install woob html2text simplejson BeautifulSoup4 PyExecJS typing-extensions pdfminer.six --ignore-installed
)
chown -R $app:www-data "$final_path"
#=================================================
# INSTALL KRESUS WITH NPM
@ -168,7 +170,6 @@ ynh_script_progression --message="Installing app..."
ynh_use_nodejs
(
cd "$final_path"
chown -R $app: "$final_path"
# 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.
@ -176,6 +177,7 @@ ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install --production --unsafe-perm
)
chown -R $app:www-data "$final_path"
#=================================================
# UPDATE A CONFIG FILE