mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 18:31:54 +00:00
fix(sg): start Caddy admin before `caddy trust` From docs: This command will attempt to connect to Caddy's admin API to fetch the root certificate, using the GET /pki/ca/<id>/certificates endpoint. If the admin server is not running at the moment, the GET request will not succeed, and the certificate won't be installed correctly.
35 lines
668 B
Bash
Executable File
35 lines
668 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euf -o pipefail
|
|
|
|
pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null
|
|
|
|
mkdir -p .bin
|
|
|
|
version="2.7.3"
|
|
case "$(go env GOOS)" in
|
|
linux)
|
|
os="linux"
|
|
;;
|
|
darwin)
|
|
os="mac"
|
|
;;
|
|
esac
|
|
name="caddy_${version}_${os}_$(go env GOARCH)"
|
|
target="$PWD/.bin/${name}"
|
|
url="https://github.com/caddyserver/caddy/releases/download/v${version}/${name}.tar.gz"
|
|
|
|
if [ ! -f "${target}" ]; then
|
|
echo "downloading ${url}" 1>&2
|
|
curl -sS -L -f "${url}" | tar -xz --to-stdout "caddy" >"${target}.tmp"
|
|
mv "${target}.tmp" "${target}"
|
|
fi
|
|
|
|
chmod +x "${target}"
|
|
|
|
popd >/dev/null
|
|
|
|
trap '${target} stop' EXIT SIGINT
|
|
eval "${target} start"
|
|
"${target}" "$@"
|