#!/bin/sh

case "$1" in
    'start')
        sudo -H -u wildfly bash -c '/opt/codiki-integ/bin/codiki-integ.sh start'
        ;;
    'stop')
        sudo -H -u wildfly bash -c '/opt/codiki-integ/bin/codiki-integ.sh stop'
        ;;
    'status')
        sudo -H -u wildfly bash -c '/opt/codiki-integ/bin/codiki-integ.sh status'
        ;;
    'restart')
        sudo -H -u wildfly bash -c '/opt/codiki-integ/bin/codiki-integ.sh restart'
        ;;
    *)
        # If no argument, we launch the app in case of server startup
        sudo -H -u wildfly bash -c '/opt/codiki-integ/bin/codiki-integ.sh start &>/dev/null'
        # And show the script usage
        echo "Usage: /etc/init.d/codiki-integ {start|stop|status|restart}\n" >&2
        exit 3
        ;;
esac
exit 0