mirror of
https://github.com/YunoHost-Apps/vaultwarden_ynh.git
synced 2024-09-03 18:26:31 +02:00
Apply last example_ynh
This commit is contained in:
parent
98c8dd8834
commit
b0480cabea
12 changed files with 91 additions and 40 deletions
|
@ -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
|
||||
|
|
0
doc/.gitkeep
Normal file
0
doc/.gitkeep
Normal file
3
doc/DISCLAIMER.md
Normal file
3
doc/DISCLAIMER.md
Normal file
|
@ -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.
|
0
doc/screenshots/.gitkeep
Normal file
0
doc/screenshots/.gitkeep
Normal file
BIN
doc/screenshots/screenshot1.png
Normal file
BIN
doc/screenshots/screenshot1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 128 KiB |
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue