mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +01:00
add a docker fetch script for conveniently downloading the compose project files
This commit is contained in:
parent
adbbda3911
commit
1126d5e6c4
@ -5,7 +5,7 @@
|
||||
|
||||
The quickstart makes these assumptions about your global DNS configuration.
|
||||
|
||||
1. A Caddy DNS plugin is available for your DNS provider (see [github.com/caddy-dns](https://github.com/caddy-dns))
|
||||
1. A Caddy DNS plugin is available for your DNS provider (see [github.com/caddy-dns](https://github.com/orgs/caddy-dns/repositories?type=all&q=sort%3Aname-asc))
|
||||
1. You have designated A DNS zone for zrok, e.g. `example.com` or `share.example.com` and created (and delegated, if necessary) the zone on your DNS provider's platform.
|
||||
1. A wildcard record exists for the IP address where the zrok instance will run, e.g. if your DNS zone is `share.example.com`, then your wildcard record is `*.share.example.com`.
|
||||
1. You have created an API token in your DNS provider's platform and the token has permission to create DNS records in the DNS zone.
|
||||
@ -14,7 +14,23 @@ The quickstart makes these assumptions about your global DNS configuration.
|
||||
|
||||
Create a working directory on your Docker host and save these Docker Compose project files. A OpenZiti network is provided by the "quickstart" container and is managed exclusively by zrok.
|
||||
|
||||
1. Get the ziti quickstart Compose file.
|
||||
#### Shortcut option
|
||||
|
||||
1. Run this script to download the files.
|
||||
|
||||
```bash
|
||||
curl https://get.openziti.io/zrok-docker/fetch.bash | bash
|
||||
```
|
||||
|
||||
Optionally, customize the install path instead of using the current directory.
|
||||
|
||||
```bash
|
||||
curl https://get.openziti.io/zrok-docker/fetch.bash | bash -s /path/to/install
|
||||
```
|
||||
|
||||
#### Do it Yourself
|
||||
|
||||
1. Fetch the ziti quickstart Compose file.
|
||||
|
||||
```bash
|
||||
wget https://get.openziti.io/dock/all-in-one/compose.yml
|
||||
|
86
docker/compose/zrok-instance/fetch.bash
Executable file
86
docker/compose/zrok-instance/fetch.bash
Executable file
@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
set -o xtrace
|
||||
|
||||
requireBashVersion() {
|
||||
if (( "${BASH_VERSION%%.*}" < 4 )); then
|
||||
echo "This script requires Bash major version 4 or greater."
|
||||
echo "Detected version: $BASH_VERSION"
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
fetchFile() {
|
||||
|
||||
local url="${1}"
|
||||
local path="${2}"
|
||||
|
||||
if [[ -s "$path" ]]; then
|
||||
echo "ERROR: file already exists: $path" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if { command -v curl > /dev/null; } 2>&1; then
|
||||
curl -fLsS --output "${path}" "${url}"
|
||||
elif { command -v wget > /dev/null; } 2>&1; then
|
||||
wget --output-document "${path}" "${url}"
|
||||
else
|
||||
echo "ERROR: need one of curl or wget to fetch the artifact." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
requireCommand() {
|
||||
if ! command -v "$1" &>/dev/null; then
|
||||
logError "this script requires command '$1'. Please install on the search PATH and try again."
|
||||
$1
|
||||
fi
|
||||
}
|
||||
|
||||
setWorkingDir() {
|
||||
workdir="${1}"
|
||||
|
||||
cd "${workdir}"
|
||||
|
||||
# Count non-hidden files
|
||||
non_hidden_files=$(find . -maxdepth 1 -not -name '.*' | wc -l)
|
||||
# Count hidden files
|
||||
if ls -ld .[^.]* 2> /dev/null; then
|
||||
hidden_files=0
|
||||
for file in .[^.]*; do
|
||||
if [[ -f "$file" ]]; then
|
||||
hidden_files=$((hidden_files + 1))
|
||||
fi
|
||||
done
|
||||
else
|
||||
hidden_files=0
|
||||
fi
|
||||
# Calculate total number of files
|
||||
total_files=$((non_hidden_files + hidden_files))
|
||||
if (( total_files > 0 )); then
|
||||
echo "WARN: working directory is not empty: ${workdir}" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
requireBashVersion
|
||||
declare -a BINS=(unzip find)
|
||||
for BIN in "${BINS[@]}"; do
|
||||
requireCommand "$BIN"
|
||||
done
|
||||
setWorkingDir "${1:-$PWD}" || {
|
||||
echo "WARN: installing anyway in a few seconds...press Ctrl-C to abort" >&2
|
||||
sleep 9
|
||||
}
|
||||
fetchFile "${ZITI_QUICK_COMPOSE:-"https://get.openziti.io/dock/all-in-one/compose.yml"}" "compose.yml"
|
||||
fetchFile "${ZROK_REPO_ZIP:-"https://github.com/openziti/zrok/archive/refs/heads/main.zip"}" "zrok.zip"
|
||||
unzip -j -d . zrok.zip '*/docker/compose/zrok-instance/*'
|
||||
rm zrok.zip .gitignore fetch.bash
|
||||
}
|
||||
|
||||
main "${@}"
|
Loading…
Reference in New Issue
Block a user