From 81e072f42675940390a4a38df877fba465adce91 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 23:52:18 +0200 Subject: [PATCH] Apply last example_ynh --- scripts/install | 23 +++++++++++++---------- scripts/restore | 1 - scripts/upgrade | 17 ++++++++++------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/scripts/install b/scripts/install index bca67eb..99d38c5 100644 --- a/scripts/install +++ b/scripts/install @@ -98,6 +98,10 @@ ynh_setup_source --dest_dir="$final_path/build/" --source_id="app" # Download, check integrity, uncompress and patch the source from web.src ynh_setup_source --dest_dir="$final_path/live/web-vault/" --source_id="web" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -139,14 +143,6 @@ ynh_secure_remove --file="$final_path/.rustup" # Create datadir mkdir -p "$final_path"/live/data -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config - #================================================= # ADD A CONFIGURATION #================================================= @@ -157,6 +153,14 @@ ynh_add_config --template="../conf/bitwarden_rs.env" --destination="$final_path/ chmod 400 "$final_path/live/bitwarden_rs.env" chown $app:$app "$final_path/live/bitwarden_rs.env" +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +# Create a dedicated systemd config +ynh_add_systemd_config + #================================================= # GENERIC FINALIZATION #================================================= @@ -165,8 +169,6 @@ chown $app:$app "$final_path/live/bitwarden_rs.env" ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) -chown -R "$app":"$app" "$final_path" -mkdir -p "/var/log/$app" ynh_use_logrotate #================================================= @@ -190,6 +192,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l ynh_script_progression --message="Configuring Fail2Ban..." # Create a dedicated Fail2Ban config +mkdir -p "/var/log/$app" 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:.*$" diff --git a/scripts/restore b/scripts/restore index c97975d..26a93f0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -76,7 +76,6 @@ ynh_script_progression --message="Restoring the Fail2Ban configuration..." # Create a dedicated Fail2Ban config mkdir -p "/var/log/$app" -chown -R "$app":"$app" "/var/log/$app" touch /var/log/"$app"/"$app".log ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" diff --git a/scripts/upgrade b/scripts/upgrade index d9aadcb..3b4dea0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -162,6 +162,16 @@ then ynh_secure_remove --file="$final_path/.rustup" fi +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a config file..." + +ynh_add_config --template="../conf/bitwarden_rs.env" --destination="$final_path/live/bitwarden_rs.env" + +chmod 400 "$final_path/live/bitwarden_rs.env" +chown $app:$app "$final_path/live/bitwarden_rs.env" + #================================================= # SETUP SYSTEMD #================================================= @@ -170,13 +180,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a config file..." - -ynh_add_config --template="../conf/bitwarden_rs.env" --destination="$final_path/live/bitwarden_rs.env" - #================================================= # GENERIC FINALIZATION #=================================================