mirror of
https://github.com/itdoginfo/ansible-openwrt-hirkn.git
synced 2025-12-11 17:44:29 +05:00
(・x・)
This commit is contained in:
32
README.md
32
README.md
@@ -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
|
||||
git clone https://github.com/itdoginfo/ansible-openwrt-hirkn
|
||||
mv ansible-openwrt-hirkn/* .
|
||||
rm -rf ansible-openwrt-hirkn README.md
|
||||
git clone https://github.com/itdoginfo/domain-routing-openwrt
|
||||
mv domain-routing-openwrt/* .
|
||||
rm -rf domain-routing-openwrt README.md
|
||||
```
|
||||
|
||||
Добавить роутер в файл hosts в группу openwrt
|
||||
@@ -116,7 +116,7 @@ rm -rf ansible-openwrt-hirkn README.md
|
||||
192.168.1.1
|
||||
```
|
||||
|
||||
Подставить переменные в **hirkn.yml**
|
||||
Подставить переменные в **hivpn.yml**
|
||||
|
||||
Для работы Ansible c OpenWrt необходимо, чтоб было выполнено одно из условий:
|
||||
- Отсутствие пароля для root (не рекомендуется)
|
||||
@@ -124,12 +124,12 @@ rm -rf ansible-openwrt-hirkn README.md
|
||||
|
||||
Запуск 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 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
|
||||
```
|
||||
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
|
||||
```
|
||||
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
|
||||
chmod +x check-hirkn.sh
|
||||
./check-hirkn.sh
|
||||
wget https://raw.githubusercontent.com/itdoginfo/domain-routing-openwrt/master/getdomains-check.sh
|
||||
chmod +x getdomains-check.sh
|
||||
./getdomains-check.sh
|
||||
```
|
||||
|
||||
С созданием dump
|
||||
```
|
||||
./check-hirkn.sh dump
|
||||
./getdomains-check.sh dump
|
||||
```
|
||||
|
||||
Поиск ошибок вручную: https://habr.com/ru/post/702388/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
HIRKN=/etc/init.d/hirkn
|
||||
HIVPN=/etc/init.d/hivpn
|
||||
GETDOMAINS=/etc/init.d/getdomains
|
||||
DUMP=/tmp/dump.txt
|
||||
|
||||
@@ -326,18 +326,18 @@ else
|
||||
output_21
|
||||
fi
|
||||
|
||||
# hirkn script
|
||||
if [ -s "$HIRKN" ]; then
|
||||
checkpoint_true "Script hirkn"
|
||||
if crontab -l | grep -q $HIRKN; then
|
||||
checkpoint_true "Script hirkn in crontab"
|
||||
# hivpn script
|
||||
if [ -s "$HIVPN" ]; then
|
||||
checkpoint_true "Script hivpn"
|
||||
if crontab -l | grep -q $HIVPN; then
|
||||
checkpoint_true "Script hivpn in crontab"
|
||||
else
|
||||
checkpoint_false "Script hirkn in crontab"
|
||||
checkpoint_false "Script hivpn in crontab"
|
||||
echo "Script is not enabled in crontab. Check: crontab -l"
|
||||
fi
|
||||
else
|
||||
checkpoint_false "Script hirkn"
|
||||
echo "Script don't exists in $HIRKN. If you don't use old hirkn script, it's OK"
|
||||
checkpoint_false "Script hivpn"
|
||||
echo "Script don't exists in $HIVPN. If you don't use old hivpn script, it's OK"
|
||||
fi
|
||||
|
||||
# getdomains script
|
||||
@@ -406,7 +406,7 @@ fi
|
||||
if [[ "$1" == dump ]]; then
|
||||
printf "\033[36;1mCreate dump without private variables\033[0m\n"
|
||||
date > $DUMP
|
||||
$HIRKN start >> $DUMP 2>&1
|
||||
$HIVPN start >> $DUMP 2>&1
|
||||
$GETDOMAINS start >> $DUMP 2>&1
|
||||
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
|
||||
|
||||
@@ -9,13 +9,13 @@ check_repo() {
|
||||
|
||||
route_vpn () {
|
||||
if [ "$TUNNEL" == wg ]; then
|
||||
cat << EOF > /etc/hotplug.d/iface/30-rknroute
|
||||
cat << EOF > /etc/hotplug.d/iface/30-vpnroute
|
||||
#!/bin/sh
|
||||
|
||||
ip route add table vpn default dev wg0
|
||||
EOF
|
||||
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
|
||||
|
||||
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
|
||||
printf "\033[31;1mScript only support OpenWrt 23.05\033[0m\n"
|
||||
echo "For OpenWrt 21.02 and 22.03 you can:"
|
||||
echo "1) Use ansible https://github.com/itdoginfo/ansible-openwrt-hirkn"
|
||||
echo "2) Configure manually. Old manual: https://itdog.info/tochechnyj-obhod-blokirovok-rkn-na-routere-s-openwrt-s-pomoshhyu-wireguard-i-dnscrypt/"
|
||||
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/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -133,8 +133,8 @@
|
||||
|
||||
- name: Route for vpn table
|
||||
template:
|
||||
src: "{{ ansible_template_dir }}openwrt-30-rknroute.j2"
|
||||
dest: "/etc/hotplug.d/iface/30-rknroute"
|
||||
src: "{{ ansible_template_dir }}openwrt-30-vpnroute.j2"
|
||||
dest: "/etc/hotplug.d/iface/30-vpnroute"
|
||||
mode: 0644
|
||||
|
||||
- name: Check string in rt_tables
|
||||
Reference in New Issue
Block a user