-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·88 lines (73 loc) · 2.54 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·88 lines (73 loc) · 2.54 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
#!/bin/bash
DEFAULT_INSTALL_DIR="/opt/warden"
WARDEN_VERSION="${WARDEN_VERSION:-0.2.0}"
if [[ -t 1 && -z "${NO_COLOR:-}" ]]; then
COLOR_BOLD=$'\033[1m'
COLOR_BLUE=$'\033[1;34m'
COLOR_YELLOW=$'\033[1;33m'
COLOR_RED=$'\033[1;31m'
COLOR_GREEN=$'\033[1;32m'
COLOR_RESET=$'\033[0m'
else
COLOR_BOLD=""
COLOR_BLUE=""
COLOR_YELLOW=""
COLOR_RED=""
COLOR_GREEN=""
COLOR_RESET=""
fi
info() {
printf "%b\n" "${COLOR_BLUE}$*${COLOR_RESET}"
}
warn() {
printf "%b\n" "${COLOR_YELLOW}$*${COLOR_RESET}"
}
error() {
printf "%b\n" "${COLOR_RED}$*${COLOR_RESET}" >&2
}
success() {
printf "%b\n" "${COLOR_GREEN}$*${COLOR_RESET}"
}
validate_python_config() {
make check-python
}
printf "%b\n" "${COLOR_BOLD}This script will install Warden on your system.${COLOR_RESET}"
warn "Please ensure you have the necessary permissions to write to the installation directory."
read -r -p "Installation directory [${WARDEN_INSTALL_DIR:-$DEFAULT_INSTALL_DIR}]: " USER_INSTALL_DIR < /dev/tty
INSTALL_DIR="${USER_INSTALL_DIR:-${WARDEN_INSTALL_DIR:-$DEFAULT_INSTALL_DIR}}"
# Create the installation directory if it doesn't exist
if ! mkdir -p "$INSTALL_DIR" 2>/dev/null; then
error "Error: Cannot create directory $INSTALL_DIR. Please run this script with sudo or as root."
exit 1
fi
# Check if the repository already exists
if [ -d "$INSTALL_DIR/.git" ]; then
# Update the existing repository
info "Updating existing checkout in $INSTALL_DIR..."
cd "$INSTALL_DIR"
git fetch --tags origin
else
# Clone the repository
info "Cloning Warden into $INSTALL_DIR..."
git clone https://github.com/pasqal-io/warden "$INSTALL_DIR"
fi
# Change to the cloned directory
cd "$INSTALL_DIR"
info "Checking out Warden ${WARDEN_VERSION}..."
git checkout "$WARDEN_VERSION"
# Wait for user input
while true; do
warn "Open ${INSTALL_DIR}/config.mk to review the configuration before proceeding with installation."
warn "PYTHON must point to Python 3.11 or 3.12."
read -r -p "Press Enter to validate the configuration..." < /dev/tty
if validate_python_config; then
break
fi
done
# Run make install
info "Running installation..."
make install
success "Installation complete! You can now:"
printf "%b\n" "1. Configure the Warden installation by editing the ${COLOR_BOLD}${INSTALL_DIR}/config.yaml${COLOR_RESET} file"
printf "%b\n" "2. Run ${COLOR_BOLD}cd ${INSTALL_DIR} && make run${COLOR_RESET} to start Warden."
printf "%b\n" "3. Check the full configuration guide in the README at https://github.com/pasqal-io/warden"