(・x・)

This commit is contained in:
itdoginfo
2024-03-09 12:29:54 +03:00
parent 8f18b95b1e
commit d0fad434cc
5 changed files with 32 additions and 32 deletions

View File

@@ -8,12 +8,12 @@ Shell скрипт и playbook для Ansible. Автоматизируют на
## Скрипт для установки ## Скрипт для установки
Запуск без скачивания Запуск без скачивания
``` ```
sh <(wget -O - https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/getdomains-install.sh) sh <(wget -O - https://raw.githubusercontent.com/itdoginfo/domain-routing-openwrt/master/getdomains-install.sh)
``` ```
Запуск со скачиванием Запуск со скачиванием
``` ```
wget https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/getdomains-install.sh && sh getdomains-install.sh wget https://raw.githubusercontent.com/itdoginfo/domain-routing-openwrt/master/getdomains-install.sh && sh getdomains-install.sh
``` ```
Подробности описаны в статье указаной выше. Подробности описаны в статье указаной выше.
@@ -105,9 +105,9 @@ ansible-galaxy install gekmihesg.openwrt
``` ```
cd /etc/ansible cd /etc/ansible
git clone https://github.com/itdoginfo/ansible-openwrt-hirkn git clone https://github.com/itdoginfo/domain-routing-openwrt
mv ansible-openwrt-hirkn/* . mv domain-routing-openwrt/* .
rm -rf ansible-openwrt-hirkn README.md rm -rf domain-routing-openwrt README.md
``` ```
Добавить роутер в файл hosts в группу openwrt Добавить роутер в файл hosts в группу openwrt
@@ -116,7 +116,7 @@ rm -rf ansible-openwrt-hirkn README.md
192.168.1.1 192.168.1.1
``` ```
Подставить переменные в **hirkn.yml** Подставить переменные в **hivpn.yml**
Для работы Ansible c OpenWrt необходимо, чтоб было выполнено одно из условий: Для работы Ansible c OpenWrt необходимо, чтоб было выполнено одно из условий:
- Отсутствие пароля для root (не рекомендуется) - Отсутствие пароля для root (не рекомендуется)
@@ -124,12 +124,12 @@ rm -rf ansible-openwrt-hirkn README.md
Запуск playbook Запуск playbook
``` ```
ansible-playbook playbooks/hirkn.yml --limit 192.168.1.1 ansible-playbook playbooks/hivpn.yml --limit 192.168.1.1
``` ```
После выполнения playbook роутер сразу начнёт выполнять обход блокировок. После выполнения playbook роутер сразу начнёт роутить необходмые домены в туннель/прокси.
Если у вас были ошибки и они исправились при повторном запуске playbook, но при этом обход не разработал, сделайте рестарт сети и скрипта: Если у вас были ошибки и они исправились при повторном запуске playbook, но при этом роутинг не заработал, сделайте рестарт сети и скрипта:
``` ```
service network restart service network restart
service getdomains start service getdomains start
@@ -145,29 +145,29 @@ service getdomains start
### Запуск ### Запуск
``` ```
wget -O - https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/getdomains-check.sh | sh wget -O - https://raw.githubusercontent.com/itdoginfo/domain-routing-openwrt/master/getdomains-check.sh | sh
``` ```
### Запустить с проверкой на подмену DNS ### Запустить с проверкой на подмену DNS
``` ```
wget -O - https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/getdomains-check.sh | sh -s dns wget -O - https://raw.githubusercontent.com/itdoginfo/domain-routing-openwrt/master/getdomains-check.sh | sh -s dns
``` ```
### Запустить с созданием dump ### Запустить с созданием dump
``` ```
wget -O - https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/getdomains-check.sh | sh -s dump wget -O - https://raw.githubusercontent.com/itdoginfo/domain-routing-openwrt/master/getdomains-check.sh | sh -s dump
``` ```
### Скачать и потом запустить ### Скачать и потом запустить
``` ```
wget https://raw.githubusercontent.com/itdoginfo/ansible-openwrt-hirkn/master/getdomains-check.sh wget https://raw.githubusercontent.com/itdoginfo/domain-routing-openwrt/master/getdomains-check.sh
chmod +x check-hirkn.sh chmod +x getdomains-check.sh
./check-hirkn.sh ./getdomains-check.sh
``` ```
С созданием dump С созданием dump
``` ```
./check-hirkn.sh dump ./getdomains-check.sh dump
``` ```
Поиск ошибок вручную: https://habr.com/ru/post/702388/ Поиск ошибок вручную: https://habr.com/ru/post/702388/

View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
HIRKN=/etc/init.d/hirkn HIVPN=/etc/init.d/hivpn
GETDOMAINS=/etc/init.d/getdomains GETDOMAINS=/etc/init.d/getdomains
DUMP=/tmp/dump.txt DUMP=/tmp/dump.txt
@@ -326,18 +326,18 @@ else
output_21 output_21
fi fi
# hirkn script # hivpn script
if [ -s "$HIRKN" ]; then if [ -s "$HIVPN" ]; then
checkpoint_true "Script hirkn" checkpoint_true "Script hivpn"
if crontab -l | grep -q $HIRKN; then if crontab -l | grep -q $HIVPN; then
checkpoint_true "Script hirkn in crontab" checkpoint_true "Script hivpn in crontab"
else else
checkpoint_false "Script hirkn in crontab" checkpoint_false "Script hivpn in crontab"
echo "Script is not enabled in crontab. Check: crontab -l" echo "Script is not enabled in crontab. Check: crontab -l"
fi fi
else else
checkpoint_false "Script hirkn" checkpoint_false "Script hivpn"
echo "Script don't exists in $HIRKN. If you don't use old hirkn script, it's OK" echo "Script don't exists in $HIVPN. If you don't use old hivpn script, it's OK"
fi fi
# getdomains script # getdomains script
@@ -406,7 +406,7 @@ fi
if [[ "$1" == dump ]]; then if [[ "$1" == dump ]]; then
printf "\033[36;1mCreate dump without private variables\033[0m\n" printf "\033[36;1mCreate dump without private variables\033[0m\n"
date > $DUMP date > $DUMP
$HIRKN start >> $DUMP 2>&1 $HIVPN start >> $DUMP 2>&1
$GETDOMAINS start >> $DUMP 2>&1 $GETDOMAINS start >> $DUMP 2>&1
uci show firewall >> $DUMP uci show firewall >> $DUMP
uci show network | sed -r 's/(.*private_key=|.*preshared_key=|.*public_key=|.*endpoint_host=|.*wan.ipaddr=|.*wan.netmask=|.*wan.gateway=|.*wan.dns|.*.macaddr=).*/\1REMOVED/' >> $DUMP uci show network | sed -r 's/(.*private_key=|.*preshared_key=|.*public_key=|.*endpoint_host=|.*wan.ipaddr=|.*wan.netmask=|.*wan.gateway=|.*wan.dns|.*.macaddr=).*/\1REMOVED/' >> $DUMP

View File

@@ -9,13 +9,13 @@ check_repo() {
route_vpn () { route_vpn () {
if [ "$TUNNEL" == wg ]; then if [ "$TUNNEL" == wg ]; then
cat << EOF > /etc/hotplug.d/iface/30-rknroute cat << EOF > /etc/hotplug.d/iface/30-vpnroute
#!/bin/sh #!/bin/sh
ip route add table vpn default dev wg0 ip route add table vpn default dev wg0
EOF EOF
elif [ "$TUNNEL" == singbox ] || [ "$TUNNEL" == ovpn ] || [ "$TUNNEL" == tun2socks ]; then elif [ "$TUNNEL" == singbox ] || [ "$TUNNEL" == ovpn ] || [ "$TUNNEL" == tun2socks ]; then
cat << EOF > /etc/hotplug.d/iface/30-rknroute cat << EOF > /etc/hotplug.d/iface/30-vpnroute
#!/bin/sh #!/bin/sh
sleep 10 sleep 10
@@ -563,8 +563,8 @@ VERSION_ID=$(grep VERSION_ID /etc/os-release | awk -F '"' '{print $2}' | awk -F.
if [ "$VERSION_ID" -ne 23 ]; then if [ "$VERSION_ID" -ne 23 ]; then
printf "\033[31;1mScript only support OpenWrt 23.05\033[0m\n" printf "\033[31;1mScript only support OpenWrt 23.05\033[0m\n"
echo "For OpenWrt 21.02 and 22.03 you can:" echo "For OpenWrt 21.02 and 22.03 you can:"
echo "1) Use ansible https://github.com/itdoginfo/ansible-openwrt-hirkn" echo "1) Use ansible https://github.com/itdoginfo/domain-routing-openwrt"
echo "2) Configure manually. Old manual: https://itdog.info/tochechnyj-obhod-blokirovok-rkn-na-routere-s-openwrt-s-pomoshhyu-wireguard-i-dnscrypt/" echo "2) Configure manually. Old manual: https://itdog.info/tochechnaya-marshrutizaciya-na-routere-s-openwrt-wireguard-i-dnscrypt/"
exit 1 exit 1
fi fi

View File

@@ -133,8 +133,8 @@
- name: Route for vpn table - name: Route for vpn table
template: template:
src: "{{ ansible_template_dir }}openwrt-30-rknroute.j2" src: "{{ ansible_template_dir }}openwrt-30-vpnroute.j2"
dest: "/etc/hotplug.d/iface/30-rknroute" dest: "/etc/hotplug.d/iface/30-vpnroute"
mode: 0644 mode: 0644
- name: Check string in rt_tables - name: Check string in rt_tables