#! /bin/sh
##
## sipxconfig-config
##
## Copyright (C) 2004 SIPfoundry Inc.
## Licensed by SIPfoundry under the LGPL license.
## 
## Copyright (C) 2004, 2005 Pingtel Corp.
## 
## 

Action=PRINT
Info=""

prefix=/usr/local
exec_prefix=@exec_prefix@
includedir=@includedir@
libdir=/usr/local/lib

while [ $# -ne 0 ]
do
    case ${1} in
        --bin)
            Info="${Info} /usr/local/bin"
            ;;

        --include)
            Info="${Info} /usr/local/include"
            ;;

        --lib)
            Info="${Info} /usr/local/lib"
            ;;

        --host)
            Info="${Info} @host@"
            ;;

        --version)
            Info="${Info} 3.6.0"
            ;;

        --build)
            Info="${Info} 008527 2007-12-17T09:00:45 freebsd.org"
            ;;

        --conf)
            Info="${Info} /usr/local/etc/sipxpbx"
            ;;

        --data)
            Info="${Info} /usr/local/share/sipxpbx"
            ;;

        --log)
            Info="${Info} /var/log/sipxpbx"
            ;;

        --run)
            Info="${Info} /var/run/sipxpbx"
            ;;

        --db)
            Info="${Info} /var/sipxdata/sipdb"
            ;;

        --all)
            Action=ALL
            break
            ;;

        --configopts)
            Info="${Info}  --enable-sip-tls --localstatedir=/var --enable-ruby-bindings --mandir=/usr/local/man --infodir=/usr/local/info/ amd64-portbld-freebsd6 --enable-sip-tls --localstatedir=/var --enable-ruby-bindings --mandir=/usr/local/man --infodir=/usr/local/info/ amd64-portbld-freebsd6"
            ;;

        --help)
            Action=USAGE
            break
            ;;

        ##
        ## handle an unknown switch
        ##
        -*)
            echo "Unknown switch '${1}'" 1>&2
            Action=USAGE
            ;;
    esac           

    shift # always consume 1
done

if [ "${Action}" = "PRINT" -a "${Info}" = "" ]
then
    Action=USAGE
fi

case ${Action} in

    USAGE)
        cat <<EOF
Usage: sipxconfig-config [OPTIONS]
 
     Option:      Displays:

    --bin         executable installation directory
    --include     header file installation directory
    --lib         object-code installation directory
    --conf        configuration directory
    --data        run time data directory
    --log         log directory
    --run         pid directory
    --db          database directory
    --host        host information
    --version     version information
    --build       build information

    --all         all of the above, with labels
    --configopts  options passed to the configure script when this was built

    --help        this message
EOF
        exit
        ;;

    PRINT)
        echo ${Info}
        ;;

    ALL)
        cat <<EOF
sipxconfig version  3.6.0
sipxconfig build    008527 2007-12-17T09:00:45 freebsd.org
sipxconfig bin      /usr/local/bin
sipxconfig include  /usr/local/include
sipxconfig lib      /usr/local/lib
sipxconfig host     @host@
sipxconfig conf     /usr/local/etc/sipxpbx
sipxconfig data     /usr/local/share/sipxpbx
sipxconfig log      /var/log/sipxpbx
sipxconfig run      /var/run/sipxpbx
sipxconfig db       /var/sipxdata/sipdb
sipxconfig cfgopts   --enable-sip-tls --localstatedir=/var --enable-ruby-bindings --mandir=/usr/local/man --infodir=/usr/local/info/ amd64-portbld-freebsd6 --enable-sip-tls --localstatedir=/var --enable-ruby-bindings --mandir=/usr/local/man --infodir=/usr/local/info/ amd64-portbld-freebsd6
EOF
        ;;

esac

exit
