From 646f30167de5e51110d3ac35f89dd1a796954bab Mon Sep 17 00:00:00 2001 From: nicofrand Date: Sun, 24 Feb 2019 19:32:07 +0100 Subject: [PATCH 1/3] Upgrade Kresus to 0.14.0 --- README.md | 5 +++-- conf/app.src | 4 ++-- conf/config.ini | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 549e0fc..be6e0f9 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Kresus for YunoHost -[![Integration level](https://dash.yunohost.org/integration/kresus.svg)](https://dash.yunohost.org/appci/app/kresus) +[![Integration level](https://dash.yunohost.org/integration/kresus.svg)](https://dash.yunohost.org/appci/app/kresus) [![Install Kresus with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=kresus) 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 on what you are spending money with the use of tags! -**Shipped version:** 0.13.2 +**Shipped version:** 0.14.0 # State of this package @@ -20,6 +20,7 @@ Kresus is an open-source libre self-hosted personal finance manager. It allows y * [ ] 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) + * [ ] Generate a salt for the config file ## Links diff --git a/conf/app.src b/conf/app.src index e13638d..4a2a2a2 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://framagit.org/kresusapp/kresus/-/archive/0.13.3/kresus-0.13.3.tar.bz2 -SOURCE_SUM=b1c4af2cab68dc0c02dcc625be416c1fa59105b1cbd3ec3cd93244296e047f68 +SOURCE_URL=https://framagit.org/kresusapp/kresus/-/archive/0.14.0/kresus-0.14.0.tar.bz2 +SOURCE_SUM=741a996db2b121e360c0dcf72633d56d010fca22dbf230a99a8be91be3a642bc SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 SOURCE_IN_SUBDIR=true diff --git a/conf/config.ini b/conf/config.ini index 85595f3..e35504a 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -41,6 +41,14 @@ url_prefix=__PATH__ ; python_exec=python3 python_exec=__FINALPATH__/venv/bin/python +; A salt value used in encryption algorithms (used for instance to +; encrypt/decrypt exports). It should be a random string value with +; at least 16 characters if you decide to provide it. +; Overriden by the KRESUS_SALT environment variable, if it's set. +; Example: +; salt=gj4J89fkjf4h29aDi0f{}fu4389sejk`9osk` +salt= + [weboob] ; The directory in which Weboob core is stored. ; Can be removed; defaults to "", indicating that weboob is already in the From 1d033cb1bfeeee9d66b111302b2a8cf5f5ae5bed Mon Sep 17 00:00:00 2001 From: nicofrand Date: Wed, 27 Feb 2019 13:39:34 +0100 Subject: [PATCH 2/3] Post-review upgrade fix --- check_process | 8 ++++++-- scripts/upgrade | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/check_process b/check_process index 283091a..26289ea 100644 --- a/check_process +++ b/check_process @@ -14,7 +14,7 @@ setup_nourl=0 setup_private=1 setup_public=0 - upgrade=1 + upgrade=1 from_commit=c455d5def074eb4012e9c1d07e8e2abba38a3aa9 backup_restore=1 multi_instance=1 incorrect_path=1 @@ -35,4 +35,8 @@ Level 10=0 ;;; Options Email=jean-baptiste@holcroft.fr -Notification=all \ No newline at end of file +Notification=all +;;; Upgrade options + ; commit=c455d5def074eb4012e9c1d07e8e2abba38a3aa9 + name=Upgrade from 0.13 +manifest_arg=domain=DOMAIN&path=/ \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 4fba93e..6b8e65f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -171,7 +171,12 @@ chmod -R 750 "$final_path/data/" # Set permissions to config files chown "$app" "$final_path/config.ini" -chmod 600 "$final_path/config.ini" "$final_path/data/weboob-data/backends" +chmod 600 "$final_path/config.ini" + +if [ -f "$final_path/data/weboob-data/backends" ] +then + chmod 600 "$final_path/data/weboob-data/backends" +fi #================================================= # RELOAD NGINX From 34c977fb8d894a78c4bec448a4cab32a2d0a4862 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Wed, 27 Feb 2019 22:56:36 +0100 Subject: [PATCH 3/3] add salt support + fix shellcheck --- README.md | 1 - conf/config.ini | 2 +- scripts/install | 8 ++++++-- scripts/restore | 10 +++++----- scripts/upgrade | 25 ++++++++++++++++--------- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index be6e0f9..c358c83 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Kresus is an open-source libre self-hosted personal finance manager. It allows y * [ ] 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) - * [ ] Generate a salt for the config file ## Links diff --git a/conf/config.ini b/conf/config.ini index e35504a..5f7eb51 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -47,7 +47,7 @@ python_exec=__FINALPATH__/venv/bin/python ; Overriden by the KRESUS_SALT environment variable, if it's set. ; Example: ; salt=gj4J89fkjf4h29aDi0f{}fu4389sejk`9osk` -salt= +salt=__SALT__ [weboob] ; The directory in which Weboob core is stored. diff --git a/scripts/install b/scripts/install index 57b01c4..e2a1370 100644 --- a/scripts/install +++ b/scripts/install @@ -24,6 +24,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH port=$(ynh_find_port 9876) +salt=$(ynh_string_random 40) app=$YNH_APP_INSTANCE_NAME @@ -49,6 +50,7 @@ ynh_webpath_register "$app" "$domain" "$path_url" ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set "$app" port "$port" +ynh_app_setting_set "$app" salt "$salt" #================================================= # STANDARD MODIFICATIONS @@ -119,7 +121,7 @@ virtualenv --system-site-packages "${final_path}/venv" ynh_use_nodejs ( cd "$final_path" - chown -R $app: "$final_path" + chown -R "$app": "$final_path" npm install --production --unsafe-perm ) @@ -132,6 +134,8 @@ cp ../conf/config.ini "$final_path/config.ini" ynh_replace_string "__PORT__" "$port" "$final_path/config.ini" ynh_replace_string "__PATH__" "$path_url" "$final_path/config.ini" ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/config.ini" +ynh_replace_string "__SALT__" "$salt" "$final_path/config.ini" + # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/config.ini" @@ -187,4 +191,4 @@ If you changed it manually and upgrade Kresus, you'll find a backup in $final_pa 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" +ynh_send_readme_to_admin "$message" \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index a15f904..4efe7d1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,9 +35,9 @@ final_path=$(ynh_app_setting_get "$app" final_path) # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_webpath_available $domain $path_url \ +ynh_webpath_available "$domain" "$path_url" \ || ynh_die "Path not available: ${domain}${path_url}" -test ! -d $final_path \ +test ! -d "$final_path" \ || ynh_die "There is already a directory: $final_path " #================================================= @@ -66,7 +66,7 @@ ynh_system_user_create "$app" #================================================= # Restore permissions on app files -chown -R $app: $final_path +chown -R "$app": "$final_path" chmod 600 "$final_path/config.ini" #================================================= @@ -90,13 +90,13 @@ ynh_install_nodejs 8 #================================================= ynh_restore_file "/etc/systemd/system/$app.service" -systemctl enable $app.service +systemctl enable "$app".service #================================================= # START HASTEBIN #================================================= -systemctl start $app +systemctl start "$app" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 6b8e65f..78dfe19 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,26 +18,32 @@ ynh_abort_if_errors app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -port=$(ynh_app_setting_get $app port) +domain=$(ynh_app_setting_get "$app" domain) +path_url=$(ynh_app_setting_get "$app" path) +final_path=$(ynh_app_setting_get "$app" final_path) +port=$(ynh_app_setting_get "$app" port) +salt=$(ynh_app_setting_get "$app" salt) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= # If final_path doesn't exist, create it -if [ -z $final_path ]; then +if [ -z "$final_path" ]; then final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path + ynh_app_setting_set "$app" final_path "$final_path" fi -if [ -z "/home/ynh$app" ]; then +if [ -d "/home/ynh$app" ]; then mv "/home/ynh$app/data" "$final_path/data" ynh_secure_remove "/home/ynh$app" fi +if [ -z "$salt" ]; then + salt=$(ynh_string_random 40) + ynh_app_setting_set "$app" salt "$salt" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -57,7 +63,7 @@ ynh_abort_if_errors #================================================= # Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) +path_url=$(ynh_normalize_url_path "$path_url") #================================================= # STANDARD UPGRADE STEPS @@ -126,7 +132,7 @@ virtualenv --system-site-packages "${final_path}/venv" ynh_use_nodejs ( cd "$final_path" - chown -R $app: "$final_path" + chown -R "$app": "$final_path" npm install --production --unsafe-perm ) @@ -141,6 +147,7 @@ cp ../conf/config.ini "$final_path/config.ini" ynh_replace_string "__PORT__" "$port" "$final_path/config.ini" ynh_replace_string "__PATH__" "$path_url" "$final_path/config.ini" ynh_replace_string "__FINALPATH__" "$final_path" "$final_path/config.ini" +ynh_replace_string "__SALT__" "$salt" "$final_path/config.ini" # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "$final_path/config.ini"