#!/bin/sh

# SystemD
if which systemctl >/dev/null; then
    echo "Removing SystemD service: {{{project.artifactId}}}"
    systemctl stop "{{{project.artifactId}}}"
    systemctl disable "{{{project.artifactId}}}"
    systemctl daemon-reload
    exit 0
fi

# Upstart
if which initctl >/dev/null; then
    echo "Removing Upstart service: {{{project.artifactId}}}"
    initctl stop "{{{project.artifactId}}}"
    initctl reload-configuration
    exit 0
fi

# SystemV
if which invoke-rc.d >/dev/null; then
    echo "Removing SystemV service: {{{project.artifactId}}}"
    invoke-rc.d "{{{project.artifactId}}}" stop
    update-rc.d "{{{project.artifactId}}}" remove
    exit 0
fi

echo "Unable to find supported init system."
exit 1
