#
# Adding service for management
# $1 = service name
#
addService() {
    app_name=$1

    app_sys_config="/etc/sysconfig/${app_name}"
    [ -e "${app_sys_config}" ] && . "${app_sys_config}"
    if [ -n "${PACKAGE_PREFIX}" ] ;
    then
        default_install_location="${{chdir}}"
        actual_install_location="${PACKAGE_PREFIX}/${app_name}"

        sed -i "s|$default_install_location|$actual_install_location|g" "/usr/lib/systemd/system/${app_name}.service"
    fi

    systemctl enable "$app_name.service"
}

#
# Start the service
# $1 = service name
#
startService() {
    app_name=$1
    systemctl start "$app_name.service"
}

#
# Removing service from autostart
# $1 = service name
#

stopService() {
    app_name=$1

    systemctl stop "$app_name.service"
    systemctl disable "$app_name.service"
}

#
# Restarting the service after package upgrade
# $1 = service name
#
restartService() {
    app_name=$1

    systemctl daemon-reload
    systemctl try-restart "$app_name.service"
}

