gravitl / netmaker

Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks.
https://netmaker.io
Other
9.5k stars 552 forks source link

[Bug]: Openwrt - mips arch - /sbin/netclient: line 1: syntax error: unexpected "(" error #1733

Open TimDowker opened 2 years ago

TimDowker commented 2 years ago

Contact Details

No response

What happened?

2 bugs really.

1 - The install script for mips on Openwrt calls a URL for "latest" (line 76 of the netclient-install.sh script) ie "url="https://github.com/gravitl/netmaker/releases/download/$VERSION/$dist" but "latest" doesn't exist - had to hard code "v0.16.3" into the URL to get it to work.

2 - The netclient executable produces the error "/sbin/netclient: line 1: syntax error: unexpected "("" continuously in the log file /tmp/netclient.logs. Tried restarting the proc - no go. Tried joining a network with "netclient join -t " - no go.

Version

Not listed

What OS are you using?

Unlisted

Relevant log output

/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("
/sbin/netclient: line 1: syntax error: unexpected "("

Contributing guidelines

mattkasun commented 2 years ago

check the file type of the 'netclient' file you downloaded.. I suspect it is not a binary but a text file.

TimDowker commented 2 years ago

It appears to be a binary file - see screenshot attached when I tried to open it in vscode.

Screenshot 2022-11-11 at 10 49 16 AM
mattkasun commented 2 years ago

run file /sbin/netclient

TimDowker commented 2 years ago

Returns "-ash: file: not found"

TimDowker commented 2 years ago

I downloaded the same file to my desktop and ran the file command on it and it returned the following

netclient-mips: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), statically linked, Go BuildID=kwVB84ITCZWtKwztk3La/zhxYcqkXBRXJ0VCJvhlG/SYjWYzO6gz7djz75OadI/9gTxvV_AZPnu0Olpuf4y, stripped

mattkasun commented 2 years ago

looks like a bad build .... the mips binary was a recent community contributionn.

TimDowker commented 2 years ago

Ok - I've trid cloning the v0.16.3 repo and compiling the binary myself but it isn't working and fixing the issue is beyond my expertise. I'll have to wait until the binary gets fixed.

TimDowker commented 2 years ago

figured it out - cloned v0.16.3 repo - then the following line in the bin-maker.sh script needed to be modified. It was compiling mipsle versions only for mips arch. GOARM=$_goarm GOMIPS=softfloat GOARCH=mipsle GOOS=$_goose GOHOSTARCH=$__HOST_ARCH CGO_ENABLED=0 go build -ldflags="-X 'main.version=$VERSION'" -o $_out

Changed GOARCH=mipsle to GOARCH=mips and re-ran the script - new binary version seems to run but it has now crashed my openwrt router so...

shan100github commented 1 year ago

@TimDowker , could you share uname & cat /etc/os-release output. Also, I would recommend checking https://github.com/gravitl/netmaker/blob/develop/netclient/bin-maker.sh#L23-L28

Recent PR merged for mips support is https://github.com/gravitl/netmaker/pull/1681

TimDowker commented 1 year ago

uname = Linux uname -a = Linux Router 5.10.146 #0 Fri Oct 14 22:44:41 2022 mips GNU/Linux cat /etc/os-release = NAME="OpenWrt" VERSION="22.03.2" ID="openwrt" ID_LIKE="lede openwrt" PRETTY_NAME="OpenWrt 22.03.2" VERSION_ID="22.03.2" HOME_URL="https://openwrt.org/" BUG_URL="https://bugs.openwrt.org/" SUPPORT_URL="https://forum.openwrt.org/" BUILD_ID="r19803-9a599fee93" OPENWRT_BOARD="ath79/generic" OPENWRT_ARCH="mips_24kc" OPENWRT_TAINTS="" OPENWRT_DEVICE_MANUFACTURER="OpenWrt" OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/" OPENWRT_DEVICE_PRODUCT="Generic" OPENWRT_DEVICE_REVISION="v0" OPENWRT_RELEASE="OpenWrt 22.03.2 r19803-9a599fee93"

shan100github commented 1 year ago

@TimDowker, could you please share the device model too for reference?

Try to use https://github.com/gravitl/netmaker/blob/develop/scripts/netclient-install.sh, to install Netclient on your device. Still, if you face trouble try to replace Netclient binary manually from https://github.com/gravitl/netmaker/releases/download/v0.16.3/netclient-mips or https://github.com/gravitl/netmaker/releases/download/v0.16.3/netclient-mips-upx

I believe the above steps will help resolve your issue.

TimDowker commented 1 year ago

The device is a TP-Link Archer C7 v5 running OpenWrt 22.03.2 r19803-9a599fee93 / LuCI openwrt-22.03 branch git-22.304.65171-ec905e6 with kernel version 5.10.146

I've tried the netclient-install.sh script - no go - like I said - had to modify it to work properly (see above).

The binary's also do not work - see above.

shan100github commented 1 year ago

@TimDowker , device I have tested has "Little Endian" architecture

>> lscpu
Architecture:        mips
Byte Order:          Little Endian

could you post the output for lscpu

TimDowker commented 1 year ago

root@Router:~# lscpu Architecture: mips Byte Order: Big Endian CPU(s): 1 On-line CPU(s) list: 0 Model: MIPS 74Kc V5.0 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 1 BogoMIPS: 385.84 Flags: mips16 dsp dsp2 Caches (sum of all):
L1d: 32 KiB (1 instance) L1i: 64 KiB (1 instance)

TimDowker commented 1 year ago

Device model is a TP-Link Archer C7 v5 ruuning OpenWrt 22.03.2 r19803-9a599fee93 / LuCI openwrt-22.03 branch git-22.304.65171-ec905e6

TimDowker commented 1 year ago

Both the netclient-mips and netclient-mips-upx are both still giving the same error ./netclient-mips: line 1: syntax error: unexpected "("

shan100github commented 1 year ago

@TimDowker , yes, as you mentioned earlier for "Big Endian" netclient binary to be generated with GOARCH=mips and GOMIPS=softfloat

I have installed OpenWrt in one of my old D-Link Router, it seems to be "Big Endian" and helped me to make the pull request https://github.com/gravitl/netmaker/pull/1756 .

Let's see if someone comes with a different device & test other binaries.

Bizarrus commented 1 week ago
line 1: syntax error: unexpected "("

says, that you using the bad compiled target version. If you get these error message, use the little endian version of mips. Most IoT Mips-CPU's using these.