#!/usr/bin/env bash

# Start and enable the service on boot
start() {
    sudo systemctl enable am-filebeat.service > /dev/null 2>&1
    sudo systemctl start am-filebeat.service > /dev/null 2>&1
}

# Stop and disable the service on boot
stop() {
    sudo systemctl stop am-filebeat.service > /dev/null 2>&1
}

# Restart function - Stops and starts the service
restart() {
    sudo systemctl restart am-filebeat.service > /dev/null 2>&1
}

disable() {
    sudo systemctl disable am-filebeat.service > /dev/null 2>&1
}

case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    restart)
        restart
    ;;
    disable)
        disable
    ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac

exit 0