From 4dbf25b73c3228675b5ff1bd7515c43239a822b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 20 Mar 2024 20:50:24 +0100 Subject: [PATCH] Move code to common.sh --- scripts/_common.sh | 15 +++++++++++++++ scripts/install | 15 --------------- scripts/upgrade | 19 ------------------- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a8ee0d6..41f73c9 100644 --- a/scripts/_common.sh +++ b/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 #================================================= diff --git a/scripts/install b/scripts/install index 63cc6a3..42324b8 100644 --- a/scripts/install +++ b/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 #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 81e7a2b..163b814 100644 --- a/scripts/upgrade +++ b/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 #=================================================