Browse Source

Use the FTL port, do not open it

Kay0u 4 years ago
parent
commit
994419c68e
5 changed files with 8 additions and 14 deletions
  1. 3 0
      conf/pihole-FTL.conf
  2. 2 1
      scripts/actions/reset_default_config
  3. 1 7
      scripts/install
  4. 1 1
      scripts/remove
  5. 1 5
      scripts/upgrade

+ 3 - 0
conf/pihole-FTL.conf

@@ -2,6 +2,9 @@
 ; localonly|all
 ; localonly|all
 SOCKET_LISTENING=localonly
 SOCKET_LISTENING=localonly
 
 
+; On which port should FTL be listening?
+FTLPORT=__PORT__
+
 ; Display all queries? Set to no to hide query display
 ; Display all queries? Set to no to hide query display
 ; yes|no
 ; yes|no
 QUERY_DISPLAY=yes
 QUERY_DISPLAY=yes

+ 2 - 1
scripts/actions/reset_default_config

@@ -70,7 +70,8 @@ then
 elif [ "$file" = "pihole-FTL.conf" ]
 elif [ "$file" = "pihole-FTL.conf" ]
 then
 then
     # Get the default file and overwrite the current config
     # Get the default file and overwrite the current config
-    cp /etc/yunohost/apps/$app/conf/pihole-FTL.conf "$config_file"
+    port=$(ynh_app_setting_get --app=$app --key=port)
+    ynh_add_config --template="/etc/yunohost/apps/$app/conf/pihole-FTL.conf" --destination="$config_file"
 
 
     ynh_script_progression --message="Restarting Pi-Hole..." --weight=2
     ynh_script_progression --message="Restarting Pi-Hole..." --weight=2
 
 

+ 1 - 7
scripts/install

@@ -74,10 +74,6 @@ if [ $port -gt 4720 ]
 then
 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."
     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
 fi
-
-ynh_script_progression --message="Configuring firewall..." --weight=1
-# Open this port
-ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port
 ynh_app_setting_set --app=$app --key=port --value=$port
 ynh_app_setting_set --app=$app --key=port --value=$port
 
 
 # Disable the port 53 for upnp
 # Disable the port 53 for upnp
@@ -230,10 +226,8 @@ ynh_exec_warn_less make install )
 ynh_secure_remove --file="$FTL_temp_path"
 ynh_secure_remove --file="$FTL_temp_path"
 
 
 cp "../conf/dns-servers.conf" "$pihole_storage"
 cp "../conf/dns-servers.conf" "$pihole_storage"
-cp "../conf/pihole-FTL.conf" "$pihole_storage"
 
 
-# Calculate and store the config file checksum into the app settings
-ynh_store_file_checksum --file="$pihole_storage/pihole-FTL.conf"
+ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf"
 
 
 if [ "$pihole_version" == "Last 3.X" ]
 if [ "$pihole_version" == "Last 3.X" ]
 then
 then

+ 1 - 1
scripts/remove

@@ -109,7 +109,7 @@ ynh_remove_fpm_config
 #=================================================
 #=================================================
 # CLOSE PORTS
 # CLOSE PORTS
 #=================================================
 #=================================================
-ynh_script_progression --message="Closing ports $port et 67..." --weight=13
+ynh_script_progression --message="Closing ports $port and 67..." --weight=13
 
 
 if yunohost firewall list | grep -q "\- $port$"
 if yunohost firewall list | grep -q "\- $port$"
 then
 then

+ 1 - 5
scripts/upgrade

@@ -265,11 +265,7 @@ fi
 # Overwrite pihole-FTL config file only if it's allowed
 # Overwrite pihole-FTL config file only if it's allowed
 if [ $overwrite_ftl -eq 1 ]
 if [ $overwrite_ftl -eq 1 ]
 then
 then
-    # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
-    ynh_backup_if_checksum_is_different --file="$pihole_storage/pihole-FTL.conf"
-    cp "../conf/pihole-FTL.conf" "$pihole_storage"
-    # Recalculate and store the checksum of the file for the next upgrade.
-    ynh_store_file_checksum --file="$pihole_storage/pihole-FTL.conf"
+    ynh_add_config --template="../conf/pihole-FTL.conf" --destination="$pihole_storage/pihole-FTL.conf"
 fi
 fi
 
 
 if [ "$pihole_version" == "Last 3.X" ]
 if [ "$pihole_version" == "Last 3.X" ]