#!/bin/sh
# sipb-xen-remote TYPE SERVICE [ARGS...]
#
# We carry out the remctl command proxied to us by the remote-control server.

TYPE="$1"
SERVICE="$2"
shift; shift;

case "$TYPE" in
    control)
        # $SERVICE is hostname
        COMMAND=/usr/sbin/sipb-xen-vmcontrol
	;;
    web)
        case "$SERVICE" in
            lvcreate|lvremove|lvrename|lvresize)
                COMMAND=/usr/sbin/sipb-xen-lvm
	        ;;
            vmboot)
                COMMAND=/usr/sbin/sipb-xen-vmcontrol
	        ;;
            listvms)
                COMMAND=/usr/sbin/sipb-xen-listvms
	        ;;
	    info)
		COMMAND=/usr/sbin/xm
		;;
            *)
                echo "ERROR: invalid subcommand"
                exit 34
                ;;
        esac
	;;
    *)
        echo "ERROR: invalid command"
        exit 34
        ;;
esac

#echo $COMMAND "$SERVICE" "$@"
$COMMAND "$SERVICE" "$@"
