Browse Source

Fix missing ports

yalh76 3 years ago
parent
commit
f385b79539
3 changed files with 23 additions and 16 deletions
  1. 3 8
      scripts/install
  2. 20 0
      scripts/restore
  3. 0 8
      scripts/upgrade

+ 3 - 8
scripts/install

@@ -78,6 +78,9 @@ ynh_app_setting_set --app=$app --key=port --value=$port
 ynh_exec_fully_quiet yunohost firewall disallow Both 53 --no-reload
 ynh_exec_fully_quiet yunohost firewall disallow Both 53 --no-reload
 ynh_exec_fully_quiet yunohost firewall allow Both 53 --no-upnp
 ynh_exec_fully_quiet yunohost firewall allow Both 53 --no-upnp
 
 
+# Open the UDP port 67 for dhcp
+ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp
+
 #=================================================
 #=================================================
 # INSTALL DEPENDENCIES
 # INSTALL DEPENDENCIES
 #=================================================
 #=================================================
@@ -292,14 +295,6 @@ do
 		echo "$localipv4	$perdomain #Added by pihole#" >> /etc/hosts
 		echo "$localipv4	$perdomain #Added by pihole#" >> /etc/hosts
 done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
 done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
 
 
-#=================================================
-# ENABLE DHCP SERVER
-#=================================================
-ynh_script_progression --message="Enabling DHCP server..." --weight=1
-
-# Open the UDP port 67 for dhcp
-ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp
-
 #=================================================
 #=================================================
 # SET VERSIONS FOR THE FOOTER OF THE WEB INTERFACE
 # SET VERSIONS FOR THE FOOTER OF THE WEB INTERFACE
 #=================================================
 #=================================================

+ 20 - 0
scripts/restore

@@ -47,6 +47,26 @@ ynh_script_progression --message="Validating restoration parameters..." --weight
 test ! -d $final_path \
 test ! -d $final_path \
 	|| ynh_die --message="There is already a directory: $final_path "
 	|| ynh_die --message="There is already a directory: $final_path "
 
 
+#=================================================
+# FIND AND OPEN A PORT
+#=================================================
+ynh_script_progression --message="Finding an available port..." --weight=12
+
+# Find an available port
+port=$(ynh_find_port --port=4711)
+if [ $port -gt 4720 ]
+then
+	ynh_die --message="The ports 4711 to 4720 are already in use. Pi-hole can't work on another port. Please try to free one of these ports."
+fi
+ynh_app_setting_set --app=$app --key=port --value=$port
+
+# Disable the port 53 for upnp
+ynh_exec_fully_quiet yunohost firewall disallow Both 53 --no-reload
+ynh_exec_fully_quiet yunohost firewall allow Both 53 --no-upnp
+
+# Open the UDP port 67 for dhcp
+ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp
+
 #=================================================
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 # ACTIVATE MAINTENANCE MODE
 #=================================================
 #=================================================

+ 0 - 8
scripts/upgrade

@@ -362,14 +362,6 @@ do
 		echo "$localipv4	$perdomain #Added by pihole#" >> /etc/hosts
 		echo "$localipv4	$perdomain #Added by pihole#" >> /etc/hosts
 done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
 done <<< "$(yunohost domain list | grep "\." | sed 's/.*: \|.*- //')"
 
 
-#=================================================
-# ENABLE DHCP SERVER
-#=================================================
-ynh_script_progression --message="Enabling DHCP server..." --weight=1
-
-# Open the UDP port 67 for dhcp
-ynh_exec_fully_quiet yunohost firewall allow UDP 67 --no-upnp
-
 #=================================================
 #=================================================
 # SET VERSIONS FOR THE FOOTER OF THE WEB INTERFACE
 # SET VERSIONS FOR THE FOOTER OF THE WEB INTERFACE
 #=================================================
 #=================================================