diff --git a/README.md b/README.md index a53b7b5..b5c4238 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ How to configure this app: by an admin panel, a plain file with SSH, or any othe * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/syncthing%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/syncthing/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/syncthing%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/syncthing/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/syncthing%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/syncthing/) ## Links diff --git a/conf/nginx.conf b/conf/nginx.conf index abbaac9..edb8c18 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,15 +1,15 @@ location __PATH__/ { - proxy_set_header Host 127.0.0.1; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_pass http://127.0.0.1:__GUI_PORT__/; - - proxy_read_timeout 600s; - proxy_send_timeout 600s; + proxy_set_header Host 127.0.0.1; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; - more_clear_input_headers 'Accept-Encoding'; + proxy_pass http://127.0.0.1:__GUI_PORT__/; + + proxy_read_timeout 600s; + proxy_send_timeout 600s; + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; + more_clear_input_headers 'Accept-Encoding'; } diff --git a/scripts/backup b/scripts/backup index c1e753b..ae55ea1 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting diff --git a/scripts/change_url b/scripts/change_url index 3e28062..0d51719 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= +ynh_print_info --message="Retrieve arguments from the manifest" old_domain=$YNH_APP_OLD_DOMAIN old_path=$YNH_APP_OLD_PATH @@ -34,6 +35,23 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #db_user=$db_name #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_print_info --message="Backing up the app before changing its url (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= @@ -57,7 +75,7 @@ fi #================================================= ynh_print_info --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" +ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd #================================================= # MODIFY URL IN NGINX CONF @@ -88,12 +106,6 @@ then ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - #================================================= # GENERIC FINALISATION #================================================= @@ -101,7 +113,7 @@ fi #================================================= ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL" #================================================= # RELOAD NGINX diff --git a/scripts/install b/scripts/install index f83c02a..f3c712c 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -23,6 +24,7 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +ynh_print_info --message="Retrieving arguments from the manifest..." domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH @@ -61,13 +63,14 @@ ynh_app_setting_set --app=$app --key=sync_home --value=$sync_home #================================================= ynh_print_info --message="Configuring firewall..." +# Find an available port gui_port=$(ynh_find_port --port=8384) ynh_app_setting_set --app=$app --key=gui_port --value=$gui_port sync_port=$(ynh_find_port --port=22000) -# Open this port -ynh_exec_warn_less yunohost firewall allow TCP $sync_port ynh_app_setting_set --app=$app --key=sync_port --value=$sync_port +# Open the port +ynh_exec_warn_less yunohost firewall allow TCP $sync_port #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -128,6 +131,7 @@ ynh_replace_string --match_string="__SYNC_HOME__" --replace_string="$sync_home" #================================================= # FIX LISTENING SERVICE #================================================= +ynh_print_info --message="Fixing listening service..." chown -R $app: $final_path @@ -140,6 +144,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= +ynh_print_info --message="Storing the config file checksum..." # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$config_file" @@ -149,13 +154,15 @@ ynh_store_file_checksum --file="$config_file" #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_print_info --message="Securing files and directories..." # Set permissions to app files chown -R $app: $final_path #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_print_info --message="Integrating service in YunoHost..." yunohost service add $app --description "$app daemon for Syncthing" diff --git a/scripts/remove b/scripts/remove index e7aa158..faa5d85 100644 --- a/scripts/remove +++ b/scripts/remove @@ -25,11 +25,12 @@ sync_port=$(ynh_app_setting_get --app=$app --key=sync_port) #================================================= # STANDARD REMOVE #================================================= -# REMOVE SERVICE FROM ADMIN PANEL +# REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= +ynh_print_info --message="Removing service integration in YunoHost..." -# Remove a service from the admin panel, added by `yunohost service add` -if yunohost service status $app >/dev/null 2>&1 +# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status $app >/dev/null then ynh_print_info --message="Removing $app service..." yunohost service remove $app @@ -62,9 +63,13 @@ ynh_remove_nginx_config #================================================= # CLOSE A PORT #================================================= +ynh_print_info --message="Closing a port..." -ynh_print_info --message="Closing port $sync_port" -ynh_exec_warn_less yunohost firewall disallow TCP $sync_port +if yunohost firewall list | grep -q "\- $sync_port$" +then + ynh_print_info --message="Closing port $sync_port..." + ynh_exec_warn_less yunohost firewall disallow TCP $sync_port +fi #================================================= # GENERIC FINALIZATION diff --git a/scripts/restore b/scripts/restore index e801b00..91a94d2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= +ynh_print_info --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -47,6 +48,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_print_info --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -92,8 +94,9 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service #================================================= -# ADVERTISE SERVICE IN ADMIN PANEL +# INTEGRATE SERVICE IN YUNOHOST #================================================= +ynh_print_info --message="Integrating service in YunoHost..." yunohost service add $app --description "$app daemon for Syncthing" diff --git a/scripts/upgrade b/scripts/upgrade index 4fd384d..baf88c5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,7 @@ gui_port=$(ynh_app_setting_get --app=$app --key=gui_port) #================================================= # CHECK VERSION #================================================= +ynh_print_info --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -39,6 +40,7 @@ ynh_print_info --message="Ensuring downward compatibility..." # If gui_port doesn't exist, create it if [ -z $gui_port ]; then + OLD_SYNCHOME="/home/yunohost.app/syncthing" OLD_SYNCUSER=debian-syncthing @@ -149,6 +151,7 @@ chown -R "$app": "$sync_home" #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= +ynh_print_info --message="Storing the config file checksum..." config_file="$final_path/.config/syncthing/config.xml" @@ -169,6 +172,7 @@ ynh_add_systemd_config #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_print_info --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path