-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
111 lines (91 loc) · 3.28 KB
/
Copy pathinstall.sh
File metadata and controls
111 lines (91 loc) · 3.28 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
#!/bin/sh
#
# install.sh — fullfetch installer
# Usage: curl -sfL https://github.com/Buct0r/fullfetch/releases/latest/download/install.sh | sh
#
set -e
REPO="Buct0r/fullfetch"
BINARY="fullfetch"
INSTALL_DIR="/usr/local/bin"
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
info() { printf "%b%s%b\\n" "${BLUE}" "$*" "${NC}"; }
ok() { printf "%b%s%b\\n" "${GREEN}" "$*" "${NC}"; }
die() { printf "%b%s%b\\n" "${RED}" "$*" "${NC}" >&2; exit 1; }
# --- OS / arch detection ---
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case "${ARCH}" in
x86_64|amd64) ARCH="x86_64" ;;
aarch64|arm64|armv8l) ARCH="arm64" ;;
armv6l) ARCH="armv6" ;;
armv7l) ARCH="armv7" ;;
*) die "Unsupported architecture: ${ARCH}" ;;
esac
case "${OS}" in
linux) OS_TITLE="Linux" ;;
darwin) OS_TITLE="Darwin" ;;
*) die "Unsupported OS: ${OS}" ;;
esac
info "Detected: ${OS_TITLE} ${ARCH}"
# --- Fetch latest release ---
info "Fetching latest release info..."
TAG="$(curl -sfL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed 's/.*"tag_name": "\(.*\)",.*/\1/')"
[ -z "${TAG}" ] && die "Could not determine latest release tag"
VERSION="${TAG#v}"
info "Latest: ${TAG}"
# --- Download ---
TARBALL="${BINARY}_${OS_TITLE}_${ARCH}.tar.gz"
URL="https://github.com/${REPO}/releases/download/${TAG}/${TARBALL}"
CHECKSUMS_URL="https://github.com/${REPO}/releases/download/${TAG}/checksums.txt"
TMPDIR="$(mktemp -d)" || die "Failed to create temp directory"
trap 'rm -rf "${TMPDIR}"' EXIT
info "Downloading ${TARBALL}..."
curl -sfL "${URL}" -o "${TMPDIR}/${TARBALL}"
info "Verifying checksum..."
curl -sfL "${CHECKSUMS_URL}" -o "${TMPDIR}/checksums.txt"
EXPECTED="$(grep "${TARBALL}" "${TMPDIR}/checksums.txt" | awk '{print $1}')"
[ -z "${EXPECTED}" ] && die "Checksum not found for ${TARBALL}"
if command -v sha256sum >/dev/null 2>&1; then
ACTUAL="$(sha256sum "${TMPDIR}/${TARBALL}" | awk '{print $1}')"
elif command -v shasum >/dev/null 2>&1; then
ACTUAL="$(shasum -a 256 "${TMPDIR}/${TARBALL}" | awk '{print $1}')"
else
die "No SHA-256 utility found (install coreutils or sha256sum)"
fi
[ "${ACTUAL}" != "${EXPECTED}" ] && die "Checksum mismatch — expected ${EXPECTED}, got ${ACTUAL}"
ok "Checksum verified"
# --- Extract ---
info "Extracting..."
tar xzf "${TMPDIR}/${TARBALL}" -C "${TMPDIR}"
BIN_PATH="$(find "${TMPDIR}" -name "${BINARY}" -type f | head -1)"
[ -z "${BIN_PATH}" ] && die "Binary not found in archive"
# --- Install ---
info "Installing to ${INSTALL_DIR}..."
if [ "$(id -u)" -eq 0 ]; then
mv "${BIN_PATH}" "${INSTALL_DIR}/${BINARY}"
else
sudo mv "${BIN_PATH}" "${INSTALL_DIR}/${BINARY}"
fi
chmod +x "${INSTALL_DIR}/${BINARY}"
ok "${BINARY} ${VERSION} installed to ${INSTALL_DIR}/${BINARY}"
# --- Config migration ---
CONFIG_FOUND=false
for p in "${HOME}/.config/fullfetch/config.json" "${INSTALL_DIR}/config.json" "$(pwd)/config.json"; do
if [ -f "$p" ]; then
CONFIG_FOUND=true
break
fi
done
if $CONFIG_FOUND; then
info "Updating config with latest features..."
if "${INSTALL_DIR}/${BINARY}" -migrate 2>/dev/null; then
ok "Config updated"
else
info "Run \`${BINARY} -migrate\` manually to update your config"
fi
else
info "Run \`${BINARY} -gen\` to generate a user config file"
fi