11 Commits

Author SHA1 Message Date
itdoginfo
dfab862088 Fixed for 24 2024-12-16 10:23:45 +03:00
itdoginfo
02f5e5e5c8 Added openwrt 24.10 2024-12-16 00:23:42 +03:00
itdoginfo
f6a6864080 Merge pull request #33 from Akiyamov/master
Add confdir for snapshot
2024-12-16 00:17:23 +03:00
Akiyamov
86b9c1c075 Major release for ansible 2024-12-05 18:35:01 +05:00
Akiyamov
7b1f1631b3 Execute confdir only for 24 and newer versions 2024-12-05 15:55:03 +05:00
Akiyamov
f3bf5dda15 Update tasks/main.yml
Co-authored-by: Morozov Dmitriy <hacker000@yandex.ru>
2024-12-04 16:51:37 +05:00
Akiyamov
ae9e42a578 Add func exec 2024-12-04 16:16:30 +05:00
Akiyamov
a974ddef29 Add confdir for snapshot 2024-12-03 23:36:40 +05:00
itdoginfo
1e7a3bb8f6 Merge pull request #25 from HattabbI4/master
feat: Added package installation check
2024-10-31 13:18:51 +03:00
HattabbI4
a81fe1fb24 translate log messages 2024-10-31 14:53:16 +05:00
HattabbI4
71590700b0 Добавлена проверка установки пакетов 2024-10-31 13:52:28 +05:00
2 changed files with 58 additions and 16 deletions

View File

@@ -325,6 +325,18 @@ dnsmasqfull() {
[ -f /etc/config/dhcp-opkg ] && cp /etc/config/dhcp /etc/config/dhcp-old && mv /etc/config/dhcp-opkg /etc/config/dhcp
fi
}
s
dnsmasqconfdir() {
if [ $VERSION_ID -ge 24 ]; then
if uci get dhcp.@dnsmasq[0].confdir | grep -q /tmp/dnsmasq.d; then
printf "\033[32;1mconfdir already 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
@@ -564,19 +576,21 @@ add_dns_resolver() {
}
add_packages() {
if opkg list-installed | grep -q "curl -"; then
printf "\033[32;1mCurl already installed\033[0m\n"
for package in curl nano; do
if opkg list-installed | grep -q "^$package "; then
printf "\033[32;1m$package already installed\033[0m\n"
else
printf "\033[32;1mInstall curl\033[0m\n"
opkg install curl
fi
printf "\033[32;1mInstalling $package...\033[0m\n"
opkg install "$package"
if opkg list-installed | grep -q nano; then
printf "\033[32;1mNano already installed\033[0m\n"
if "$package" --version >/dev/null 2>&1; then
printf "\033[32;1m$package was successfully installed and available\033[0m\n"
else
printf "\033[32;1mInstall nano\033[0m\n"
opkg install nano
printf "\033[31;1mError: failed to install $package\033[0m\n"
exit 1
fi
fi
done
}
add_getdomains() {
@@ -958,8 +972,8 @@ printf "\033[34;1mVersion: $OPENWRT_RELEASE\033[0m\n"
VERSION_ID=$(echo $VERSION | awk -F. '{print $1}')
if [ "$VERSION_ID" -ne 23 ]; then
printf "\033[31;1mScript only support OpenWrt 23.05\033[0m\n"
if [ "$VERSION_ID" -ne 23 ] && [ "$VERSION_ID" -ne 24 ]; then
printf "\033[31;1mScript only support OpenWrt 23.05 and 24.10\033[0m\n"
echo "For OpenWrt 21.02 and 22.03 you can:"
echo "1) Use ansible https://github.com/itdoginfo/domain-routing-openwrt"
echo "2) Configure manually. Old manual: https://itdog.info/tochechnaya-marshrutizaciya-na-routere-s-openwrt-wireguard-i-dnscrypt/"
@@ -984,6 +998,8 @@ add_set
dnsmasqfull
dnsmasqconfdir
add_dns_resolver
add_getdomains

View File

@@ -6,6 +6,15 @@
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
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
@@ -63,6 +72,16 @@
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: ansible_distribution_major_version >= 24
notify:
- Restart dnsmasq
# Getdomains script configure
- name: getdomains script copy
@@ -655,6 +674,13 @@
notify:
- Restart firewall
- name: uci commit dhcp
uci:
command: commit
config: dhcp
notify:
- Restart dnsmasq
- name: uci commit network
uci:
command: commit