#!/usr/bin/env bash # Generated by tools/build.py. Edit the template and scripts instead. set -euo pipefail getsh_main() ( set -euo pipefail BASE_URL=https://get.domain.com command_name="${1:-help}" if (( $# > 0 )); then shift; fi case "$command_name" in help|-h|--help) cat <<'GETSH_HELP' getsh — Debian script distribution Usage: curl -fsSL https://get.domain.com | bash -s -- [args...] Available commands: check Check Debian compatibility without changing the system Examples: curl -fsSL https://get.domain.com | bash curl -fsSL https://get.domain.com | bash -s -- check GETSH_HELP return 0 ;; esac case "$command_name" in check) expected_hash='176647114516a634e1039c070c466855a9f172223f77517f9dece95fbcab3f4e' ;; *) printf 'Error: unknown command "%s". Run the entry script without arguments for help.\n' "$command_name" >&2 return 2 ;; esac for dependency in curl mktemp bash; do if ! command -v "$dependency" >/dev/null 2>&1; then printf 'Error: required command is missing: %s\n' "$dependency" >&2 return 1 fi done if command -v sha256sum >/dev/null 2>&1; then hash_command=sha256sum elif command -v shasum >/dev/null 2>&1; then hash_command=shasum else printf 'Error: sha256sum or shasum is required.\n' >&2 return 1 fi temp_dir=$(mktemp -d) trap 'rm -rf -- "$temp_dir"' EXIT trap 'exit 130' INT trap 'exit 143' TERM script_path="$temp_dir/module.sh" if ! curl --fail --silent --show-error --location \ --connect-timeout 10 --max-time 300 \ --proto '=https' --proto-redir '=https' \ --output "$script_path" "${BASE_URL}/${command_name}.sh"; then printf 'Error: failed to download module "%s"; nothing executed.\n' "$command_name" >&2 return 1 fi if [[ "$hash_command" == sha256sum ]]; then actual_hash=$(sha256sum "$script_path") else actual_hash=$(shasum -a 256 "$script_path") fi actual_hash="${actual_hash%% *}" if [[ "$actual_hash" != "$expected_hash" ]]; then printf 'Error: module checksum mismatch. Retry with a fresh entry script.\n' >&2 return 1 fi if ! bash -n "$script_path"; then printf 'Error: module syntax check failed; nothing executed.\n' >&2 return 1 fi bash "$script_path" "$@" ) getsh_main "$@"