Skip to content
This repository was archived by the owner on Jan 17, 2021. It is now read-only.

Incompatible with wget from BusyBox #102

Closed
SteveEdson opened this issue May 12, 2019 · 10 comments · Fixed by #125
Closed

Incompatible with wget from BusyBox #102

SteveEdson opened this issue May 12, 2019 · 10 comments · Fixed by #125

Comments

@SteveEdson
Copy link

Trying to use this against my Alpine Linux server, but receive the following error:

2019-05-12 15:07:05 INFO	ensuring code-server is updated...
+ mkdir -p /home/steve/.local/share/code-server
+ cd /tmp
+ wget -N https://codesrv-ci.cdr.sh/latest-linux
wget: unrecognized option: N
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.

Usage: wget [-c|--continue] [--spider] [-q|--quiet] [-O|--output-document FILE]
	[--header 'header: value'] [-Y|--proxy on/off] [-P DIR]
	[-S|--server-response] [-U|--user-agent AGENT] [-T SEC] URL...

Retrieve files via HTTP or FTP

	--spider	Only check URL existence: $? is 0 if exists
	-c		Continue retrieval of aborted transfer
	-q		Quiet
	-P DIR		Save to DIR (default .)
	-S    		Show server response
	-T SEC		Network read timeout is SEC seconds
	-O FILE		Save to FILE ('-' for stdout)
	-U STR		Use STR for User-Agent header
	-Y on/off	Use proxy
2019-05-12 15:07:06 FATAL	failed to update code-server: exit status 1
---ssh cmd---
ssh  [email protected] /bin/bash
---download script---
set -euxo pipefail || exit 1

mkdir -p ~/.local/share/code-server
cd /tmp
wget -N https://codesrv-ci.cdr.sh/latest-linux
[ -f /tmp/codessh-code-server ] && rm /tmp/codessh-code-server
ln latest-linux /tmp/codessh-code-server
chmod +x /tmp/codessh-code-server

It looks like alpine uses a different wget version, any way to detect and fix this?

Thanks

@teddy-codes
Copy link
Contributor

We could possibly add a check to see if the file exists initially before running wget. This would allow us to omit the -N flag. Thoughts?

@SteveEdson
Copy link
Author

What does the -N flag do? Is it possible to use curl instead?

If not, checking for the file first might work yeah.

@teddy-codes
Copy link
Contributor

This is from the documentation:

When running Wget without ‘-N’, ‘-nc’, ‘-r’, or ‘-p’, downloading the same file in the same directory will result in the original copy of file being preserved and the second copy being named ‘file.1’.

I think that just changing the arguments around would allow for this to work properly. I am in the midst of opening a PR for it right now.

@teddy-codes teddy-codes mentioned this issue May 13, 2019
@sreya
Copy link
Collaborator

sreya commented May 14, 2019

The -N flag prevents re-downloading a file if it hasn't been modified

@teddy-codes
Copy link
Contributor

Hm, I don't see that in the docs. Do you have a reference? I am pretty sure it downloads again but overwrites based on the quote that I posted earlier.

@sreya
Copy link
Collaborator

sreya commented May 14, 2019

GNU Wget 1.17.1 built on linux-gnu

-N,  --timestamping              don't re-retrieve files unless newer local

@teddy-codes
Copy link
Contributor

teddy-codes commented May 14, 2019

ah, I just saw that actually. @SteveEdson What version of wget are you using?

Edit:

After the conversation that @sreya92 and I had, the PR that I had produced is becoming obsolete in favor of a newer flag (which is --docker).

@SteveEdson
Copy link
Author

It's whatever the default wget is, bundled with BusyBox v1.29.3

@deansheather deansheather changed the title Unable to use with Alpine Incompatible with wget from BusyBox Jun 27, 2019
@deansheather
Copy link
Member

We can use curl with the -z flag to test file modification time. I tested this in alpine:latest with curl installed and it works.

@stokito
Copy link

stokito commented Jan 16, 2021

curl is quite heavy and may not be installed. But bb wget allows to pass custom headers so we can imitate it

FILE=example.txt
wget --header="If-Modified-Since:$(date -R -u -r $FILE | sed 's/\UTC/GMT/')" http://example.com/$FILE
# update or not depending on status code 304

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

Successfully merging a pull request may close this issue.

5 participants