mirror of
https://github.com/YunoHost-Apps/squid3_ynh.git
synced 2024-09-03 20:26:11 +02:00
Port changing option in upgrade and find port in restore
This commit is contained in:
parent
028e92158d
commit
c86332fa3e
4 changed files with 41 additions and 9 deletions
|
@ -15,11 +15,11 @@
|
|||
setup_public=0
|
||||
upgrade=1
|
||||
#upgrade=1 from_commit=CommitHash
|
||||
backup_restore=1
|
||||
backup_restore=0
|
||||
multi_instance=0
|
||||
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||
# incorrect_path=1
|
||||
port_already_use=1
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
||||
|
|
|
@ -25,6 +25,7 @@ ynh_abort_if_errors
|
|||
#=================================================
|
||||
|
||||
squid_port=$YNH_APP_ARG_SQUID_PORT
|
||||
new_port=""
|
||||
|
||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||
|
@ -53,6 +54,7 @@ ynh_script_progression --message="Configuring firewall..."
|
|||
# Find an available port
|
||||
port=$(ynh_find_port --port=$squid_port)
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
ynh_app_setting_set --app=$app --key=new_port --value=$new_port
|
||||
|
||||
# Optional: Expose this port publicly
|
||||
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
|
||||
|
|
|
@ -41,8 +41,14 @@ ynh_install_app_dependencies $pkg_dependencies
|
|||
#=================================================
|
||||
# OPEN PORTS
|
||||
#=================================================
|
||||
# Optional: Expose this port publicly
|
||||
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
|
||||
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
|
||||
|
||||
yunohost firewall allow --no-upnp TCP $port
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=$squid_port)
|
||||
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
|
@ -109,4 +115,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --type="install"
|
|||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --time --last
|
||||
ynh_script_progression --message="Restoration completed for $app"
|
|
@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
app=$YNH_APP_INSTANCE_NAME
|
||||
port=$(ynh_app_setting_get $app port)
|
||||
new_port=$(ynh_app_setting_get $app new_port)
|
||||
|
||||
#=================================================
|
||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||
|
@ -40,13 +41,36 @@ ynh_script_progression --message="Upgrading dependencies..." -
|
|||
|
||||
ynh_install_app_dependencies $pkg_dependencies
|
||||
|
||||
#=================================================
|
||||
# CLOSE A PORT
|
||||
#=================================================
|
||||
# If #new_port is not defined test the $port and keep it open
|
||||
if [ -z $new_port ] then
|
||||
# Optional: Expose this port publicly
|
||||
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
|
||||
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
|
||||
|
||||
# Optional: Expose this port publicly
|
||||
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
|
||||
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
|
||||
# Find an available port
|
||||
port=$(ynh_find_port --port=$squid_port)
|
||||
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
# If $new_port is define close the $port and open the $new_port
|
||||
else
|
||||
#Close $port
|
||||
if yunohost firewall list | grep -q "\- $port$"
|
||||
then
|
||||
ynh_script_progression --message="Closing port $port..."
|
||||
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||
fi
|
||||
|
||||
# Open $new_port
|
||||
port=$(ynh_find_port --port=$squid_new_port)
|
||||
#Add the value of $new_port to $port
|
||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||
#Remove the value of $new_port
|
||||
ynh_app_setting_set --app=$app --key=new_port --value=""
|
||||
fi
|
||||
|
||||
# Open the port
|
||||
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||
|
||||
#=================================================
|
||||
# MODIFY A CONFIG FILE
|
||||
|
|
Loading…
Add table
Reference in a new issue