-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·115 lines (97 loc) Β· 3.1 KB
/
install.sh
File metadata and controls
executable file
Β·115 lines (97 loc) Β· 3.1 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
#!/bin/bash
#
# Crust Installer
# https://getcrust.io
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/BakeLens/crust/main/install.sh | bash
#
# With options:
# curl -fsSL .../install.sh | bash -s -- --version v2.0.0
# curl -fsSL .../install.sh | bash -s -- --no-tui
#
# Non-interactive (Docker/CI):
# bash install.sh --local . --prefix /usr/local/bin --no-font --no-completion
#
set -e
# Source shared functions (works for both local and piped execution)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/scripts/install-common.sh" ]; then
# shellcheck source=scripts/install-common.sh
source "$SCRIPT_DIR/scripts/install-common.sh"
else
# When piped via curl, download common script to temp
_common_tmp=$(mktemp)
if command -v curl &>/dev/null; then
curl -fsSL "https://raw.githubusercontent.com/BakeLens/crust/main/scripts/install-common.sh" -o "$_common_tmp"
elif command -v wget &>/dev/null; then
wget -q "https://raw.githubusercontent.com/BakeLens/crust/main/scripts/install-common.sh" -O "$_common_tmp"
elif command -v fetch &>/dev/null; then
fetch -q -o "$_common_tmp" "https://raw.githubusercontent.com/BakeLens/crust/main/scripts/install-common.sh"
else
echo "Error: curl, wget, or fetch required" >&2
exit 1
fi
# shellcheck source=/dev/null
source "$_common_tmp"
fi
main() {
parse_args "$@"
if [ -n "$DO_UNINSTALL" ]; then
# shellcheck disable=SC2119 # no extra paths to remove for basic uninstall
run_uninstall
exit 0
fi
print_banner ""
local src_dir
if [ -n "$LOCAL_SRC" ]; then
init_steps 5
src_dir="$LOCAL_SRC"
if [ "$VERSION" = "latest" ]; then
VERSION=$(git -C "$src_dir" describe --tags --always 2>/dev/null || echo "dev")
fi
else
init_steps 7
fi
step "Detecting system"
detect_platform
step "Checking requirements"
check_requirements "go"
if [ -z "$LOCAL_SRC" ]; then
step "Fetching version"
resolve_version
local tmp_dir
tmp_dir=$(mktemp -d)
trap 'rm -rf "$tmp_dir"; rm -f "${_common_tmp:-}"' EXIT
step "Cloning repository"
clone_repo "$VERSION" "$tmp_dir/crust"
src_dir="$tmp_dir/crust"
fi
step "Building Crust"
build_go_binary "$src_dir" "$VERSION"
step "Installing"
install_go_binary "$src_dir"
setup_data_dir
step "Finalizing"
setup_completion
setup_font
echo ""
if [ "${_PLAIN:-0}" = "1" ]; then
echo "Crust installed successfully!"
else
echo -e " ${GREEN}${BOLD}β Crust installed successfully!${NC}"
fi
echo ""
echo -e " ${BLUE}Binary${NC} ${INSTALL_DIR}/${BINARY_NAME}"
echo -e " ${BLUE}Data${NC} ${DATA_DIR}/"
echo ""
setup_path_hint
echo -e " ${BOLD}Quick Start${NC}"
echo ""
echo " crust start # Start with interactive setup"
echo " crust status # Check status"
echo " crust logs -f # Follow logs"
echo " crust stop # Stop crust"
echo ""
}
main "$@"