#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source ynh_docker_image_extract source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= admin_mail=$(ynh_user_get_info --username=$admin --key=mail) admin_token=$(ynh_string_random --length=48 | base64) #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=admin_token --value=$admin_token #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." _download_vaultwarden_from_docker #================================================= # 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 #================================================= ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_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: \. Username:.*$" 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..." # Start 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 #================================================= ynh_script_progression --message="Installation of $app completed"