-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsetup.sh
More file actions
66 lines (55 loc) · 2.08 KB
/
Copy pathsetup.sh
File metadata and controls
66 lines (55 loc) · 2.08 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
#!/bin/bash
set -e
GREEN='\033[0;32m'
RED='\033[0;31m'
CYAN='\033[0;36m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${CYAN}🎯 Installing system dependencies...${NC}"
sudo apt update && sudo apt install -y build-essential pkg-config libssl-dev git curl
MIN_RUST_VERSION="1.70.0"
should_install_rust=false
if command -v rustc &> /dev/null && command -v cargo &> /dev/null; then
INSTALLED_RUST_VERSION=$(rustc --version | awk '{print $2}')
echo -e "${CYAN}🔍 Detected rustc ${INSTALLED_RUST_VERSION}${NC}"
if [ "$(printf '%s\n' "$INSTALLED_RUST_VERSION" "$MIN_RUST_VERSION" | sort -V | head -n1)" != "$MIN_RUST_VERSION" ]; then
echo -e "${YELLOW}⚠️ Rust version is too old (< ${MIN_RUST_VERSION}). Updating via rustup...${NC}"
should_install_rust=true
else
echo -e "${GREEN}✅ Rust version is sufficient. Skipping installation.${NC}"
fi
else
echo -e "${YELLOW}🚫 Rust or Cargo not found.${NC}"
should_install_rust=true
fi
if [ "$should_install_rust" = true ]; then
echo -e "${CYAN}🚀 Installing rustup (Rust & Cargo)...${NC}"
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
fi
# Handle --force flag
if [[ "$1" == "--force" ]]; then
echo -e "${YELLOW}⚠️ --force enabled. Removing existing 'pipe' folder...${NC}"
rm -rf pipe
fi
if [ -d "pipe" ]; then
echo -e "${YELLOW}📁 'pipe' folder already exists. Skipping clone.${NC}"
else
echo -e "${CYAN}📦 Cloning Pipe repo...${NC}"
git clone https://github.com/PipeNetwork/pipe.git
fi
cd pipe
echo -e "${CYAN}🔧 Building Pipe CLI...${NC}"
if cargo install --path .; then
echo -e "${GREEN}✅ Build successful!${NC}"
else
echo -e "${RED}❌ Build failed. Please check the error log.${NC}"
exit 1
fi
if command -v pipe &> /dev/null; then
echo -e "\n${GREEN}🚀 All set! You can now run:${NC}"
echo -e " ${CYAN}pipe --help${NC}\n"
else
echo -e "\n${RED}⚠️ Setup complete, but 'pipe' command not found in PATH.${NC}"
echo -e "${YELLOW}You might need to restart your terminal or add ~/.cargo/bin to PATH.${NC}\n"
fi