From bd4aabe055020454a5a4277f34521fe1e79ae35e Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 21 Sep 2020 09:02:06 +0200 Subject: [PATCH 1/3] cleaning up --- scripts/backup | 20 ++------------------ scripts/change_url | 16 ++++++++-------- scripts/install | 10 +++++----- scripts/remove | 8 ++++---- scripts/restore | 6 +++--- scripts/upgrade | 10 +++++----- 6 files changed, 27 insertions(+), 43 deletions(-) diff --git a/scripts/backup b/scripts/backup index b4aff41..0b5d5af 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -32,32 +31,25 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Stopping a systemd service..." - -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Bitwarden Server" +ynh_print_info --message="Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info --message="Backing up the main app directory..." ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Backing up nginx web server configuration..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= -ynh_print_info --message="Backing up fail2ban configuration..." ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" @@ -67,7 +59,6 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" #================================================= # BACKUP LOGROTATE #================================================= -ynh_print_info --message="Backing up logrotate configuration..." ynh_backup --src_path="/etc/logrotate.d/$app" @@ -78,13 +69,6 @@ ynh_print_info --message="Backing up systemd configuration..." ynh_backup --src_path="/etc/systemd/system/$app.service" -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Rocket has launched from" --length=100 - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 2705f2f..f903d5a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -40,7 +40,7 @@ websocket_port=$(ynh_app_setting_get --app=$app --key=websocket_port) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before changing its url (may take a while)..." +ynh_print_info --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -82,23 +82,23 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --li #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info --message="Updating nginx web server configuration..." +ynh_print_info --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# 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 + # 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 + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config "websocket_port rocket_port" fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -136,7 +136,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_print_info --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 4cac41e..8ca301e 100644 --- a/scripts/install +++ b/scripts/install @@ -96,9 +96,9 @@ ynh_setup_source --dest_dir="$final_path/live/web-vault/" --source_id="web" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Configuring nginx web server..." +ynh_print_info --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config "websocket_port rocket_port" #================================================= @@ -209,9 +209,9 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # SETUP FAIL2BAN #================================================= -ynh_print_info --message="Configuring fail2ban..." +ynh_print_info --message="Configuring Fail2Ban..." -# Create a dedicated fail2ban config +# Create a dedicated Fail2Ban config touch /var/log/"$app"/"$app".log ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Username or password is incorrect\. Try again\. IP: \. Username:.*$" @@ -230,7 +230,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_print_info --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index aef4bb4..293ea59 100644 --- a/scripts/remove +++ b/scripts/remove @@ -60,9 +60,9 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Removing nginx web server configuration..." +ynh_print_info --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= @@ -76,9 +76,9 @@ ynh_remove_logrotate #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= -ynh_print_info --message="Removing fail2ban configuration..." +ynh_print_info --message="Removing Fail2Ban configuration..." -# Remove the dedicated fail2ban config +# Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config #================================================= diff --git a/scripts/restore b/scripts/restore index 2bb3d30..395dc27 100644 --- a/scripts/restore +++ b/scripts/restore @@ -78,9 +78,9 @@ chown -R "$app":"$app" /var/log/"$app" #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= -ynh_print_info --message="Restoring the fail2ban configuration..." +ynh_print_info --message="Restoring the Fail2Ban configuration..." -# Create a dedicated fail2ban config +# Create a dedicated Fail2Ban config mkdir -p "/var/log/$app" chown -R "$app":"$app" "/var/log/$app" touch /var/log/"$app"/"$app".log @@ -133,7 +133,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_print_info --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 64fd78b..6bf87c8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -95,9 +95,9 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Upgrading nginx web server configuration..." +ynh_print_info --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config "websocket_port rocket_port" #================================================= @@ -200,9 +200,9 @@ ynh_add_systemd_config #================================================= # UPGRADE FAIL2BAN #================================================= -ynh_print_info --message="Reconfiguring fail2ban..." +ynh_print_info --message="Reconfiguring Fail2Ban..." -# Create a dedicated fail2ban config +# Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Username or password is incorrect\. Try again\. IP: \. Username:.*$" #================================================= @@ -237,7 +237,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading nginx web server..." +ynh_print_info --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload From 214463d95b73d79b77775717f24c14b128196642 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 1 Dec 2020 22:04:05 +0100 Subject: [PATCH 2/3] Apply last example_ynh --- README.md | 16 +++--- README_fr.md | 8 +-- check_process | 12 ++-- conf/app.src | 1 + conf/systemd.service | 2 +- conf/web.src | 1 + issue_template.md | 55 +++++++++++++++++++ manifest.json | 2 +- scripts/backup | 1 - scripts/change_url | 18 +++--- scripts/install | 46 ++++++++-------- scripts/remove | 24 ++++---- scripts/restore | 41 +++++++------- scripts/upgrade | 127 +++++++++++++++++++------------------------ 14 files changed, 198 insertions(+), 156 deletions(-) create mode 100644 issue_template.md diff --git a/README.md b/README.md index b18ac46..93fef86 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,10 @@ *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install Bitwarden quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install Bitwarden quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview - Bitwarden is a open source password manager. **Shipped version:** 1.16.3 @@ -36,7 +35,7 @@ How to configure this app: by an admin panel at https://bitwarden.domain.tld/adm ## YunoHost specific features -#### Multi-users support +#### Multi-user support * Are LDAP and HTTP auth supported? **No** * Can the app be used by multiple users? **Yes** @@ -55,14 +54,13 @@ How to configure this app: by an admin panel at https://bitwarden.domain.tld/adm --- -Developers info ----------------- +## Developer info -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/bitwarden_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/bitwarden_ynh/tree/testing). To try the testing branch, please proceed like that. ``` -sudo yunohost app install --debug https://github.com/YunoHost-Apps/bitwarden_ynh/tree/testing +sudo yunohost app install https://github.com/YunoHost-Apps/bitwarden_ynh/tree/testing --debug or -sudo yunohost app upgrade --debug bitwarden -u https://github.com/YunoHost-Apps/bitwarden_ynh/tree/testing +sudo yunohost app upgrade bitwarden -u https://github.com/YunoHost-Apps/bitwarden_ynh/tree/testing --debug ``` diff --git a/README_fr.md b/README_fr.md index 01a1a3d..0141049 100644 --- a/README_fr.md +++ b/README_fr.md @@ -6,10 +6,9 @@ *[Read this readme in english.](./README.md)* > *Ce package vous permet d'installer Bitwarden rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble - Bitwarden est un gestionnaire de mots de passe open source. **Version incluse :** 1.16.3 @@ -36,7 +35,7 @@ Comment configurer cette application : via le panneau d'administration https://b ## Caractéristiques spécifiques YunoHost -#### Support multi-utilisateurs +#### Support multi-utilisateur * L'authentification LDAP et HTTP est-elle prise en charge? **Non** * L'application peut-elle être utilisée par plusieurs utilisateurs ? **Oui** @@ -55,8 +54,7 @@ Comment configurer cette application : via le panneau d'administration https://b --- -Informations pour les développeurs ----------------- +## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/bitwarden_ynh/tree/testing). diff --git a/check_process b/check_process index e8b99bf..78433bc 100644 --- a/check_process +++ b/check_process @@ -11,20 +11,22 @@ is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 - setup_sub_dir=0 + setup_sub_dir=1 setup_root=1 setup_nourl=0 setup_private=1 setup_public=1 upgrade=1 # 1.9.1~ynh3 - upgrade=1 from_commit=501bf18eafcda987ac255d12ca213d15e63c5eef + #upgrade=1 from_commit=501bf18eafcda987ac255d12ca213d15e63c5eef # 1.14.2~ynh2 - upgrade=1 from_commit=2a7b9d6b6705be6e3a7217309a77b9def226eaa6 + #upgrade=1 from_commit=2a7b9d6b6705be6e3a7217309a77b9def226eaa6 # 1.15.1~ynh2 - upgrade=1 from_commit=bb9dac9cc50e11d8ef60033a543f9e21b42d0d8e + #upgrade=1 from_commit=bb9dac9cc50e11d8ef60033a543f9e21b42d0d8e # 1.16.1~ynh2 upgrade=1 from_commit=5572d0420cf500fdb313c15b4ab40e7a6c38e294 + # 1.16.3~ynh1 + upgrade=1 from_commit=576a173a43de914253645daa2c0b066f693a20f7 backup_restore=1 multi_instance=1 # 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. @@ -46,3 +48,5 @@ Notification=all name=1.15.1~ynh2 ; commit=5572d0420cf500fdb313c15b4ab40e7a6c38e294 name=1.16.1~ynh2 + ; commit=576a173a43de914253645daa2c0b066f693a20f7 + name=1.16.3~ynh1 diff --git a/conf/app.src b/conf/app.src index 6f57d9a..71b40fa 100644 --- a/conf/app.src +++ b/conf/app.src @@ -4,3 +4,4 @@ SOURCE_SUM_PRG=sha512sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 1213d78..7cf5e99 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -24,4 +24,4 @@ WorkingDirectory=__FINALPATH__/live/ ReadWriteDirectories=__FINALPATH__/live/ [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/conf/web.src b/conf/web.src index 4be84ba..a45e9bf 100644 --- a/conf/web.src +++ b/conf/web.src @@ -4,3 +4,4 @@ SOURCE_SUM_PRG=sha512sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..aa9b193 --- /dev/null +++ b/issue_template.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to Bitwarden itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install bitwarden + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/manifest.json b/manifest.json index c9cd553..fc4a2b5 100644 --- a/manifest.json +++ b/manifest.json @@ -45,7 +45,7 @@ "type": "user", "ask": { "en": "Choose an admin user", - "fr": "Choisissez l’administrateur" + "fr": "Choisissez l'administrateur" }, "example": "johndoe" }, diff --git a/scripts/backup b/scripts/backup index 0b5d5af..cb104bf 100644 --- a/scripts/backup +++ b/scripts/backup @@ -65,7 +65,6 @@ ynh_backup --src_path="/etc/logrotate.d/$app" #================================================= # BACKUP SYSTEMD #================================================= -ynh_print_info --message="Backing up systemd configuration..." ynh_backup --src_path="/etc/systemd/system/$app.service" diff --git a/scripts/change_url b/scripts/change_url index f903d5a..e63ec90 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,7 +12,6 @@ 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 @@ -25,7 +24,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) @@ -40,7 +39,7 @@ websocket_port=$(ynh_app_setting_get --app=$app --key=websocket_port) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before changing its URL (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -75,14 +74,14 @@ fi #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Bitwarden Server" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info --message="Updating NGINX web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -113,7 +112,7 @@ fi #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info --message="Modifying a config file..." +ynh_script_progression --message="Modifying a config file..." config="$final_path/live/bitwarden_rs.env" @@ -129,14 +128,15 @@ ynh_store_file_checksum --file="$config" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Rocket has launched from" --length=100 #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -144,4 +144,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Change of URL completed for $app" +ynh_script_progression --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 8ca301e..f80adcd 100644 --- a/scripts/install +++ b/scripts/install @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -24,7 +23,6 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH @@ -39,7 +37,7 @@ admin_token=$(ynh_string_random --length=48 | base64) #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info --message="Validating installation parameters..." +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -50,7 +48,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info --message="Storing installation settings..." +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 @@ -63,7 +61,7 @@ ynh_app_setting_set --app=$app --key=admin_token --value=$admin_token #================================================= # FIND AND OPEN A PORT #================================================= -ynh_print_info --message="Configuring firewall..." +ynh_script_progression --message="Configuring firewall..." # Find an available port websocket_port=$(ynh_find_port --port=3012) @@ -76,14 +74,14 @@ ynh_app_setting_set --app=$app --key=rocket_port --value="$rocket_port" #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Installing dependencies..." +ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path @@ -96,7 +94,7 @@ ynh_setup_source --dest_dir="$final_path/live/web-vault/" --source_id="web" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Configuring NGINX web server..." +ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config "websocket_port rocket_port" @@ -104,7 +102,7 @@ ynh_add_nginx_config "websocket_port rocket_port" #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Configuring system user..." +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username="$app" --home_dir="$final_path" @@ -114,21 +112,21 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" #================================================= # MAKE INSTALL #================================================= -ynh_print_info --message="Making install..." +ynh_script_progression --message="Making install..." # Set right permissions chown -R "$app":"$app" "$final_path" # Install rustup with the toolchain needed by bitwarden_rs pushd "$final_path" - sudo -u "$app" RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=$(cat build/rust-toolchain)' + sudo -u "$app" RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=$(cat build/rust-toolchain)' popd export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" # Compile bitwarden_rs pushd "$final_path"/build - sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release + sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release popd # Install bitwarden_rs @@ -142,7 +140,7 @@ ynh_secure_remove --file="$final_path/.rustup" #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config @@ -150,7 +148,7 @@ ynh_add_systemd_config #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info --message="Modifying a config file..." +ynh_script_progression --message="Modifying a config file..." config="$final_path/live/bitwarden_rs.env" @@ -166,7 +164,7 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_print_info --message="Storing 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" @@ -176,7 +174,7 @@ ynh_store_file_checksum --file="$config" #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_print_info --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R "$app":"$app" "$final_path" @@ -186,7 +184,7 @@ chown -R "$app":"$app" "/var/log/$app" #================================================= # SETUP LOGROTATE #================================================= -ynh_print_info --message="Configuring log rotation..." +ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -194,14 +192,14 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "$app daemon for Bitwarden" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Rocket has launched from" --length=100 @@ -209,7 +207,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= # SETUP FAIL2BAN #================================================= -ynh_print_info --message="Configuring Fail2Ban..." +ynh_script_progression --message="Configuring Fail2Ban..." # Create a dedicated Fail2Ban config touch /var/log/"$app"/"$app".log @@ -218,7 +216,7 @@ ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Usern #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -230,14 +228,14 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload #================================================= # SEND A README FOR THE ADMIN #================================================= -ynh_print_info --message="Sending a readme for the admin..." +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" @@ -250,4 +248,4 @@ ynh_send_readme_to_admin --app_message="../conf/message" --recipients="$admin_ma # END OF SCRIPT #================================================= -ynh_print_info --message="Installation of $app completed" +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 293ea59..50ef568 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -24,19 +24,18 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_print_info --message="Removing service integration in YunoHost..." # 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 then - ynh_print_info --message="Removing $app service..." + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info --message="Stopping and removing the systemd service..." +ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config @@ -44,7 +43,7 @@ ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_print_info --message="Removing dependencies..." +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -52,7 +51,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info --message="Removing app main directory..." +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -60,7 +59,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info --message="Removing NGINX web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -68,7 +67,7 @@ ynh_remove_nginx_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_print_info --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -76,7 +75,7 @@ ynh_remove_logrotate #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= -ynh_print_info --message="Removing Fail2Ban configuration..." +ynh_script_progression --message="Removing Fail2Ban configuration..." # Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config @@ -84,8 +83,9 @@ ynh_remove_fail2ban_config #================================================= # SPECIFIC REMOVE #================================================= -# REMOVE THE LOG FILE +# REMOVE VARIOUS FILES #================================================= +ynh_script_progression --message="Removing various files..." # Remove the log files ynh_secure_remove --file="/var/log/$app" @@ -95,7 +95,7 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info --message="Removing the dedicated system user..." +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=$app @@ -104,4 +104,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_print_info --message="Removal of $app completed" +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 395dc27..0aa9900 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -24,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading settings..." +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -35,7 +34,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info --message="Validating restoration parameters..." +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -47,20 +46,21 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info --message="Recreating the dedicated system user..." +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -68,7 +68,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # RESTORE USER RIGHTS #================================================= -ynh_print_info --message="Restoring user rights..." +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R "$app":"$app" "$final_path" @@ -78,7 +78,7 @@ chown -R "$app":"$app" /var/log/"$app" #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= -ynh_print_info --message="Restoring the Fail2Ban configuration..." +ynh_script_progression --message="Restoring the Fail2Ban configuration..." # Create a dedicated Fail2Ban config mkdir -p "/var/log/$app" @@ -94,46 +94,47 @@ ynh_systemd_action --action=restart --service_name=fail2ban #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_print_info --message="Reinstalling dependencies..." +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 #================================================= -ynh_print_info --message="Restoring the systemd configuration..." +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service +systemctl enable $app.service --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_print_info --message="Integrating service in YunoHost..." +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add $app --description "$app daemon for Bitwarden" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_print_info --message="Starting a systemd service..." +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_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -141,4 +142,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Restoration completed for $app" +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 6bf87c8..0ffc03e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -29,33 +29,14 @@ websocket_port=$(ynh_app_setting_get --app=$app --key=websocket_port) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_print_info --message="Ensuring downward compatibility..." - -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi - -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_print_info --message="Backing up the app before upgrading (may take a while)..." +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -72,18 +53,17 @@ ynh_abort_if_errors #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_print_info --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped Bitwarden Server" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info --message="Upgrading source files..." if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_print_info --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." # Download, check integrity, uncompress the source of bitwarden_rs from app.src to his build directory ynh_setup_source --dest_dir="$final_path/build/" --source_id="app" @@ -95,7 +75,7 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info --message="Upgrading NGINX web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config "websocket_port rocket_port" @@ -103,14 +83,14 @@ ynh_add_nginx_config "websocket_port rocket_port" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_print_info --message="Upgrading dependencies..." +ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info --message="Making sure dedicated system user exists..." +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" @@ -120,7 +100,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # MAKE UPGRADE #================================================= -ynh_print_info --message="Making upgrade..." +ynh_script_progression --message="Making upgrade..." # Set right permissions chown -R "$app":"$app" "$final_path" @@ -129,17 +109,17 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then # Install rustup with the toolchain needed by bitwarden_rs pushd "$final_path" - sudo -u "$app" RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=$(cat build/rust-toolchain)' + sudo -u "$app" RUSTUP_HOME="$final_path"/.rustup CARGO_HOME="$final_path"/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=$(cat build/rust-toolchain)' popd export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" # Compile bitwarden_rs pushd "$final_path"/build - sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release + sudo -u "$app" env PATH="$PATH" cargo build --features sqlite --release popd - # Remove old generated files before copying the new ones + # Remove old generated files before copying the new ones ynh_secure_remove --file="$final_path/live/build" ynh_secure_remove --file="$final_path/live/deps" ynh_secure_remove --file="$final_path/live/.fingerprint" @@ -147,16 +127,24 @@ then # Install bitwarden_rs cp -af "$final_path"/build/target/release/. "$final_path"/live/. - # Remove build files and rustup + # Remove build files and rustup ynh_secure_remove --file="$final_path/build" ynh_secure_remove --file="$final_path/.cargo" ynh_secure_remove --file="$final_path/.rustup" fi +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info --message="Modifying a config file..." +ynh_script_progression --message="Modifying a config file..." config="$final_path/live/bitwarden_rs.env" @@ -174,51 +162,57 @@ ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_fil #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_print_info --message="Storing 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" -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_print_info --message="Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_print_info --message="Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # GENERIC FINALIZATION -#================================================= -# UPGRADE FAIL2BAN -#================================================= -ynh_print_info --message="Reconfiguring Fail2Ban..." - -# Create a dedicated Fail2Ban config -ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Username or password is incorrect\. Try again\. IP: \. Username:.*$" - #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_print_info --message="Securing files and directories..." +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R "$app":"$app" "$final_path" mkdir -p "/var/log/$app" chown -R "$app":"$app" /var/log/"$app" +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." + +# 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..." + +yunohost service add $app --description "$app daemon for Bitwarden" --log "/var/log/$app/$app.log" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +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 + +#================================================= +# UPGRADE FAIL2BAN +#================================================= +ynh_script_progression --message="Reconfiguring Fail2Ban..." + +# Create a dedicated Fail2Ban config +ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Username or password is incorrect\. Try again\. IP: \. Username:.*$" + #================================================= # SETUP SSOWAT #================================================= -ynh_print_info --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -227,17 +221,10 @@ then ynh_app_setting_set --app=$app --key=skipped_uris --value="/" fi -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_print_info --message="Starting a systemd service..." - -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Rocket has launched from" --length=100 - #================================================= # RELOAD NGINX #================================================= -ynh_print_info --message="Reloading NGINX web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -245,4 +232,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_print_info --message="Upgrade of $app completed" +ynh_script_progression --message="Upgrade of $app completed" From b8d5033020d94ff691e224e8c2078c9d22606edf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 8 Dec 2020 22:00:40 +0100 Subject: [PATCH 3/3] Upgrade version number --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index fc4a2b5..ec7163d 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Manage passwords and other sensitive informations", "fr": "Gérez les mots de passe et autres informations sensibles" }, - "version": "1.16.3~ynh1", + "version": "1.16.3~ynh2", "url": "https://github.com/dani-garcia/bitwarden_rs", "license": "GPL-3.0-or-later", "maintainer": {