From ea5eb155d3d26917a1807334e947e2f2bf874c80 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 20 Dec 2021 10:42:16 +0100 Subject: [PATCH] Fix linter --- conf/nginx.conf | 4 ---- scripts/install | 9 +++++---- scripts/remove | 7 +------ scripts/restore | 21 ++++----------------- scripts/upgrade | 39 +++++++++++++++++++++------------------ 5 files changed, 31 insertions(+), 49 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b6db808..a60cf3b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,8 +1,4 @@ location __PATH__ { - # Force usage of https - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } proxy_pass http://127.0.0.1:__PORT__; proxy_set_header Host $host; diff --git a/scripts/install b/scripts/install index 4648d7f..9039dff 100644 --- a/scripts/install +++ b/scripts/install @@ -11,12 +11,14 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= + # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= + domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH superuser=$YNH_APP_ARG_SUPERUSER @@ -62,9 +64,8 @@ ynh_app_setting_set --app=$app --key=stream_port --value=$stream_port # Open ports ynh_script_progression --message="Configuring firewall..." --weight=15 -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port +ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $stream_port #================================================= # INSTALL DEPENDENCIES @@ -142,7 +143,7 @@ ynh_add_nginx_config # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $port $stream_port +yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $stream_port #================================================= # SETUP SSOWAT @@ -175,4 +176,4 @@ ynh_systemd_action --service_name=$app --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of Tvheadend completed, HTTP port is $port and HTSP port is $stream_port" --last +ynh_script_progression --message="Installation of Tvheadend completed, HTSP port is $stream_port" --last diff --git a/scripts/remove b/scripts/remove index 217b3de..93408d3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -74,7 +74,7 @@ ynh_script_progression --message="Removing Tvheadend main directory and config f # Remove the app directory securely (/home/hts folder) ## Use rm -r because ynh_secure_remove says that /home/hts is not an acceptable path to delete -rm -r $final_path +ynh_secure_remove --file="$final_path" ynh_secure_remove --file="/etc/default/tvheadend" #================================================= @@ -88,11 +88,6 @@ ynh_remove_nginx_config #================================================= # CLOSE PORTS #================================================= -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." --weight=8 - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi if yunohost firewall list | grep -q "\- $stream_port$" then diff --git a/scripts/restore b/scripts/restore index e4341a8..d51b2db 100644 --- a/scripts/restore +++ b/scripts/restore @@ -11,6 +11,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= + # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -35,8 +36,7 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=16 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD MODIFICATIONS @@ -44,10 +44,6 @@ test ! -d $final_path \ # OPEN TVHEADEND PORTS #================================================= ynh_script_progression --message="Configuring firewall..." --weight=15 -if yunohost firewall list | grep -q "\- $port$" -then - ynh_die --message="Port $port already open (and maybe used by another application)" -fi if yunohost firewall list | grep -q "\- $stream_port$" then @@ -121,21 +117,13 @@ ynh_script_progression --message="Restoring NGINX web server configuration..." - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $port $stream_port - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -ynh_permission_update --permission="main" --add="visitors" - #================================================= # RELOAD NGINX #================================================= @@ -160,5 +148,4 @@ ynh_systemd_action --service_name=$app --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of Tvheadend completed, HTTP port is $port and HTSP port is $stream_port" --last - +ynh_script_progression --message="Installation of Tvheadend completed, HTSP port is $stream_port" --last diff --git a/scripts/upgrade b/scripts/upgrade index e1d5c62..c844380 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -5,6 +5,7 @@ #================================================= # IMPORT GENERIC HELPERS #================================================= + source _common.sh source /usr/share/yunohost/helpers @@ -27,6 +28,7 @@ stream_port=$(ynh_app_setting_get --app=$app --key=stream_port) #================================================= # CHECK VERSION #================================================= + upgrade_type=$(ynh_check_app_version_changed) #================================================= @@ -52,10 +54,26 @@ ynh_script_progression --message="Stopping Tvheadend service..." --weight=3 ynh_systemd_action --service_name=$app --action="stop" +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public +fi + +if ! ynh_permission_exists --permission="main"; then + # Create the required permissions + ynh_permission_create --permission="main" --allowed="visitors" +fi #================================================= # UPGRADE TVHEADEND DEB PACKAGE #================================================= + if [ "$upgrade_type" == "UPGRADE_APP" ] then #================================================= @@ -116,7 +134,6 @@ then fi fi - #================================================= # NGINX CONFIGURATION #================================================= @@ -125,26 +142,11 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config - -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -if ! ynh_permission_exists --permission="main"; then - # Create the required permissions - ynh_permission_create --permission="main" --allowed="visitors" -fi - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 + yunohost service add $app --description="TV streaming server and recorder" --needs_exposed_ports $port $stream_port #================================================= @@ -157,6 +159,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= # PREVENT TVHEADEND BEING UPGRADED THROUGHT APT #================================================= + apt-mark hold tvheadend #================================================= @@ -169,4 +172,4 @@ ynh_systemd_action --service_name=$app --action="start" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of Tvheadend completed, HTTP port is $port and HTSP port is $stream_port" --last +ynh_script_progression --message="Upgrade of Tvheadend completed, HTSP port is $stream_port" --last