Last active
February 14, 2023 01:32
-
-
Save top4ek/0c3de14a73f0313221522430407e9d83 to your computer and use it in GitHub Desktop.
My Zyxel Keenetic scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
[ "$table" != "filter" ] && exit 0 | |
/opt/sbin/iptables -A FORWARD -i tun0 -s 10.8.0.0/24 -j ACCEPT | |
/opt/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT | |
/opt/sbin/iptables -t nat -I POSTROUTING -o ppp0 -s 10.8.0.0/24 -j MASQUERADE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Send message to user via bot | |
token='11111111:11111111111111111111111111111111111' | |
id=11111111 | |
curl "https://api.telegram.org/bot${token}/sendMessage?chat_id=${id}&parse_mode=markdown" --data-urlencode "text=*$1* $2" > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Update NS at pdd.yandex.ru | |
token="11111111111111111111111111111111111111111111111111111111" | |
domain="domain.tld" | |
subdomain="subdomain" | |
record_id="11111111" | |
curl -k "https://pddimp.yandex.ru/nsapi/edit_a_record.xml?token=${token}&domain=${domain}&subdomain=${subdomain}&record_id=${record_id}&content=$1" > /dev/null | |
/opt/home/tg_send.sh "Updated pdd.yandex:" $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Reconnect WAN until white IP received(hello Rostelecom) | |
interface_port=ppp0 | |
interface_name=PPPoE0 | |
interface_thru=ISP-Vlan | |
counter=/opt/tmp/wan_reconnect_counter.txt | |
max_tries=20 | |
[ ! "$interface" == "${interface_port}" ] && exit 0 | |
/opt/home/tg_send.sh "WAN is up: " $address | |
_ip=$(echo $address | grep -v -E "(^100\.6[4-9]\.|^100\.[7-9][0-9]\.|^100\.1[0-1][0-9]\.|^100\.12[0-7]\.)") | |
if [ -z ${_ip} ]; then | |
[ -f "$counter" ] || echo '0' > $counter | |
try_nr="$(cat $counter)" | |
try_nr=$((try_nr+1)) | |
if [ $try_nr -gt $max_tries ]; then | |
echo '0' > $counter | |
/opt/home/tg_send.sh 'Giving up to get real IP.' | |
exit | |
fi | |
/opt/home/tg_send.sh "Force reconnect to get real IP:" "$try_nr/$max_tries" | |
echo "$try_nr" > $counter | |
/opt/home/fn_led.sh on | |
ndmq -p "no interface ${interface_name} connect via ${interface_thru}" | |
sleep 5 | |
ndmq -p "interface ${interface_name} connect via ${interface_thru}" | |
/opt/home/fn_led.sh off | |
else | |
echo '0' > $counter | |
/opt/home/update_pdd.sh $address | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx. 🖖🏽
Looks good 👍🏾