From 206f25cc0b7436c3c43f367f031efdf21bb3445b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 21 Mar 2020 14:04:37 +0100 Subject: [PATCH] enable path_url --- check_process | 2 +- conf/bitwarden_rs.env | 2 +- manifest.json | 10 ++++++++++ scripts/change_url | 13 ++++++++++++- scripts/install | 3 ++- scripts/upgrade | 1 + 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/check_process b/check_process index e511988..234cd7d 100644 --- a/check_process +++ b/check_process @@ -22,7 +22,7 @@ # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. # incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto diff --git a/conf/bitwarden_rs.env b/conf/bitwarden_rs.env index 6d90dae..9c74ffa 100644 --- a/conf/bitwarden_rs.env +++ b/conf/bitwarden_rs.env @@ -138,7 +138,7 @@ ADMIN_TOKEN=__ADMIN_TOKEN__ ## It's recommended to configure this value, otherwise certain functionality might not work, ## like attachment downloads, email links and U2F. ## For U2F to work, the server must use HTTPS, you can use Let's Encrypt for free certs -DOMAIN=https://__DOMAIN__ +DOMAIN=https://__DOMAIN____PATH_URL__ ## Yubico (Yubikey) Settings ## Set your Client ID and Secret Key for Yubikey OTP diff --git a/manifest.json b/manifest.json index 6130c58..7eef607 100644 --- a/manifest.json +++ b/manifest.json @@ -30,6 +30,16 @@ }, "example": "example.com" }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Bitwarden", + "fr": "Choisissez un chemin pour Bitwarden" + }, + "example": "/bitwarden", + "default": "/bitwarden" + }, { "name": "admin", "type": "user", diff --git a/scripts/change_url b/scripts/change_url index afdc363..aee7425 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_print_info --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -108,8 +109,18 @@ fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -# ... +# MODIFY A CONFIG FILE #================================================= +ynh_print_info --message="Modifying a config file..." + +config="$final_path/live/bitwarden_rs.env" + +ynh_backup_if_checksum_is_different --file="$config" + +ynh_replace_string --match_string="DOMAIN=https://$old_domain$old_path" --replace_string="DOMAIN=https://$new_domain$new_path" --target_file="$config" + +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$config" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 348549f..189bcb8 100644 --- a/scripts/install +++ b/scripts/install @@ -27,7 +27,7 @@ ynh_abort_if_errors ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN -path_url="/" +path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC @@ -158,6 +158,7 @@ cp -f ../conf/bitwarden_rs.env "$config" ynh_replace_string --match_string="__ADMIN_TOKEN__" --replace_string="$admin_token" --target_file="$config" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$config" ynh_replace_string --match_string="__WEBSOCKET_PORT__" --replace_string="$websocket_port" --target_file="$config" ynh_replace_string --match_string="__ROCKET_PORT__" --replace_string="$rocket_port" --target_file="$config" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$config" diff --git a/scripts/upgrade b/scripts/upgrade index fb45c31..3f3b6fa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -161,6 +161,7 @@ cp -f ../conf/bitwarden_rs.env "$config" ynh_replace_string --match_string="__ADMIN_TOKEN__" --replace_string="$admin_token" --target_file="$config" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="$config" ynh_replace_string --match_string="__WEBSOCKET_PORT__" --replace_string="$websocket_port" --target_file="$config" ynh_replace_string --match_string="__ROCKET_PORT__" --replace_string="$rocket_port" --target_file="$config" ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$config"