Files
codecraft/server/resources-cli/install.sh
T
2026-11-19 11:57:07 +01:00

54 lines
1.8 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# Install the CodeCraft terminal client (codecraft) from __CODECRAFT_URL__
# curl -fsSL __CODECRAFT_URL__/cli/install.sh | sh
# Options (environment): CODECRAFT_INSTALL_DIR (default ~/.local/bin)
set -eu
SERVER="__CODECRAFT_URL__"
DIR="${CODECRAFT_INSTALL_DIR:-$HOME/.local/bin}"
os=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m)
case "$arch" in
x86_64|amd64) arch=x86_64 ;;
aarch64|arm64) arch=aarch64 ;;
riscv64) arch=riscv64 ;;
*) echo "codecraft: unsupported architecture $arch" >&2; exit 1 ;;
esac
case "$os" in
linux) ;;
*) echo "codecraft: no prebuilt binary for $os yet – build from source: cargo install --locked --git https://git.familie-zink.org/zink/codecraft codecraft-cli" >&2; exit 1 ;;
esac
target="$os-$arch"
url="$SERVER/cli/download/$target"
mkdir -p "$DIR"
tmp="$DIR/.codecraft.download"
echo "Downloading codecraft ($target) from $SERVER …"
no_build() {
rm -f "$tmp"
echo "codecraft: this server has no prebuilt binary for $target." >&2
echo "Build it from source (needs Rust): cargo install --locked --git https://git.familie-zink.org/zink/codecraft codecraft-cli" >&2
exit 1
}
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$tmp" || no_build
elif command -v wget >/dev/null 2>&1; then
wget -q "$url" -O "$tmp" || no_build
else
echo "codecraft: needs curl or wget" >&2; exit 1
fi
chmod +x "$tmp"
mv "$tmp" "$DIR/codecraft"
echo "Installed $DIR/codecraft ($("$DIR/codecraft" --version 2>/dev/null || echo codecraft))"
case ":$PATH:" in
*":$DIR:"*) ;;
*) echo "Note: $DIR is not in your PATH – add this to your shell profile:"
echo " export PATH=\"$DIR:\$PATH\"" ;;
esac
echo
echo "Next steps:"
echo " codecraft login $SERVER # sign in with your CodeCraft account"
echo " codecraft # start in your project folder"