You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
4.3 KiB

#!/bin/bash
# D-Star Site Install Script
# For Raspberry Pi 3B running Raspberry Pi OS Lite (64-bit)
# Usage: sudo bash install.sh
set -e
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MMDVM_SOURCE_DIR="/home/pi/MMDVM-Host"
MMDVM_REPO="https://github.com/g4klx/MMDVMHost.git"
ZEROTIER_NETWORK="c5029fdad4ccf9c5"
echo "================================================"
echo " D-Star Site Installer"
echo "================================================"
echo ""
# Select site
echo "Available sites:"
echo " 1) ORNG - Orange Portable"
echo " 2) ORNG2 - Orange TXRX"
echo ""
read -p "Select site [1-2]: " SITE_CHOICE
case $SITE_CHOICE in
1) SITE="ORNG" ;;
2) SITE="ORNG2" ;;
*) echo "Invalid selection"; exit 1 ;;
esac
echo ""
echo "Installing site: $SITE"
echo ""
# Load site config
source "$REPO_DIR/sites/$SITE/site.conf"
# Install dependencies
echo "Installing dependencies..."
apt-get update -qq
apt-get install -y git build-essential nlohmann-json3-dev libssl-dev python3 libmosquitto-dev
# Install ZeroTier
echo "Installing ZeroTier..."
curl -s https://install.zerotier.com | bash
zerotier-cli join $ZEROTIER_NETWORK
echo "ZeroTier installed and joined network $ZEROTIER_NETWORK"
echo ""
echo "NOTE: Approve this device in ZeroTier Central before continuing"
read -p "Press ENTER once device is approved..."
# Configure serial port for MMDVM board
echo "Configuring serial port..."
# Modern Pi OS - config in /boot/firmware/config.txt
CONFIG_FILE="/boot/firmware/config.txt"
if [ ! -f "$CONFIG_FILE" ]; then
# Fall back to old path
CONFIG_FILE="/boot/config.txt"
fi
# Disable Bluetooth and enable UART for MMDVM board
if ! grep -q "dtoverlay=disable-bt" "$CONFIG_FILE"; then
echo "" >> "$CONFIG_FILE"
echo "# MMDVM Board - disable BT, enable hardware UART" >> "$CONFIG_FILE"
echo "dtoverlay=disable-bt" >> "$CONFIG_FILE"
echo "enable_uart=1" >> "$CONFIG_FILE"
echo "Serial port configured in $CONFIG_FILE"
fi
# Disable serial console so Linux doesn't use the UART
echo "Disabling serial console..."
systemctl stop serial-getty@ttyAMA0.service 2>/dev/null || true
systemctl disable serial-getty@ttyAMA0.service 2>/dev/null || true
# Remove serial console from cmdline.txt
CMDLINE_FILE="/boot/firmware/cmdline.txt"
if [ ! -f "$CMDLINE_FILE" ]; then
CMDLINE_FILE="/boot/cmdline.txt"
fi
sed -i 's/console=serial0,[0-9]* //' "$CMDLINE_FILE"
sed -i 's/console=ttyAMA0,[0-9]* //' "$CMDLINE_FILE"
echo "Serial console removed from $CMDLINE_FILE"
# Add pi user to dialout
usermod -a -G dialout pi
# Clone MMDVMHost if not present
if [ ! -d "$MMDVM_SOURCE_DIR" ]; then
echo "Cloning MMDVMHost..."
git clone "$MMDVM_REPO" "$MMDVM_SOURCE_DIR"
fi
# Copy patched source files
echo "Applying patches..."
cp "$REPO_DIR/src/DStarNetwork.cpp" "$MMDVM_SOURCE_DIR/"
cp "$REPO_DIR/src/DStarNetwork.h" "$MMDVM_SOURCE_DIR/"
cp "$REPO_DIR/src/Conf.h" "$MMDVM_SOURCE_DIR/"
cd "$MMDVM_SOURCE_DIR"
python3 "$REPO_DIR/src/patch_conf_cpp.py"
python3 "$REPO_DIR/src/patch_mmdvm_host_cpp.py"
# Compile
echo "Compiling MMDVMHost..."
make -j$(nproc)
# Install binary
echo "Installing binary..."
cp MMDVM-Host /usr/local/bin/MMDVM-Host
chmod 755 /usr/local/bin/MMDVM-Host
# Generate config from template
echo "Generating config for $SITE..."
sed \
-e "s/%%CALLSIGN%%/$CALLSIGN/g" \
-e "s/%%MODULE%%/$MODULE/g" \
-e "s/%%SITE_NAME%%/$SITE_NAME/g" \
-e "s/%%GATEWAY_ADDRESS%%/$GATEWAY_ADDRESS/g" \
-e "s/%%GATEWAY_PORT%%/$GATEWAY_PORT/g" \
-e "s/%%LOCAL_PORT%%/$LOCAL_PORT/g" \
-e "s/%%MODEM_PORT%%/$MODEM_PORT/g" \
-e "s/%%MODEM_SPEED%%/$MODEM_SPEED/g" \
"$REPO_DIR/sites/mmdvmhost.template" > /etc/mmdvmhost
echo "Config written to /etc/mmdvmhost"
# Install service
echo "Installing systemd service..."
cp "$REPO_DIR/services/mmdvmhost.service" /etc/systemd/system/
systemctl daemon-reload
systemctl enable mmdvmhost
echo ""
echo "================================================"
echo " Installation complete for site: $SITE"
echo "================================================"
echo ""
echo "ZeroTier status:"
zerotier-cli status
echo ""
echo "A reboot is required to activate serial port changes."
echo ""
read -p "Reboot now? [y/N]: " REBOOT
if [ "$REBOOT" = "y" ] || [ "$REBOOT" = "Y" ]; then
reboot
else
echo "Run 'sudo reboot' when ready."
echo "MMDVMHost will start automatically after reboot."
fi

Powered by TurnKey Linux.