#!/bin/sh
# dialix - the Dialix command line on an appliance.
#
#   sudo dialix doctor          check this server and explain what is wrong
#   sudo dialix doctor --fix    also do the safe repairs
#   sudo dialix engine [asterisk|dialixengine|none]   show or choose the SIP engine
#   sudo dialix update [--install]                   check for / install a new Dialix
#
# The server itself runs as the systemd service `dialix`; this never starts a
# second copy of it.
case "${1:-}" in
  doctor|engine|update|--version|-V) ;;
  *) echo "usage: dialix doctor [--fix] [--json]" >&2
     echo "       dialix engine [asterisk|dialixengine|none]" >&2
     echo "       dialix update [--install] [--force]" >&2
     echo "       dialix --version" >&2
     echo "(the server runs as a service: systemctl status dialix)" >&2
     exit 2 ;;
esac
[ "$(id -u)" = 0 ] || exec sudo "$0" "$@"
cd /opt/dialix && exec /opt/dialix/dialix "$@"
