forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaddy.sh
More file actions
executable file
·37 lines (29 loc) · 845 Bytes
/
caddy.sh
File metadata and controls
executable file
·37 lines (29 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
set -euf -o pipefail
pushd "$(dirname "${BASH_SOURCE[0]}")/.." > /dev/null
mkdir -p .bin
version="2.0.0-rc.1"
case "$(go env GOOS)" in
linux)
os="Linux"
;;
darwin)
os="macOS"
;;
esac
name="caddy_${version}_${os}_x86_64"
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
if [ ${SOURCEGRAPH_HTTPS_PORT:-"3443"} -lt 1000 ] && ! [ $(id -u) = 0 ] && hash authbind; then
# Support using authbind to bind to port 443 as non-root
exec authbind "${target}" "$@"
else
exec "${target}" "$@"
fi