-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·81 lines (66 loc) · 1.99 KB
/
install.sh
File metadata and controls
executable file
·81 lines (66 loc) · 1.99 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
#!/bin/bash
LATEST_TAG=$(curl "https://api.github.com/repos/Luganodes/hypermon/tags" | jq -r '.[0].name')
DESTINATION_DIR="/usr/local/bin"
DOWNLOAD_LINK="https://github.com/Luganodes/hypermon/releases/download/$LATEST_TAG/hypermon"
BINARY_NAME="hypermon"
SERVICE_FILE="/etc/systemd/system/hypermon.service"
# Function to check OS type
check_os_type() {
case "$(uname -s)" in
Linux*) OS="Linux" ;;
Darwin*) OS="MacOS" ;;
*) echo "Unsupported OS"; exit 1 ;;
esac
}
# Function to install the binary
install_binary() {
Check if the user is root or has sudo privileges
if [ "$EUID" -ne 0 ]; then
echo "Please run this script with sudo or as root."
exit 1
fi
# Check if the destination directory exists
if [ ! -d "$DESTINATION_DIR" ]; then
echo "Creating $DESTINATION_DIR..."
mkdir -p "$DESTINATION_DIR"
fi
# Copy the binary to the destination directory
echo "Installing $BINARY_NAME to $DESTINATION_DIR..."
wget $DOWNLOAD_LINK -O "$DESTINATION_DIR/$BINARY_NAME"
chmod +x "$DESTINATION_DIR/$BINARY_NAME"
# Verify installation
if [ -f "$DESTINATION_DIR/$BINARY_NAME" ]; then
echo "$BINARY_NAME successfully installed in $DESTINATION_DIR"
else
echo "Installation failed."
exit 1
fi
}
install_service() {
echo "Installing service..."
cat <<EOF | sudo tee $SERVICE_FILE > /dev/null
[Unit]
Description=Hyperliquid Validator Monitoring Daemon
After=network.target
[Service]
User=$USER
Type=simple
ExecStart=$DESTINATION_DIR/$BINARY_NAME start --rpc-url=http://localhost:3001/evm
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
echo "Reloading systemd daemon..."
sudo systemctl daemon-reload
}
# Check the OS type
check_os_type
# Install the binary
install_binary
# Install service
install_service
# Success message
echo "Installation complete."
echo "Please edit /etc/systemd/system/hypermon.service if needed"
echo "Then run"
echo "sudo systemctl daemon-reload && sudo systemctl enable hypermon && sudo systemctl restart hypermon"