-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·114 lines (98 loc) · 3.67 KB
/
install.sh
File metadata and controls
executable file
·114 lines (98 loc) · 3.67 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
#!/bin/bash
# Qtools Installer
# Usage: curl -sSL https://raw.githubusercontent.com/QuilibriumNetwork/qtools/main/install.sh | bash
# or: wget -qO- https://raw.githubusercontent.com/QuilibriumNetwork/qtools/main/install.sh | bash
#
# This script clones the qtools repository and runs the initialization process.
# It should be run as a regular user with sudo access (NOT as root directly).
set -e
REPO_URL="https://github.com/QuilibriumNetwork/qtools.git"
BRANCH="main"
INSTALL_DIR="$HOME/qtools"
# Colors
RED="\033[0;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
BLUE="\033[0;34m"
RESET="\033[0m"
info() { echo -e "${BLUE}[INFO]${RESET} $1"; }
success() { echo -e "${GREEN}[OK]${RESET} $1"; }
warn() { echo -e "${YELLOW}[WARN]${RESET} $1"; }
error() { echo -e "${RED}[ERROR]${RESET} $1"; exit 1; }
# -------------------------------------------------------------------
# Pre-flight checks
# -------------------------------------------------------------------
# Ensure we are NOT running as root (the init script uses sudo internally)
if [ "$(id -u)" -eq 0 ]; then
error "Do not run this script as root. Run as a regular user with sudo access.\n Example: curl -sSL <url> | bash"
fi
# Verify sudo access
if ! sudo -v 2>/dev/null; then
error "This script requires sudo access. Please ensure your user can run sudo."
fi
# Check for git
if ! command -v git >/dev/null 2>&1; then
info "git is not installed. Attempting to install..."
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update -y && sudo apt-get install -y git
elif command -v yum >/dev/null 2>&1; then
sudo yum install -y git
elif command -v dnf >/dev/null 2>&1; then
sudo dnf install -y git
elif command -v pacman >/dev/null 2>&1; then
sudo pacman -Sy --noconfirm git
else
error "Cannot install git automatically. Please install git and try again."
fi
if ! command -v git >/dev/null 2>&1; then
error "Failed to install git. Please install it manually and try again."
fi
success "git installed"
fi
# -------------------------------------------------------------------
# Clone or update the repository
# -------------------------------------------------------------------
if [ -d "$INSTALL_DIR/.git" ]; then
info "Existing qtools installation found at $INSTALL_DIR"
info "Pulling latest changes..."
cd "$INSTALL_DIR"
git fetch origin
git checkout "$BRANCH"
git pull origin "$BRANCH"
success "Repository updated"
else
if [ -d "$INSTALL_DIR" ]; then
warn "$INSTALL_DIR exists but is not a git repo. Backing up to ${INSTALL_DIR}.bak"
mv "$INSTALL_DIR" "${INSTALL_DIR}.bak.$(date +%s)"
fi
info "Cloning qtools from $REPO_URL ..."
git clone "$REPO_URL" "$INSTALL_DIR"
cd "$INSTALL_DIR"
git checkout "$BRANCH"
success "Repository cloned to $INSTALL_DIR"
fi
# -------------------------------------------------------------------
# Run initialization
# -------------------------------------------------------------------
info "Running qtools init..."
chmod +x "$INSTALL_DIR/qtools.sh"
cd "$INSTALL_DIR"
./qtools.sh init
success "qtools has been installed!"
echo ""
echo -e "${GREEN}============================================${RESET}"
echo -e "${GREEN} Qtools installation complete!${RESET}"
echo -e "${GREEN}============================================${RESET}"
echo ""
echo " To finish setting up your shell, run:"
echo ""
echo -e " ${YELLOW}source ~/.bashrc${RESET}"
echo ""
echo " Then install a Quilibrium node with:"
echo ""
echo -e " ${YELLOW}qtools complete-install${RESET}"
echo ""
echo " For all available commands, run:"
echo ""
echo -e " ${YELLOW}qtools --help${RESET}"
echo ""