diff --git a/conf/vaultwarden.env b/conf/vaultwarden.env index 6f3225b..7a100a6 100644 --- a/conf/vaultwarden.env +++ b/conf/vaultwarden.env @@ -5,7 +5,7 @@ ## in the admin interface. Those overrides are stored within DATA_FOLDER/config.json . ## Main data folder -# DATA_FOLDER=data +DATA_FOLDER=__DATADIR__ ## Database URL ## When using SQLite, this is the path to the DB file, default to %DATA_FOLDER%/db.sqlite3 diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md new file mode 100644 index 0000000..ab63183 --- /dev/null +++ b/doc/DISCLAIMER.md @@ -0,0 +1,3 @@ +* Other infos that people should be aware of, such as: + * At the end of the installation, the admin user will receive a mail with the admin_token used to access https://your.domain.tld/vaultwarden/admin. + * How to configure this app: by an admin panel at https://vaultwarden.domain.tld/admin. diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/screenshots/screenshot1.png b/doc/screenshots/screenshot1.png new file mode 100644 index 0000000..9d80d59 Binary files /dev/null and b/doc/screenshots/screenshot1.png differ diff --git a/manifest.json b/manifest.json index ccc8aae..335859d 100644 --- a/manifest.json +++ b/manifest.json @@ -8,6 +8,14 @@ }, "version": "1.22.1~ynh1", "url": "https://github.com/dani-garcia/vaultwarden", + "upstream": { + "license": "GPL-3.0-or-later", + "website": "https://bitwarden.com/", + "demo": "https://vault.bitwarden.com/#/register", + "admindoc": "https://github.com/dani-garcia/vaultwarden/wiki", + "userdoc": "https://help.bitwarden.com/", + "code": "https://github.com/dani-garcia/vaultwarden" + }, "license": "GPL-3.0-or-later", "maintainer": { "name": "yalh76" diff --git a/scripts/backup b/scripts/backup index 79cfc6d..3bb4107 100644 --- a/scripts/backup +++ b/scripts/backup @@ -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 @@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP @@ -41,6 +42,12 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$final_path" +#================================================= +# BACKUP THE DATA DIR +#================================================= + +ynh_backup --src_path="$datadir" --is_big + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= diff --git a/scripts/change_url b/scripts/change_url index c592221..321dc16 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,6 +35,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) rocket_port=$(ynh_app_setting_get --app=$app --key=rocket_port) websocket_port=$(ynh_app_setting_get --app=$app --key=websocket_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP @@ -94,7 +95,7 @@ then domain="$old_domain" path_url="$new_path" # Create a dedicated NGINX config - ynh_add_nginx_config "websocket_port rocket_port" + ynh_add_nginx_config fi # Change the domain for NGINX diff --git a/scripts/install b/scripts/install index 2f98459..24f7220 100644 --- a/scripts/install +++ b/scripts/install @@ -64,11 +64,11 @@ ynh_script_progression --message="Finding an available port..." # Find an available port websocket_port=$(ynh_find_port --port=3012) -ynh_app_setting_set --app=$app --key=websocket_port --value="$websocket_port" +ynh_app_setting_set --app=$app --key=websocket_port --value=$websocket_port # Find an available port rocket_port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app=$app --key=rocket_port --value="$rocket_port" +ynh_app_setting_set --app=$app --key=rocket_port --value=$rocket_port #================================================= # INSTALL DEPENDENCIES @@ -83,7 +83,7 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -108,7 +108,7 @@ chown -R $app:$app "$final_path" ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config -ynh_add_nginx_config "websocket_port rocket_port" +ynh_add_nginx_config #================================================= # SPECIFIC SETUP @@ -137,12 +137,19 @@ ynh_secure_remove --file="$final_path/build" ynh_secure_remove --file="$final_path/.cargo" ynh_secure_remove --file="$final_path/.rustup" -# Create datadir -mkdir -p "$final_path/live/data" +#================================================= +# CREATE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Creating a data directory..." -chmod 750 "$final_path/live/data" -chmod -R o-rwx "$final_path/live/data" -chown -R $app:$app "$final_path/live/data" +datadir=/home/yunohost.app/$app +ynh_app_setting_set --app=$app --key=datadir --value=$datadir + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:$app "$datadir" #================================================= # ADD A CONFIGURATION diff --git a/scripts/remove b/scripts/remove index e8c4267..f725253 100644 --- a/scripts/remove +++ b/scripts/remove @@ -75,7 +75,7 @@ ynh_remove_logrotate #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Removing Fail2ban configuration..." +ynh_script_progression --message="Removing Fail2Ban configuration..." # Remove the dedicated Fail2Ban config ynh_remove_fail2ban_config diff --git a/scripts/restore b/scripts/restore index 59a680f..1ce4441 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,6 +30,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -56,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" 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" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE THE APP MAIN DIR @@ -69,6 +70,19 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." + +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p $datadir + +chmod 750 "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www-data "$datadir" + #================================================= # RESTORE FAIL2BAN CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index cf2bb2d..9356063 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,6 +24,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) admin_token=$(ynh_app_setting_get --app=$app --key=admin_token) rocket_port=$(ynh_app_setting_get --app=$app --key=rocket_port) websocket_port=$(ynh_app_setting_get --app=$app --key=websocket_port) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) #================================================= # CHECK VERSION @@ -32,11 +33,45 @@ ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +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 +ynh_clean_setup () { + ynh_clean_check_starting + # Restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped vaultwarden Server" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." +if [ -z "$datadir" ]; then + datadir=/home/yunohost.app/$app + mv $final_path/live/data $datadir + ynh_app_setting_set --app=$app --key=datadir --value=$datadir + + chmod 750 "$datadir" + chmod -R o-rwx "$datadir" + chown -R $app:$app "$datadir" +fi + # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -54,39 +89,15 @@ 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 -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -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 -ynh_clean_setup () { - ynh_clean_check_starting - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - ynh_remove_logrotate -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." - -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped vaultwarden Server" - #================================================= # CREATE DEDICATED USER #================================================= 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" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -113,7 +124,7 @@ chown -R $app:$app "$final_path" ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config -ynh_add_nginx_config "websocket_port rocket_port" +ynh_add_nginx_config #================================================= # UPGRADE DEPENDENCIES