#!/usr/bin/env bash # Check if running as root if [ "$(id -u)" -ne 0 ]; then echo "This script must be run as root (or with sudo)" exit 1 fi # Make sure the script is running on a Debian-based system if ! [ -f "/etc/debian_version" ]; then echo "Error: This script is only supported on Debian-based systems." exit 1 fi # Check if node exists if ! command -v node &> /dev/null; then echo "Node.js is required but not installed" echo "To install Node.js, visit: https://deb.nodesource.com/" exit 1 fi # Cleanup old sources rm -f /usr/share/keyrings/apt.medplum.com.asc || true rm -f /etc/apt/sources.list.d/apt.medplum.com.list || true # Download GPG key if ! wget -O /usr/share/keyrings/apt.medplum.com.asc https://apt.medplum.com/apt.medplum.com.asc; then echo "Failed to download Medplum signing key" exit 1 fi # Set permissions if ! chmod 644 /usr/share/keyrings/apt.medplum.com.asc; then echo "Failed to set correct permissions on /usr/share/keyrings/apt.medplum.com.asc" exit 1 fi # Add sources if ! echo "deb [signed-by=/usr/share/keyrings/apt.medplum.com.asc] https://apt.medplum.com/debian stable main" | tee /etc/apt/sources.list.d/apt.medplum.com.list > /dev/null; then echo "Failed to add Medplum repository to sources list" exit 1 fi echo "Medplum repository has been configured successfully." echo "" echo "To install Medplum, run:" echo " sudo apt-get update" echo " sudo apt-get install medplum"