#!/bin/sh
#set -x

usage() {
  echo
  echo "Astium - an asterisk-based VoIP PBX. (c) 2004-2009 By NeoNova BV, The Netherlands."
  echo
  echo "Software Management commands:"
  echo "  astium install        - install astium"

  if [ -x /usr/local/astium/sbin/astiumd ]
  then
    echo "  astium uninstall      - uninstall astium"
    echo "  astium update         - update astium to latest version"
    echo
    echo " High Availability commands:"
    echo "  astium prepha         - prepare master & slave for High Availability. Run this *only* on the master."
    echo "  astium export2slave   - copy all data to the slave. Run this from cron."
    echo "  astium promote        - promote a slave to become the master. This change is permanent!"
    echo
    echo "Use astium help <command> for more information"
  fi 
  echo
  exit 1
}

if [ $# -eq 0 ]
then
  usage
fi
if [ "$1" = "help" ]
then
  if [ -z "$2" ]
  then
    usage
  else
    shift
  fi
fi

export PATH=/usr/local/astium/sbin:$PATH

if [ ! -x /usr/local/astium/sbin/astium.$1 ]
then
  echo "command '$1' not found"
  usage
  exit 1
fi

CMD=astium.$1
shift
exec $CMD $1 $2 $3 $4 $5 $6 $7 $8

