gotify / cli

A command line interface for pushing messages to gotify/server.
MIT License
444 stars 58 forks source link

Gotify CLI on Termux #26

Open mskian opened 5 years ago

mskian commented 5 years ago

I am trying to Run Gotify CLI on Termux Terminal Emulator for Android but Endup with this Below Error while init the CLI

Error: Get https://push.example.com/version: dial tcp: lookup google.com on [::1]:53: read udp [::1]:48773->[::1]:53: read: connection refused
eternal-flame-AD commented 5 years ago

As far as I know, binary built for linux will have name resolving problems on android, and you will need to build the program with GOOS=android and try again

mskian commented 5 years ago

How example pls

eternal-flame-AD commented 5 years ago

Try building with:

CGO_ENABLED=0 GOOS=android GOARCH=amd64 go build
mskian commented 5 years ago

we need to Clone the Github Respo and Build the package for android right?

mskian commented 5 years ago

Got this error

/tmp/go-link-001157295/go.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
eternal-flame-AD commented 5 years ago

Sorry I specified the wrong GOARCH, you need GOARCH=arm64

If it still does not work, try building on termux directly without any extra environment variable.

mskian commented 5 years ago
git clone https://github.com/gotify/cli.git
cd cli

$ CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build

go: finding github.com/go-openapi/errors v0.19.0
go: finding github.com/go-openapi/analysis v0.19.0
go: finding github.com/go-openapi/jsonreference v0.19.0
go: finding github.com/go-openapi/validate v0.19.0
go: finding github.com/go-openapi/strfmt v0.19.0
go: finding github.com/go-openapi/spec v0.19.0
go: finding github.com/go-openapi/runtime v0.19.0
go: finding github.com/go-openapi/jsonpointer v0.19.0
go: finding github.com/go-openapi/loads v0.19.0
go: finding golang.org/x/sys v0.0.0-20190412213103-97732733099d
go: finding golang.org/x/net v0.0.0-20181005035420-146acd28ed58
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/davecgh/go-spew v1.1.1
go: finding golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53
go: finding golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a
go: finding github.com/PuerkitoBio/purell v1.1.0
go: finding github.com/go-openapi/jsonreference v0.18.0
go: finding github.com/stretchr/testify v1.3.0
go: finding golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576
go: finding github.com/PuerkitoBio/purell v1.1.1
go: finding github.com/go-openapi/validate v0.18.0
go: finding golang.org/x/text v0.3.0
go: finding github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
go: finding github.com/go-openapi/spec v0.18.0
go: finding github.com/go-openapi/errors v0.17.0
go: finding github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983
go: finding github.com/go-openapi/spec v0.17.0
go: finding github.com/tj/go-spin v1.1.0
go: finding github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
go: finding github.com/go-openapi/analysis v0.17.0
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding github.com/go-openapi/loads v0.17.0
go: finding github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: finding github.com/mitchellh/mapstructure v1.1.2
go: finding github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329
go: finding github.com/kr/pretty v0.1.0
go: finding github.com/go-openapi/strfmt v0.18.0
go: finding github.com/gotify/go-api-client/v2 v2.0.4
go: finding golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54
go: finding github.com/go-openapi/swag v0.18.0
go: finding gopkg.in/yaml.v2 v2.2.1
go: finding github.com/go-openapi/errors v0.18.0
go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
go: finding golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e
go: finding gopkg.in/urfave/cli.v1 v1.20.0
go: finding github.com/go-openapi/jsonpointer v0.18.0
go: finding github.com/davecgh/go-spew v1.1.0
go: finding github.com/go-openapi/analysis v0.18.0
go: finding github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277
go: finding github.com/stretchr/objx v0.1.0
go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
go: finding github.com/go-openapi/jsonpointer v0.17.0
go: finding github.com/pborman/uuid v1.2.0
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding github.com/go-openapi/swag v0.19.0
go: finding github.com/go-openapi/errors v0.17.2
go: finding github.com/docker/go-units v0.3.3
go: finding github.com/go-openapi/loads v0.18.0
go: finding github.com/google/uuid v1.1.1
go: finding github.com/stretchr/objx v0.1.1
go: finding github.com/go-openapi/jsonreference v0.17.0
go: finding github.com/kr/text v0.1.0
go: finding github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe
go: finding github.com/go-openapi/swag v0.17.0
go: finding golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
go: finding github.com/go-openapi/strfmt v0.17.0
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: finding github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9
go: finding github.com/google/uuid v1.0.0
go: finding github.com/go-openapi/runtime v0.17.2
go: finding github.com/kr/pty v1.1.1
go: finding github.com/go-openapi/validate v0.17.0
go: downloading gopkg.in/urfave/cli.v1 v1.20.0
go: downloading github.com/gotify/go-api-client/v2 v2.0.4
go: extracting gopkg.in/urfave/cli.v1 v1.20.0
go: extracting github.com/gotify/go-api-client/v2 v2.0.4
go: downloading github.com/tj/go-spin v1.1.0
go: downloading github.com/go-openapi/strfmt v0.19.0
go: downloading github.com/go-openapi/swag v0.19.0
go: downloading github.com/go-openapi/runtime v0.19.0
go: downloading golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a
go: extracting github.com/tj/go-spin v1.1.0
go: extracting github.com/go-openapi/strfmt v0.19.0
go: downloading github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
go: extracting github.com/go-openapi/swag v0.19.0
go: extracting github.com/go-openapi/runtime v0.19.0
go: downloading github.com/go-openapi/errors v0.19.0
go: downloading github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
go: downloading gopkg.in/yaml.v2 v2.2.2
go: extracting github.com/go-openapi/errors v0.19.0
go: extracting github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf
go: downloading github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983
go: extracting golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a
go: extracting gopkg.in/yaml.v2 v2.2.2
go: extracting github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: extracting github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983
go: extracting github.com/mitchellh/mapstructure v1.1.2
go: downloading golang.org/x/sys v0.0.0-20190412213103-97732733099d
go: downloading github.com/go-openapi/loads v0.19.0
go: downloading github.com/go-openapi/analysis v0.19.0
go: downloading github.com/go-openapi/validate v0.19.0
go: downloading github.com/go-openapi/spec v0.19.0
go: extracting github.com/go-openapi/analysis v0.19.0
go: extracting github.com/go-openapi/loads v0.19.0
go: downloading github.com/go-openapi/jsonpointer v0.19.0
go: extracting github.com/go-openapi/jsonpointer v0.19.0
go: extracting github.com/go-openapi/spec v0.19.0
go: downloading github.com/go-openapi/jsonreference v0.19.0
go: extracting github.com/go-openapi/jsonreference v0.19.0
go: downloading github.com/PuerkitoBio/purell v1.1.1
go: extracting golang.org/x/sys v0.0.0-20190412213103-97732733099d
go: extracting github.com/go-openapi/validate v0.19.0
go: extracting github.com/PuerkitoBio/purell v1.1.1
go: downloading golang.org/x/text v0.3.0
go: downloading golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
go: downloading github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: extracting github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
go: extracting golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
go: extracting golang.org/x/text v0.3.0
# github.com/gotify/cli/v2
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/usr/bin/ld: /tmp/go-link-961218562/go.o: Relocations in generic ELF (EM: 183)
/tmp/go-link-961218562/go.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status

