From 42f33698fecf8101be90d3874d3ea7a71ac170bb Mon Sep 17 00:00:00 2001 From: liberodark Date: Thu, 19 Dec 2019 17:35:44 +0100 Subject: [PATCH] Update restore --- scripts/restore | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/restore b/scripts/restore index 3db3cc3..452d66b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -27,18 +27,18 @@ ynh_script_progression --message="Loading settings..." --weight=1 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) +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) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=1 -ynh_webpath_available --domain=$domain --path_url=$path_url \ +ynh_webpath_available --domain="$domain" --path_url="$path_url" \ || ynh_die --message="Path not available: ${domain}${path_url}" -test ! -d $final_path \ +test ! -d "$final_path" \ || ynh_die --message="There is already a directory: $final_path " #================================================= @@ -62,16 +62,16 @@ ynh_restore_file --origin_path="$final_path" ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 # 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 USER RIGHTS #================================================= # Restore permissions on app files -chown -R "$app":"$app" $final_path +chown -R "$app":"$app" "$final_path" mkdir -p "/var/log/$app" -chown -R "$app":"$app" /var/log/$app +chown -R "$app":"$app" /var/log/"$app" #================================================= # RESTORE FAIL2BAN CONFIGURATION @@ -81,7 +81,7 @@ ynh_script_progression --message="Restoring the fail2ban configuration..." --wei # Create a dedicated fail2ban config mkdir -p "/var/log/$app" chown -R "$app":"$app" "/var/log/$app" -touch /var/log/$app/$app.log +touch /var/log/"$app"/"$app".log ynh_restore_file "/etc/fail2ban/jail.d/$app.conf" ynh_restore_file "/etc/fail2ban/filter.d/$app.conf" @@ -95,7 +95,7 @@ ynh_systemd_action --action=restart --service_name=fail2ban ynh_script_progression --message="Reinstalling dependencies..." --weight=8 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies "$pkg_dependencies" #================================================= # RESTORE SYSTEMD @@ -103,22 +103,22 @@ ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service +systemctl enable "$app".service #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app --description "$app daemon for Bitwarden" --log "/var/log/$app/$app.log" +yunohost service add "$app" --description "$app daemon for Bitwarden" --log "/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Rocket has launched from" -if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then - ynh_systemd_action --service_name=$app --action="restart" --log_path="systemd" --line_match="Rocket has launched from" +ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="Rocket has launched from" +if [ "${PACKAGE_CHECK_EXEC:-0}" -eq 1 ]; then + ynh_systemd_action --service_name="$app" --action="restart" --log_path="systemd" --line_match="Rocket has launched from" fi #=================================================