Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add using hotplug, init.d and procd OpenWrt system. Do not more need … #2

Open
wants to merge 48 commits into
base: master
Choose a base branch
from

Conversation

ilya-fedin
Copy link
Contributor

…cron and usbreset, using reconnect! And also, autoupdate ban list on reconnect!

@derlaft
Copy link

derlaft commented Oct 17, 2016

У модифицированных прошивок есть telnet. К сожалению, нельзя командой выполнить перезагрузку. Можно поставить питон и написать скрипт... Но разве роутер - место для траты памяти? Да и я не умею программировать на питоне, потому едем дальше

echo -e "login\npassword\nreboot" | nc 192.168.8.1 23

Так пробовал?


/etc/init.d/yotaban enabled && {
[ -f /tmp/yotaban ] && {
# remove old records
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если список изменился, старые записи таким методом не удалятся.
Чтобы избежать этой проблемы в TTLMaster для Android я создавал отдельную новую цепочку со всеми правилами дропа. И когда нужно, польностью её обнулял.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тем не менее, у меня это работает. Но у меня удален из прошивки фарйволл, потому более ничего iptables не трогает.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну да, работать-то будет, проблема не в этом. Проблема в том, что мы удалим одну запись из списка, обновим его и перезапустим этот скрипт -- удаленная запись останется в правилах.

Copy link
Contributor Author

@ilya-fedin ilya-fedin Oct 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Попробовал ваш способ для записи в telnet - нет, не работает

Copy link

@derlaft derlaft Oct 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может быть так?

(echo root; echo root; echo reboot) | while read s; do echo "$s"; sleep 1; done | nc 192.168.1.1 23

Copy link
Contributor Author

@ilya-fedin ilya-fedin Nov 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Работает, несколько упростил:
echo reboot | busybox nc -w 1 -i 1 192.168.8.1 23
Но в OpenWrt как всегда по дефолту не добавлены эти ключи, пришлось городить костыль:

(echo reboot; sleep 1) | nc 192.168.8.1 23 & (sleep 1; kill `pidof $(ps | grep 'nc 192.168.8.1 23' | grep -v 'grep')`)

Кстати, я сделал пакеты и конфиг написал, сейчас дополнил телнетом.

content=$(wget captive.apple.com -q -O -)
if [ `echo $content | grep -c "tethering.svg" ` -gt 0 ]
then
usbreset "HUAWEI Mobile"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может быть использовать конфиг-файл для определения метода перезагрузки? Тогда можно было бы скрипты полностью уже собранным opkg-пакетом дистрибьютить.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я пока конфиг-файлы не писал. Посмотрю, идея хорошая.

Copy link

@derlaft derlaft Oct 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ОК. Помогу по мере возможности, спрашивай, если что: баш знаю хорошо, но к openwrt у меня сейчас доступа нет.

adbport="`uci -q get yota.@yotareboot[0].adbport`"
ttydevice="`uci -q get yota.@yotareboot[0].ttydevice`"
usbreset="`uci -q get yota.@yotareboot[0].usbreset`"
method="`uci -q get yota.@reboot[0].method`"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Какая-то задница. Так лучше не делать.

method=$(uci -q get yota.@reboot[0].method)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему? Они же индентичны...

@derlaft
Copy link

derlaft commented Nov 21, 2016

Бинарники, да еще и зазипованные, в гите -- bad practice, тем более, со скриптами, которые лежат в репе :(

По-хорошему -- все это нужно в github-релизы выкладывать. @kolyanok дадим ему доступ к репе? В целом все выглядит хорошо

В идеале -- могу билд-ферму поднять, чтобы после каждого коммита собирало скрипты в zip и openwrt-пакеты

@derlaft derlaft mentioned this pull request Nov 21, 2016
@derlaft
Copy link

derlaft commented Nov 21, 2016

А, чорт, уже приглашен. Тогда поднимаю билдферму и мержу

@derlaft
Copy link

derlaft commented Nov 21, 2016

@ilya-fedin подскажи только, как собственно собирать пакеты

@ilya-fedin
Copy link
Contributor Author

ilya-fedin commented Nov 22, 2016

@derlaft нужно брать OpenWrt Buildroot (который у меня уже есть, т. к. я собираю прошивки), добавлять папку со скриптами в package (в соответствующую подпапку, в нашем случае package/network/utils), для сборки - make package/yota/compile, но скорее всего сначала придётся полностью скомпилить мир (make world), у меня он уже скомпилен был. Разумеется, нужно через make menuconfig отмечать пакеты хотя бы как M, а то не будут компилиться

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants