-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·117 lines (93 loc) · 3.14 KB
/
install.sh
File metadata and controls
executable file
·117 lines (93 loc) · 3.14 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
#!/bin/bash
# proc installer script
# Usage: curl -fsSL https://raw.githubusercontent.com/yazeed/proc/main/install.sh | bash
set -e
REPO="yazeed/proc"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
BINARY_NAME="proc"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
info() { echo -e "${GREEN}[INFO]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
# Detect OS and architecture
detect_platform() {
local os arch
case "$(uname -s)" in
Darwin) os="darwin" ;;
Linux) os="linux" ;;
MINGW*|MSYS*|CYGWIN*) os="windows" ;;
*) error "Unsupported operating system: $(uname -s)" ;;
esac
case "$(uname -m)" in
x86_64|amd64) arch="x86_64" ;;
arm64|aarch64) arch="aarch64" ;;
*) error "Unsupported architecture: $(uname -m)" ;;
esac
echo "${os}-${arch}"
}
# Get latest release version
get_latest_version() {
curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | \
grep '"tag_name":' | \
sed -E 's/.*"([^"]+)".*/\1/'
}
# Download and install
install_proc() {
local platform version url tmp_dir
platform=$(detect_platform)
info "Detected platform: ${platform}"
version=$(get_latest_version)
if [ -z "$version" ]; then
error "Failed to get latest version"
fi
info "Latest version: ${version}"
# Construct download URL
if [ "$platform" = "windows-x86_64" ]; then
url="https://github.com/${REPO}/releases/download/${version}/proc-${platform}.exe"
else
url="https://github.com/${REPO}/releases/download/${version}/proc-${platform}"
fi
info "Downloading from: ${url}"
tmp_dir=$(mktemp -d)
trap "rm -rf ${tmp_dir}" EXIT
if ! curl -fsSL "${url}" -o "${tmp_dir}/${BINARY_NAME}"; then
error "Failed to download proc"
fi
chmod +x "${tmp_dir}/${BINARY_NAME}"
# Install
if [ -w "$INSTALL_DIR" ]; then
mv "${tmp_dir}/${BINARY_NAME}" "${INSTALL_DIR}/${BINARY_NAME}"
else
info "Installing to ${INSTALL_DIR} requires sudo..."
sudo mv "${tmp_dir}/${BINARY_NAME}" "${INSTALL_DIR}/${BINARY_NAME}"
fi
info "Successfully installed proc to ${INSTALL_DIR}/${BINARY_NAME}"
# Verify installation
if command -v proc &> /dev/null; then
echo ""
info "Installation complete!"
proc --version
echo ""
info "Run 'proc --help' to get started"
else
warn "proc installed but not found in PATH"
warn "Add ${INSTALL_DIR} to your PATH or run: ${INSTALL_DIR}/${BINARY_NAME}"
fi
}
# Main
main() {
echo ""
echo " ╔═══════════════════════════════════╗"
echo " ║ proc installer ║"
echo " ║ Semantic Process Management CLI ║"
echo " ╚═══════════════════════════════════╝"
echo ""
# Check for required tools
command -v curl &> /dev/null || error "curl is required but not installed"
install_proc
}
main "$@"