From a974ddef29619c7fc1533f00ef054c33018d5bc6 Mon Sep 17 00:00:00 2001 From: Akiyamov <116005851+Akiyamov@users.noreply.github.com> Date: Tue, 3 Dec 2024 23:36:40 +0500 Subject: [PATCH 1/5] Add confdir for snapshot --- getdomains-install.sh | 9 +++++++++ tasks/main.yml | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/getdomains-install.sh b/getdomains-install.sh index 044fad4..e8e767d 100755 --- a/getdomains-install.sh +++ b/getdomains-install.sh @@ -326,6 +326,15 @@ dnsmasqfull() { fi } +dnsmasqconfdir() { + if uci get dhcp.@dnsmasq[0].confdir | grep -q /tmp/dnsmasq.d; then + printf "\033[32;1mconfdir alreadt set\033[0m\n" + else + printf "\033[32;1mSetting confdir\033[0m\n" + uci set dhcp.@dnsmasq[0].confdir='/tmp/dnsmasq.d' + uci commit dhcp +fi +} remove_forwarding() { if [ ! -z "$forward_id" ]; then while uci -q delete firewall.@forwarding[$forward_id]; do :; done diff --git a/tasks/main.yml b/tasks/main.yml index 18a2b6b..c325f66 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,6 +6,10 @@ shell: opkg list-installed | grep dnsmasq-full | awk '{print $3}' register: dnsmasqfull_version + - name: Check confdir option + shell: uci get dhcp.@dnsmasq[0].confdir + register: dnsmasq_confdir + - name: debug debug: var: ansible_distribution_major_version @@ -63,6 +67,14 @@ when: ansible_distribution_major_version >= "23" and list_domains and not dnsmasqfull_version.stdout ignore_errors: true + - name: set confdir for dnsmasq + uci: + command: set + key: dhcp.@dnsmasq[0] + value: + confdir: "/tmp/dnsmasq.d" + when: dnsmasq_confdir.stdout != "/tmp/dnsmasq.d" + # Getdomains script configure - name: getdomains script copy From ae9e42a5787878900aa88a8fb16f7120ef6f37e1 Mon Sep 17 00:00:00 2001 From: Akiyamov <116005851+Akiyamov@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:16:30 +0500 Subject: [PATCH 2/5] Add func exec --- getdomains-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/getdomains-install.sh b/getdomains-install.sh index e8e767d..e7fe8ea 100755 --- a/getdomains-install.sh +++ b/getdomains-install.sh @@ -995,6 +995,8 @@ add_set dnsmasqfull +dnsmasqconfdir + add_dns_resolver add_getdomains From f3bf5dda1540460b48f36bc86fe92cbc0efa213f Mon Sep 17 00:00:00 2001 From: Akiyamov <116005851+Akiyamov@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:51:37 +0500 Subject: [PATCH 3/5] Update tasks/main.yml Co-authored-by: Morozov Dmitriy --- tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/main.yml b/tasks/main.yml index c325f66..09509ae 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,6 +9,7 @@ - name: Check confdir option shell: uci get dhcp.@dnsmasq[0].confdir register: dnsmasq_confdir + ignore_errors: true - name: debug debug: From 7b1f1631b3727c19b5a812ba342b086d184a0ca7 Mon Sep 17 00:00:00 2001 From: Akiyamov <116005851+Akiyamov@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:55:03 +0500 Subject: [PATCH 4/5] Execute confdir only for 24 and newer versions --- getdomains-install.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/getdomains-install.sh b/getdomains-install.sh index e7fe8ea..130be08 100755 --- a/getdomains-install.sh +++ b/getdomains-install.sh @@ -323,18 +323,22 @@ dnsmasqfull() { opkg remove dnsmasq && opkg install dnsmasq-full --cache /tmp/ [ -f /etc/config/dhcp-opkg ] && cp /etc/config/dhcp /etc/config/dhcp-old && mv /etc/config/dhcp-opkg /etc/config/dhcp -fi + fi } dnsmasqconfdir() { - if uci get dhcp.@dnsmasq[0].confdir | grep -q /tmp/dnsmasq.d; then - printf "\033[32;1mconfdir alreadt set\033[0m\n" - else - printf "\033[32;1mSetting confdir\033[0m\n" - uci set dhcp.@dnsmasq[0].confdir='/tmp/dnsmasq.d' - uci commit dhcp -fi + openwrt_release=$(cat /etc/openwrt_release | grep -Eo [0-9]{2}[.][0-9]{2}[.][0-9]* | cut -d '.' -f 1 | tail -n 1) + if [ $openwrt_release -ge 24 ]; then + if uci get dhcp.@dnsmasq[0].confdir | grep -q /tmp/dnsmasq.d; then + printf "\033[32;1mconfdir alreadt set\033[0m\n" + else + printf "\033[32;1mSetting confdir\033[0m\n" + uci set dhcp.@dnsmasq[0].confdir='/tmp/dnsmasq.d' + uci commit dhcp + fi + fi } + remove_forwarding() { if [ ! -z "$forward_id" ]; then while uci -q delete firewall.@forwarding[$forward_id]; do :; done From 86b9c1c075c4b4a39dfb7329a7c8c2736782fb96 Mon Sep 17 00:00:00 2001 From: Akiyamov <116005851+Akiyamov@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:35:01 +0500 Subject: [PATCH 5/5] Major release for ansible --- tasks/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 09509ae..7e2a130 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,6 +11,10 @@ register: dnsmasq_confdir ignore_errors: true + - name: Get openwrt major release + shell: cat /etc/openwrt_release | grep -Eo [0-9]{2}[.][0-9]{2}[.][0-9]* | cut -d '.' -f 1 | tail -n 1 + register: openwrt_major_release + - name: debug debug: var: ansible_distribution_major_version @@ -74,7 +78,7 @@ key: dhcp.@dnsmasq[0] value: confdir: "/tmp/dnsmasq.d" - when: dnsmasq_confdir.stdout != "/tmp/dnsmasq.d" + when: dnsmasq_confdir.stdout != "/tmp/dnsmasq.d" and openwrt_major_release >= 24 # Getdomains script configure