#!/bin/bash

# Copy systemd service file
# The installation directory is usually /opt/Farm Control Server
# but we can try to find it if it's different.
APP_DIR="/opt/Farm Control Server"
if [ ! -d "$APP_DIR" ]; then
    # Fallback to slugified name
    APP_DIR="/opt/farmcontrol-server"
fi

cp "$APP_DIR/resources/farmcontrol-server.service" /etc/systemd/system/farmcontrol-server.service

# Reload systemd to recognize the new service
systemctl daemon-reload

# Enable the service to start on boot
systemctl enable farmcontrol-server.service

# Start the service
systemctl start farmcontrol-server.service

