zw963 / asuswrt-merlin-v2ray

Use Asuswrt Merlin as a transparent proxy, powered by V2Ray
MIT License
60 stars 12 forks source link

deploy_router script not working on Asus Merlin 386.7.2 anymore #8

Closed roshan-riazi closed 2 years ago

roshan-riazi commented 2 years ago

Using both release version and also the latest codes, deploy_router script gets stuck after binary file(s) (v2ray-linux*.zip) have been copied to the router. As far as I can tell, the problem is with "SSH $target bash" commands and "bash <<< ..." syntax. Also (on release version) when I stop that, the next ssh returns "bash: syntax error: unexpected redirection" error (which also seems to be related to "bash <<< ..." syntax).

Tested with: Asus RT-AC86U running Asus merlin 386.7.2, fresh Install with Entware and USB Swap. Predownloaded binary is v2ray-linux-arm64-v8a.zip with v4.45.2 which installs easily on AC86U. Release version code (v4.44.0) and and latest codes from git both have this problem. Note that Release version uses a separete deploy_start.sh but latest codes from git use "https://gitlab.com/zw963/deployment_bash/-/raw/v0.8.3/deploy_start.sh" and this problem is persistent with both of them.

As far as I checked, if I use fresh install (+ Entware and Swap file), "bash --version" on router will not output anything. Also it seems that bash is the default shell ("echo $0" returns "bash") and "which bash" returns "/bin/bash".

Terminal Log:

./deploy_router admin@192.168.1.1 admin@192.168.1.1's password: admin@192.168.1.1's password: v2ray.json 100% 1571 820.9KB/s 00:00
admin@192.168.1.1's password: apply_iptables_rule.sh 100% 6816 2.5MB/s 00:00
admin@192.168.1.1's password: clean_iptables_rule.sh 100% 1314 619.6KB/s 00:00
admin@192.168.1.1's password: enable_swap.sh 100% 482 313.0KB/s 00:00
admin@192.168.1.1's password: update_geosite.sh 100% 803 394.5KB/s 00:00
admin@192.168.1.1's password: update_big_geosite.sh 100% 813 474.9KB/s 00:00
admin@192.168.1.1's password: restart_dnsmasq.sh 100% 156 100.9KB/s 00:00
admin@192.168.1.1's password: toggle_proxy.sh 100% 5873 1.1MB/s 00:00
admin@192.168.1.1's password: patch_router 100% 269 140.3KB/s 00:00
admin@192.168.1.1's password: check_google_use_proxy.sh 100% 113 50.3KB/s 00:00
admin@192.168.1.1's password: check_google_use_socks5.sh 100% 146 83.9KB/s 00:00
admin@192.168.1.1's password: debug_v2ray.sh 100% 989 480.0KB/s 00:00
Copy predownloaded binary to router ... admin@192.168.1.1's password: admin@192.168.1.1's password: v2ray-linux-arm64-v8a.zip 100% 12MB 7.1MB/s 00:01
roshan@192.168.1.1's password: c admin@192.168.1.1's password: bash: syntax error: unexpected redirection

roshan-riazi commented 2 years ago

Also, as far as I can understand, you don't need to unzip and copy xray binary file on router (you are not using it in your router related codes later).

roshan-riazi commented 2 years ago

Another thing that may help is that when I manually install "perl" using Entware (opkg install perl), default shell on router changes to "sh" ("echo $0" returns "sh").

roshan-riazi commented 2 years ago

Solved! I installed bash using Entware (opkg install bash) which made "which bash" equal to "/opt/bin/bash". After that, in the deploy_start.sh I replaced two instances of "ssh $target bash ..." with "ssh $target /opt/bin/bash ...". It seems that my router (actually newer merlin firmwares, because I tried it many times from fresh install) had problems with bash reference.