1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/syncthing_ynh.git synced 2024-09-03 20:26:23 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2020-02-23 19:04:06 +01:00
parent 5d94c3b1fc
commit c815da70aa
8 changed files with 61 additions and 30 deletions

View file

@ -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/) * 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/) * 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 ## Links

View file

@ -1,15 +1,15 @@
location __PATH__/ { location __PATH__/ {
proxy_set_header Host 127.0.0.1; proxy_set_header Host 127.0.0.1;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:__GUI_PORT__/;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
# Include SSOWAT user panel. proxy_pass http://127.0.0.1:__GUI_PORT__/;
include conf.d/yunohost_panel.conf.inc;
more_clear_input_headers 'Accept-Encoding'; 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';
} }

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting

View file

@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
ynh_print_info --message="Retrieve arguments from the manifest"
old_domain=$YNH_APP_OLD_DOMAIN old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH 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_user=$db_name
#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #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 # CHECK WHICH PARTS SHOULD BE CHANGED
#================================================= #=================================================
@ -57,7 +75,7 @@ fi
#================================================= #=================================================
ynh_print_info --message="Stopping a systemd service..." 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 # MODIFY URL IN NGINX CONF
@ -88,12 +106,6 @@ then
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi fi
#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
# ...
#=================================================
#================================================= #=================================================
# GENERIC FINALISATION # GENERIC FINALISATION
#================================================= #=================================================
@ -101,7 +113,7 @@ fi
#================================================= #=================================================
ynh_print_info --message="Starting a systemd service..." 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 # RELOAD NGINX

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
@ -23,6 +24,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
ynh_print_info --message="Retrieving arguments from the manifest..."
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH 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..." ynh_print_info --message="Configuring firewall..."
# Find an available port
gui_port=$(ynh_find_port --port=8384) gui_port=$(ynh_find_port --port=8384)
ynh_app_setting_set --app=$app --key=gui_port --value=$gui_port ynh_app_setting_set --app=$app --key=gui_port --value=$gui_port
sync_port=$(ynh_find_port --port=22000) 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 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 # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -128,6 +131,7 @@ ynh_replace_string --match_string="__SYNC_HOME__" --replace_string="$sync_home"
#================================================= #=================================================
# FIX LISTENING SERVICE # FIX LISTENING SERVICE
#================================================= #=================================================
ynh_print_info --message="Fixing listening service..."
chown -R $app: $final_path 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 # 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 # Calculate and store the config file checksum into the app settings
ynh_store_file_checksum --file="$config_file" ynh_store_file_checksum --file="$config_file"
@ -149,13 +154,15 @@ ynh_store_file_checksum --file="$config_file"
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions to app files # Set permissions to app files
chown -R $app: $final_path 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" yunohost service add $app --description "$app daemon for Syncthing"

View file

@ -25,11 +25,12 @@ sync_port=$(ynh_app_setting_get --app=$app --key=sync_port)
#================================================= #=================================================
# STANDARD REMOVE # 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` # Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
if yunohost service status $app >/dev/null 2>&1 if ynh_exec_warn_less yunohost service status $app >/dev/null
then then
ynh_print_info --message="Removing $app service..." ynh_print_info --message="Removing $app service..."
yunohost service remove $app yunohost service remove $app
@ -62,9 +63,13 @@ ynh_remove_nginx_config
#================================================= #=================================================
# CLOSE A PORT # CLOSE A PORT
#================================================= #=================================================
ynh_print_info --message="Closing a port..."
ynh_print_info --message="Closing port $sync_port" if yunohost firewall list | grep -q "\- $sync_port$"
ynh_exec_warn_less yunohost firewall disallow TCP $sync_port then
ynh_print_info --message="Closing port $sync_port..."
ynh_exec_warn_less yunohost firewall disallow TCP $sync_port
fi
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -13,6 +13,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_print_info --message="Managing script failure..."
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
@ -47,6 +48,7 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # 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" 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 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" yunohost service add $app --description "$app daemon for Syncthing"

View file

@ -29,6 +29,7 @@ gui_port=$(ynh_app_setting_get --app=$app --key=gui_port)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_print_info --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) 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 gui_port doesn't exist, create it
if [ -z $gui_port ]; then if [ -z $gui_port ]; then
OLD_SYNCHOME="/home/yunohost.app/syncthing" OLD_SYNCHOME="/home/yunohost.app/syncthing"
OLD_SYNCUSER=debian-syncthing OLD_SYNCUSER=debian-syncthing
@ -149,6 +151,7 @@ chown -R "$app": "$sync_home"
#================================================= #=================================================
# STORE THE CONFIG FILE CHECKSUM # STORE THE CONFIG FILE CHECKSUM
#================================================= #=================================================
ynh_print_info --message="Storing the config file checksum..."
config_file="$final_path/.config/syncthing/config.xml" config_file="$final_path/.config/syncthing/config.xml"
@ -169,6 +172,7 @@ ynh_add_systemd_config
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
ynh_print_info --message="Securing files and directories..."
# Set permissions on app files # Set permissions on app files
chown -R $app: $final_path chown -R $app: $final_path