#!/bin/sh # GO-KP radio tool installer. # curl gokp.click | sh # The tool itself is always fetched over HTTPS and checked against its SHA-256. # Installs one file, go-kp-flash, into ~/.local/bin and starts it. No root needed. Remove it by deleting that file. set -eu BASE_URL="${GO_KP_BASE_URL:-https://gokp.click}" VERSION="v0.2.0, build 2026.11.10-18ebf09" DEST_DIR="${GO_KP_INSTALL_DIR:-$HOME/.local/bin}" DEST="$DEST_DIR/go-kp-flash" say() { printf '%s\n' "$*"; } fail() { printf 'Install stopped: %s\n' "$*" >&2; exit 1; } case "$(uname -s)" in Linux) ;; *) fail "this tool runs on Linux only." ;; esac command -v python3 >/dev/null 2>&1 || fail "Python 3 is not installed. Install python3 and run this again." python3 -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)' \ || fail "Python 3.10 or newer is needed; this computer has $(python3 -c 'import sys; print(sys.version.split()[0])')." if command -v curl >/dev/null 2>&1; then fetch() { curl -fsSL "$1" -o "$2"; } elif command -v wget >/dev/null 2>&1; then fetch() { wget -q "$1" -O "$2"; } else fail "neither curl nor wget is installed." fi command -v sha256sum >/dev/null 2>&1 || fail "sha256sum is not installed." WORK=$(mktemp -d) trap 'rm -rf "$WORK"' EXIT INT TERM say "Downloading the GO-KP radio tool ($VERSION)..." fetch "$BASE_URL/go-kp-flash.pyz" "$WORK/go-kp-flash.pyz" || fail "could not download the tool from $BASE_URL." fetch "$BASE_URL/go-kp-flash.pyz.sha256" "$WORK/expected" || fail "could not download the checksum from $BASE_URL." EXPECTED=$(cut -d' ' -f1 "$WORK/expected") ACTUAL=$(sha256sum "$WORK/go-kp-flash.pyz" | cut -d' ' -f1) [ -n "$EXPECTED" ] && [ "$EXPECTED" = "$ACTUAL" ] || fail "the download does not match its checksum. Nothing was installed." python3 "$WORK/go-kp-flash.pyz" --version >/dev/null 2>&1 || fail "the downloaded tool does not run on this computer." mkdir -p "$DEST_DIR" cp "$WORK/go-kp-flash.pyz" "$DEST.new" chmod 755 "$DEST.new" mv "$DEST.new" "$DEST" say "Installed: $DEST" if ! python3 -c 'import ctypes.util, sys; sys.exit(0 if ctypes.util.find_library("usb-1.0") else 1)' 2>/dev/null; then say "Note: libusb-1.0 was not found. The tool needs it to talk to a radio." say " Debian/Ubuntu: sudo apt install libusb-1.0-0 Fedora: sudo dnf install libusb1" fi case ":$PATH:" in *":$DEST_DIR:"*) AGAIN="go-kp-flash" ;; *) AGAIN="$DEST" ;; esac say "To start it again later, type: $AGAIN" say "If it cannot reach the radio, start it with sudo in front." # Start it now. The script arrived through a pipe, so the tool reads the keyboard from the terminal itself. # Set GO_KP_NO_RUN=1 to install without starting it. if [ -z "${GO_KP_NO_RUN:-}" ] && [ -t 1 ] && ( : /dev/null; then rm -rf "$WORK" trap - EXIT INT TERM say "" exec "$DEST"