-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·118 lines (95 loc) · 3.78 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·118 lines (95 loc) · 3.78 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env sh
# install.sh — one-line installer for sisyphus
#
# curl -fsSL https://raw.githubusercontent.com/ignavan39/sisyphus/master/install.sh | sh
#
# Options (env vars):
# SISYPHUS_VERSION pin a specific version, e.g. v1.2.0 (default: latest)
# SISYPHUS_INSTALL install directory (default: /usr/local/bin)
# NO_COLOR disable coloured output
set -e
if [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; then
BOLD="\033[1m"; DIM="\033[2m"; YELLOW="\033[33m"
GREEN="\033[32m"; RED="\033[31m"; CYAN="\033[36m"; RESET="\033[0m"
else
BOLD=""; DIM=""; YELLOW=""; GREEN=""; RED=""; CYAN=""; RESET=""
fi
info() { printf " ${CYAN}•${RESET} %s\n" "$1"; }
success() { printf " ${GREEN}✓${RESET} ${BOLD}%s${RESET}\n" "$1"; }
warn() { printf " ${YELLOW}!${RESET} %s\n" "$1"; }
error() { printf " ${RED}✗${RESET} ${BOLD}%s${RESET}\n" "$1" >&2; exit 1; }
printf "\n"
printf " ${YELLOW}${BOLD}⟳ S I S Y P H U S${RESET}\n"
printf " ${DIM}the terminal myth — installer${RESET}\n"
printf "\n"
need() {
if ! command -v "$1" >/dev/null 2>&1; then
error "required command not found: $1 — please install it and retry"
fi
}
need curl
need tar
OS="$(uname -s)"
case "$OS" in
Linux) OS_KEY="linux" ;;
Darwin) OS_KEY="darwin" ;;
*) error "unsupported operating system: $OS (Windows users: see README for .exe download)" ;;
esac
ARCH="$(uname -m)"
case "$ARCH" in
x86_64 | amd64) ARCH_KEY="amd64" ;;
aarch64 | arm64 | armv8) ARCH_KEY="arm64" ;;
*) error "unsupported architecture: $ARCH" ;;
esac
info "detected platform: ${OS_KEY}/${ARCH_KEY}"
REPO="ignavan39/sisyphus"
if [ -n "${SISYPHUS_VERSION:-}" ]; then
VERSION="$SISYPHUS_VERSION"
info "using pinned version: ${VERSION}"
else
info "fetching latest release…"
VERSION="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
| grep '"tag_name"' | sed 's/.*"tag_name": *"\(.*\)".*/\1/')"
[ -n "$VERSION" ] || error "could not determine latest version — check your internet connection"
info "latest version: ${VERSION}"
fi
BINARY_NAME="sisyphus-${OS_KEY}-${ARCH_KEY}"
ARCHIVE="${BINARY_NAME}.tar.gz"
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${ARCHIVE}"
INSTALL_DIR="${SISYPHUS_INSTALL:-/usr/local/bin}"
if [ ! -w "$INSTALL_DIR" ] && [ -z "${SISYPHUS_INSTALL:-}" ]; then
INSTALL_DIR="$HOME/.local/bin"
warn "/usr/local/bin not writable — installing to ${INSTALL_DIR}"
mkdir -p "$INSTALL_DIR"
fi
[ -d "$INSTALL_DIR" ] || error "install directory does not exist: $INSTALL_DIR"
[ -w "$INSTALL_DIR" ] || error "install directory is not writable: $INSTALL_DIR (try: sudo SISYPHUS_INSTALL=$INSTALL_DIR sh install.sh)"
info "install directory: ${INSTALL_DIR}"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
info "downloading ${ARCHIVE}…"
curl -fsSL --progress-bar "$DOWNLOAD_URL" -o "${TMP_DIR}/${ARCHIVE}" \
|| error "download failed — release may not exist yet: ${DOWNLOAD_URL}"
info "extracting…"
tar -xzf "${TMP_DIR}/${ARCHIVE}" -C "$TMP_DIR"
EXTRACTED="${TMP_DIR}/${BINARY_NAME}"
[ -f "$EXTRACTED" ] || EXTRACTED="${TMP_DIR}/sisyphus"
[ -f "$EXTRACTED" ] || error "could not find binary after extraction — unexpected archive layout"
chmod +x "$EXTRACTED"
mv "$EXTRACTED" "${INSTALL_DIR}/sisyphus"
printf "\n"
success "sisyphus ${VERSION} installed → ${INSTALL_DIR}/sisyphus"
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
printf "\n"
warn "${INSTALL_DIR} is not in your PATH. Add this to your shell config:"
printf "\n"
printf " ${DIM}export PATH=\"${INSTALL_DIR}:\$PATH\"${RESET}\n"
printf "\n"
;;
esac
printf "\n"
printf " ${YELLOW}${BOLD}Run it:${RESET} sisyphus\n"
printf " ${DIM}\"One must imagine Sisyphus happy.\" — Albert Camus${RESET}\n"
printf "\n"