فهرست منبع

Move code to common.sh

Félix Piédallu 2 سال پیش
والد
کامیت
4dbf25b73c
3فایلهای تغییر یافته به همراه15 افزوده شده و 34 حذف شده
  1. 15 0
      scripts/_common.sh
  2. 0 15
      scripts/install
  3. 0 19
      scripts/upgrade

+ 15 - 0
scripts/_common.sh

@@ -13,6 +13,21 @@ PI_HOLE_INSTALL_DIR="/opt/pihole"
 PI_HOLE_CONFIG_DIR="/etc/pihole"
 PI_HOLE_BIN_DIR="/usr/local/bin"
 
+# Get the default network interface
+main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
+
+# Get the dnsmasq user to set log files permissions
+dnsmasq_user=$(grep DNSMASQ_USER= /etc/init.d/dnsmasq | cut -d'"' -f2)
+
+# Find the IP associated to the network interface
+localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
+
+if [ "$query_logging" -eq 1 ]; then
+    query_logging_str=true
+else
+    query_logging_str=false
+fi
+
 #=================================================
 # PERSONAL HELPERS
 #=================================================

+ 0 - 15
scripts/install

@@ -14,21 +14,6 @@ source /usr/share/yunohost/helpers
 ynh_app_setting_set --app="$app" --key="overwrite_setupvars" --value=1
 ynh_app_setting_set --app="$app" --key="overwrite_ftl" --value=1
 
-# Get the default network interface
-main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
-
-# Get the dnsmasq user to set log files permissions
-dnsmasq_user=$(grep DNSMASQ_USER= /etc/init.d/dnsmasq | cut -d'"' -f2)
-
-# Find the IP associated to the network interface
-localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
-
-if [ "$query_logging" -eq 1 ]; then
-    query_logging_str=true
-else
-    query_logging_str=false
-fi
-
 #=================================================
 # CHECK AVAILABLE PORT
 #=================================================

+ 0 - 19
scripts/upgrade

@@ -7,25 +7,6 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# INITIALIZE AND STORE SETTINGS
-#=================================================
-
-# Get the default network interface
-main_iface=$(ip route | grep --max-count=1 default | awk '{print $5;}')
-
-# Get the dnsmasq user to set log files permissions
-dnsmasq_user=$(grep DNSMASQ_USER= /etc/init.d/dnsmasq | cut -d'"' -f2)
-
-# Find the IP associated to the network interface
-localipv4=$(ip address | grep "${main_iface}\$" | awk '{print $2;}' | cut -d/ -f1)
-
-if [ "$query_logging" -eq 1 ]; then
-    query_logging_str=true
-else
-    query_logging_str=false
-fi
-
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================