Skip to content

Instantly share code, notes, and snippets.

@Ne00n
Last active October 1, 2025 19:02
Show Gist options
  • Select an option

  • Save Ne00n/d974761e27cfe9914ac4443eb070c316 to your computer and use it in GitHub Desktop.

Select an option

Save Ne00n/d974761e27cfe9914ac4443eb070c316 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Globalping Probe Installer for Debian
# This script downloads, installs, and configures the Globalping probe
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Configuration
BINARY_URL="https://github.com/jsdelivr/globalping-probe/releases/download/v0.41.0/globalping-probe-bin"
INSTALL_DIR="/usr/local/bin"
BINARY_NAME="globalping-probe"
SERVICE_USER="globalping"
SERVICE_NAME="globalping-probe"
# Function to print colored messages
print_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
# Check if running as root
if [[ $EUID -ne 0 ]]; then
print_error "This script must be run as root (use sudo)"
exit 1
fi
print_info "Starting Globalping Probe installation..."
# Check if running on Debian/Ubuntu
if ! command -v apt-get &> /dev/null; then
print_error "This script is designed for Debian/Ubuntu systems"
exit 1
fi
# Update package list
print_info "Updating package list..."
apt-get update -qq
# Install required dependencies
print_info "Installing dependencies..."
apt-get install -y curl wget ca-certificates
# Create service user if it doesn't exist
if ! id -u "$SERVICE_USER" &> /dev/null; then
print_info "Creating service user '$SERVICE_USER'..."
useradd -r -s /bin/false -d /nonexistent "$SERVICE_USER"
else
print_info "Service user '$SERVICE_USER' already exists"
fi
# Download the binary
print_info "Downloading Globalping probe binary..."
wget -q --show-progress "$BINARY_URL" -O "/tmp/$BINARY_NAME"
# Move binary to installation directory
print_info "Installing binary to $INSTALL_DIR..."
mv "/tmp/$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
chmod +x "$INSTALL_DIR/$BINARY_NAME"
# Create systemd service file
print_info "Creating systemd service..."
cat > "/etc/systemd/system/$SERVICE_NAME.service" << EOF
[Unit]
Description=Globalping Probe
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=$SERVICE_USER
ExecStart=$INSTALL_DIR/$BINARY_NAME
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
# Security hardening
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/globalping
[Install]
WantedBy=multi-user.target
EOF
# Create data directory
print_info "Creating data directory..."
mkdir -p /var/lib/globalping
chown "$SERVICE_USER:$SERVICE_USER" /var/lib/globalping
# Reload systemd
print_info "Reloading systemd daemon..."
systemctl daemon-reload
# Enable the service
print_info "Enabling $SERVICE_NAME service..."
systemctl enable "$SERVICE_NAME"
# Start the service
print_info "Starting $SERVICE_NAME service..."
systemctl start "$SERVICE_NAME"
# Check service status
sleep 2
if systemctl is-active --quiet "$SERVICE_NAME"; then
print_info "✓ Installation completed successfully!"
echo ""
print_info "Service is running. You can check its status with:"
echo " sudo systemctl status $SERVICE_NAME"
echo ""
print_info "View logs with:"
echo " sudo journalctl -u $SERVICE_NAME -f"
echo ""
print_info "To stop the service:"
echo " sudo systemctl stop $SERVICE_NAME"
echo ""
print_info "To disable the service:"
echo " sudo systemctl disable $SERVICE_NAME"
else
print_error "Service failed to start. Check logs with:"
echo " sudo journalctl -u $SERVICE_NAME -n 50"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment