mirror of
https://github.com/YunoHost-Apps/vaultwarden_ynh.git
synced 2024-09-03 18:26:31 +02:00
commit
e5ea5b0763
6 changed files with 50 additions and 84 deletions
|
@ -1,3 +1,5 @@
|
|||
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
|
||||
|
||||
packaging_format = 2
|
||||
|
||||
id = "vaultwarden"
|
||||
|
|
|
@ -10,6 +10,27 @@ pkg_image="vaultwarden/server"
|
|||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
_download_vaultwarden_from_docker() {
|
||||
|
||||
# Download, check integrity, uncompress the source of vaultwarden from app.src to his build directory
|
||||
docker_arg=""
|
||||
# Fixup for armhf
|
||||
if [ $YNH_ARCH == "armhf" ]; then
|
||||
docker_arg="--os_arch_variant=linux/arm/v7"
|
||||
fi
|
||||
ynh_docker_image_extract --dest_dir="$install_dir/build/" --image_spec="$pkg_image:$(ynh_app_upstream_version)" $docker_arg
|
||||
|
||||
mkdir -p "$install_dir/live/"
|
||||
|
||||
mv -f "$install_dir/build/vaultwarden" "$install_dir/live/vaultwarden"
|
||||
rsync -a "$install_dir/build/web-vault/" "$install_dir/live/web-vault/"
|
||||
ynh_secure_remove --file="$install_dir/build"
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -29,18 +29,17 @@ ynh_app_setting_set --app=$app --key=admin_token --value=$admin_token
|
|||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
docker_arg=""
|
||||
if [ $YNH_ARCH == "armhf" ]
|
||||
then
|
||||
docker_arg="--os_arch_variant=linux/arm/v7"
|
||||
fi
|
||||
ynh_docker_image_extract --dest_dir="$install_dir/build/" --image_spec="$pkg_image:$(ynh_app_upstream_version)" $docker_arg
|
||||
mkdir -p "$install_dir/live/"
|
||||
_download_vaultwarden_from_docker
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
ynh_add_config --template="vaultwarden.env" --destination="$install_dir/live/.env"
|
||||
|
||||
chmod 400 "$install_dir/live/.env"
|
||||
chown $app:$app "$install_dir/live/.env"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
|
@ -53,43 +52,19 @@ ynh_add_nginx_config
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
mkdir -p "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
|
||||
ynh_use_logrotate
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
# Create log file for fail2ban
|
||||
mkdir -p "/var/log/$app"
|
||||
touch "/var/log/$app/$app.log"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_use_logrotate
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Username or password is incorrect\. Try again\. IP: <ADDR>\. Username:.*$"
|
||||
|
||||
yunohost service add $app --description="$app daemon for vaultwarden" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# MAKE INSTALL
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making install..."
|
||||
|
||||
mv -f "$install_dir/build/vaultwarden" "$install_dir/live/vaultwarden"
|
||||
rsync -a "$install_dir/build/web-vault/" "$install_dir/live/web-vault/"
|
||||
ynh_secure_remove --file="$install_dir/build"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..."
|
||||
|
||||
ynh_add_config --template="vaultwarden.env" --destination="$install_dir/live/.env"
|
||||
|
||||
chmod 400 "$install_dir/live/.env"
|
||||
chown $app:$app "$install_dir/live/.env"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
|
|
|
@ -32,8 +32,6 @@ chown -R $app:$app "$data_dir"
|
|||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
# RESTORE THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
@ -41,25 +39,23 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|||
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
|
||||
systemctl enable $app.service --quiet
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
yunohost service add $app --description="$app daemon for vaultwarden" --log="/var/log/$app/$app.log"
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
# Create log file for fail2ban
|
||||
mkdir -p "/var/log/$app"
|
||||
touch "/var/log/$app/$app.log"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
ynh_systemd_action --action=restart --service_name=fail2ban
|
||||
|
||||
yunohost service add $app --description="$app daemon for vaultwarden" --log="/var/log/$app/$app.log"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Starting a systemd service..."
|
||||
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||
|
||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Rocket has launched from" --length=100
|
||||
|
||||
|
|
|
@ -33,37 +33,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|||
then
|
||||
ynh_script_progression --message="Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress the source of vaultwarden from app.src to his build directory
|
||||
docker_arg=""
|
||||
if [ $YNH_ARCH == "armhf" ]
|
||||
then
|
||||
docker_arg="--os_arch_variant=linux/arm/v7"
|
||||
_download_vaultwarden_from_docker
|
||||
fi
|
||||
ynh_docker_image_extract --dest_dir="$install_dir/build/" --image_spec="$pkg_image:$(ynh_app_upstream_version)" $docker_arg
|
||||
mkdir -p "$install_dir/live/"
|
||||
fi
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# MAKE UPGRADE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Making upgrade..."
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
then
|
||||
mv -f "$install_dir/build/vaultwarden" "$install_dir/live/vaultwarden"
|
||||
ynh_secure_remove --file="$install_dir/live/web-vault/"
|
||||
rsync -a "$install_dir/build/web-vault/" "$install_dir/live/web-vault/"
|
||||
ynh_secure_remove --file="$install_dir/build"
|
||||
fi
|
||||
|
||||
chmod 750 "$install_dir"
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R $app:$app "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
|
@ -86,15 +57,14 @@ ynh_add_nginx_config
|
|||
# Create a dedicated systemd config
|
||||
ynh_add_systemd_config
|
||||
|
||||
mkdir -p "/var/log/$app"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
# Create log file for fail2ban
|
||||
mkdir -p "/var/log/$app"
|
||||
touch "/var/log/$app/$app.log"
|
||||
chown -R $app:$app "/var/log/$app"
|
||||
|
||||
# Use logrotate to manage app-specific logfile(s)
|
||||
ynh_use_logrotate --non-append
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="/var/log/$app/$app.log" --failregex="^.*Username or password is incorrect\. Try again\. IP: <ADDR>\. Username:.*$"
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
|
||||
|
||||
test_format = 1.0
|
||||
|
||||
[default]
|
||||
|
|
Loading…
Add table
Reference in a new issue