My System INFO - Ubuntu 18.04 LTS Golang version - go version go1.12.5 linux/amd64

jmattheis commented 5 years ago

Here it is recommended to compile the go program in your termux environment https://github.com/termux/termux-app/issues/210#issuecomment-265733873

mskian commented 5 years ago

Gotify CLI having any specific file to build the complete package?

jmattheis commented 5 years ago

go build should be enough, there are no extra steps.

mskian commented 5 years ago

Let me try and Update

jmattheis commented 5 years ago

Dns lookup works if the cli is compiled on termux. image

mskian commented 5 years ago

Got this Error

$ go build

photo_2019-05-20_22-19-14

mskian commented 5 years ago

@jmattheis Share your steps how you achieve in Termux

jmattheis commented 5 years ago

I just did:

pkg install golang git
git clone https://github.com/gotify/cli
cd cli
go build
./cli init
mskian commented 5 years ago

For me, it's not Building I am facing error check above screenshot

jmattheis commented 5 years ago

Could you try a system upgrade (pkg upgrade) and try again. If it still doesn't work, could you paste the outputs of the following commands:

go env
go version
gcc --version

With android version do you have?

mskian commented 5 years ago

photo_2019-05-20_23-24-55

Android Version - 8.1.0

jmattheis commented 5 years ago

I've android 9.

I'm out of ideas now, could be a Go bug.

mskian commented 5 years ago

@jmattheis yes may be 4 hours no proper solution for this issue

mskian commented 5 years ago

This Method works well

pkg install golang
go get github.com/gotify/cli

Binary File Stored in Home /go/bin/cli

cd $HOME
cd go
cd bin
cp cli $HOME
cd $HOME
mv cli gotify
## Setup Gotify
./gotify init
mv gotify $PREFIX/bin
## test Gotify
gotify config

My issue ticket in Termux Respo https://github.com/termux/termux-app/issues/1138

mskian commented 5 years ago

Why these all three are unknown?

$ gotify version
version: unknown
commit: unknown
BuildDate: unknow
eternal-flame-AD commented 5 years ago

These information are replaced on link time with a linker flag. You can refer to Makefile to see how we did that.

mskian commented 5 years ago

Now got it Thanks Kindly Release binary compiled for Android too (For Termux)