Closed acolombi closed 3 years ago
@acolombi I took a look at this today, but I'm not seeing an easy way to get this one-liner to fail as is if curl
doesn't exist without writing a temporary file.
You can add set -o pipefail
, if you are using bash
or a compatible shell, to exit non-zero if a piped command fails. Would that suffice for you?
I noted that homebrew does:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
but this would still exit 0 if curl
doesn't exist given the failure is in a subshell.
fluentd
does the same as us:
curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-focal-td-agent4.sh | sh
I'm open to other ideas here though 😄
The shell my Docker build process is running is sh
sadly, so set -o pipefail
isn't helpful for me in this context. Also, tbh, fixing this is more for the next person than me.
I wish I was a shell guru, and maybe I'd have some ideas for you... If you think it's impossible I think it's reasonable to close this as a "won't fix".
Thanks for looking!
Thanks @acolombi ! I'll close this, but we can see if anything comes up in the future.
For codifying vector installs I'd probably lean towards doing it directly. For example, on Debian this would be something like:
curl -1sLf 'https://repositories.timber.io/public/vector/gpg.3543DB2D0A2BC4B8.key' | apt-key add -
curl -1sLf 'https://repositories.timber.io/public/vector/config.deb.txt?distro=ubuntu&codename=xenial' > /etc/apt/sources.list.d/timber-vector.list
apt-get update
apt install vector
It sounds like you are using a stripped down image if it only has sh
so in your case it'd probably just be downloading the tarball and extracting it where desired.
The shell script is useful to get up and running quickly though.
Version: 0.13 OS: Debian 10 Shell: bash
When I run the install for machines,
If
curl
is missing, the exit code for this command is still 0 (i.e. success!). Obviously the command failed, butsh -s -- -y
is obfuscating this fact. This makes including this script in installs brittle, because it may fail silently.Additional Context
I noticed this when adding vector install to a Dockerfile, i.e.
in a Dockerfile. The Docker build completed "successfully", but vector was missing. Solution was to install curl first.