From ada2aa88f03ff03a8509901f45e35d50860240f0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 28 Feb 2021 12:24:08 +0100 Subject: [PATCH 1/4] apply last example --- scripts/install | 32 +++++++------------------------- scripts/restore | 15 +++++++-------- scripts/upgrade | 32 +++++++------------------------- 3 files changed, 21 insertions(+), 58 deletions(-) diff --git a/scripts/install b/scripts/install index f8bd3ec..a65c2cc 100644 --- a/scripts/install +++ b/scripts/install @@ -129,7 +129,7 @@ pushd "$final_path"/build popd # Install bitwarden_rs -cp -a "$final_path"/build/target/release/bitwarden_rs "$final_path"/live/bitwarden_rs +cp -a "$final_path/build/target/release/bitwarden_rs" "$final_path/live/bitwarden_rs" # Remove build files and rustup ynh_secure_remove --file="$final_path/build" @@ -152,24 +152,7 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Modifying a config file..." -config="$final_path/live/bitwarden_rs.env" - -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" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$config" +ynh_add_config --template="../conf/bitwarden_rs.env" --destination="$final_path/live/bitwarden_rs.env" #================================================= # GENERIC FINALIZATION @@ -218,11 +201,13 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Usern #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring permissions..." # Make app public if necessary if [ $is_public -eq 1 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi @@ -241,12 +226,9 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Sending a readme for the admin..." -ynh_replace_string --match_string="__ADMIN_MAIL__" --replace_string="$admin_mail" --target_file="../conf/message" -ynh_replace_string --match_string="__ADMIN_TOKEN__" --replace_string="$admin_token" --target_file="../conf/message" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message" -ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message" +ynh_add_config --template="../conf/message" --destination="../conf/msg_install" -ynh_send_readme_to_admin --app_message="../conf/message" --recipients="$admin_mail" --type='install' +ynh_send_readme_to_admin --app_message="../conf/msg_install" --recipients="$admin_mail" --type='install' #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 0aa9900..ea4ea2d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -99,14 +99,6 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # RESTORE SYSTEMD #================================================= @@ -129,6 +121,13 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Rocket has launched from" --length=100 +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index d52d04d..cd8e7d1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -44,15 +44,16 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +if ! ynh_permission_exists --permission="admin"; then + # Create the required permissions + ynh_permission_create --permission="admin" --url="/admin" --allowed="$admin" --show_tile="false" +fi + # Create a permission if needed if ! ynh_permission_exists --permission="api"; then ynh_permission_create --permission="api" --url="/api" --additional_urls="/identity/connect/token" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" fi -if ! ynh_permission_exists --permission="admin"; then - ynh_permission_create --permission="admin" --url="/admin" --allowed="$admin" --show_tile="false" -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -149,7 +150,7 @@ then ynh_secure_remove --file="$final_path/live/bitwarden_rs.d" # Install bitwarden_rs - cp -af "$final_path"/build/target/release/bitwarden_rs "$final_path"/live/bitwarden_rs + cp -af "$final_path/build/target/release/bitwarden_rs" "$final_path/live/bitwarden_rs" # Remove build files and rustup ynh_secure_remove --file="$final_path/build" @@ -170,26 +171,7 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Modifying a config file..." -config="$final_path/live/bitwarden_rs.env" - -ynh_backup_if_checksum_is_different --file="$config" - -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" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$config" +ynh_add_config --template="../conf/bitwarden_rs.env" --destination="$final_path/live/bitwarden_rs.env" #================================================= # GENERIC FINALIZATION From 2fb1244880bcf90e73fd386a930b2a61cc9c94b6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 28 Feb 2021 12:25:55 +0100 Subject: [PATCH 2/4] Update check_process --- check_process | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/check_process b/check_process index 24ed91a..ec673b0 100644 --- a/check_process +++ b/check_process @@ -31,6 +31,8 @@ upgrade=1 from_commit=e2e958b1885f7a08e0d5afe5dada5c0dd44dd671 # 1.16.3~ynh3 upgrade=1 from_commit=df2a0510288c352cfc03886763149f49839ed620 + # 1.19.0~ynh1 + upgrade=1 from_commit=980f625ab1eb3136437ff6275bec7990c534282c backup_restore=1 multi_instance=1 port_already_use=0 @@ -53,3 +55,5 @@ Notification=all name=1.16.3~ynh2 ; commit=df2a0510288c352cfc03886763149f49839ed620 name=1.16.3~ynh3 + ; commit=980f625ab1eb3136437ff6275bec7990c534282c + name=1.19.0~ynh1 From e143c7d04f7fca10de4a46a24ea6c9e53200aeb5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 1 Mar 2021 22:21:45 +0100 Subject: [PATCH 3/4] YunoHost 4.2 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index e617a5d..6f13e86 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "name": "yalh76" }, "requirements": { - "yunohost": ">= 4.1.3" + "yunohost": ">= 4.2" }, "multi_instance": true, "services": [ From e9aac2408391dec728356946d5eec976cf97c2dd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Mar 2021 08:14:54 +0100 Subject: [PATCH 4/4] YunoHost 4.1.7.3 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 6f13e86..259c7b3 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "name": "yalh76" }, "requirements": { - "yunohost": ">= 4.2" + "yunohost": ">= 4.1.7.3" }, "multi_instance": true, "services": [