#!/bin/sh
# 
# -------------------------------------------------------------------
#                                   X-BONE
#
#                          http://www.isi.edu/xbone
#                USC Information Sciences Institute (USC/ISI)
#                   Marina del Rey, California 90292, USA
#                          Copyright (c) 1998-2005
# 
# -------------------------------------------------------------------
#
# Copyright (c) 1998-2005 by the University of Southern California.
# All rights reserved.
#
# Permission to use, copy, modify, and distribute this software and
# its documentation in source and binary forms for non-commercial
# purposes and without fee is hereby granted, provided that the above
# copyright notice appear in all copies and that both the copyright
# notice and this permission notice appear in supporting
# documentation, and that any documentation, advertising materials,
# and other materials related to such distribution and use acknowledge
# that the software was developed by the University of Southern
# California, Information Sciences Institute.  The name of the
# University may not be used to endorse or promote products derived
# from this software without specific prior written permission.
# 
# THE UNIVERSITY OF SOUTHERN CALIFORNIA MAKES NO REPRESENTATIONS ABOUT
# THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE.  THIS SOFTWARE IS
# PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Other copyrights might apply to parts of this software and are so
# noted when applicable.
#
# -------------------------------------------------------------------
#
# Effort partly sponsored by the Defense Advanced Research Projects
# Agency (DARPA) and Air Force Research Laboratory, Air Force Materiel
# Command, USAF, under agreement numbers F30602-98-1-0200 (X-Bone) and
# F30602-01-2-0529 (DynaBone). The views and conclusions contained
# herein are those of the authors and should not be interpreted as
# necessarily representing the official policies or endorsements,
# either expressed or implied, of the Defense Advanced Research
# Projects Agency (DARPA), the Air Force Research Laboratory, or the
# U.S. Government.
#
# This work was partly supported by the NSF STI-XTEND (ANI-0230789)
# and NETFS (ANI-0129689) projects. Any opinions, findings, and
# conclusions or recommendations expressed in this material are those
# of the authors and do not necessarily reflect the views of the
# National Science Foundation.
#
# -------------------------------------------------------------------
#  $RCSfile: sample-app-deploy-script.sh,v $
#
# $Revision: 1.3 $
#   $Author: pingali $
#     $Date: 2005/03/31 07:03:42 $
#    $State: Exp $
# ----------------------------------------------------------------------------
#
# Primary Author: Yu-Shun Wang

# ========================================================================
# XBone Application Deployment Script Example
# ========================================================================

# ========================================================================
# Standard Virtual Network (Overlay) Application Deployment Arguments
# ========================================================================
# - node parameters
#   i: virtual IP address(es)
#   I: base    IP address
#   h: virtual hostname
#   H: base    hostname
#   f: interface(s)
#
# - overlay parameters
#   a: all virtual IP addresses
#   A: all base    IP addresses
#   n: all virtual hostnames
#   N: all base    hostname
#   d: overlay DNS domain suffix
#   p: overlay network prerix
#   O: overlay manager IP address
#   P: overlay manager XBone API port
#

args=`getopt t:i:I:h:H:f:a:A:n:N:d:p:O:P: $*`

if [ $? != 0 ]
then
  echo 'Usage: ...'
  exit 2
fi
set -- $args

for i
do
  case "$i"
  in
    -t)
        echo target is "'"$2"'"; target="$2"; shift;
        shift;;
    -i)
        echo [i] Virtual IP       "'"$2"'"; iarg="$2"; shift;
        shift;;
    -I)
        echo [I] Base    IP       "'"$2"'"; Iarg="$2"; shift;
        shift;;
    -h)
        echo [h] Virtual hostname "'"$2"'"; harg="$2"; shift;
        shift;;
    -H)
        echo [H] Base    hostname "'"$2"'"; Harg="$2"; shift;
        shift;;
    -f)
        echo [f] Interface list   "'"$2"'"; farg="$2"; shift;
        shift;;
    -a)
        echo [a] All Virtual IP   "'"$2"'"; aarg="$2"; shift;
        shift;;
    -A)
        echo [A] All Base    IP  "'"$2"'"; Aarg="$2"; shift;
        shift;;
    -n)
        echo [n] All Virtual hostname "'"$2"'"; narg="$2"; shift;
        shift;;
    -N)
        echo [N] All Base    hostname "'"$2"'"; Narg="$2"; shift;
        shift;;
    -d)
        echo [d] Overlay Domain  "'"$2"'"; darg="$2"; shift;
        shift;;
    -p)
        echo [p] Overlay Prefix  "'"$2"'"; parg="$2"; shift;
        shift;;
    -O)
        echo [O] OM base IP      "'"$2"'"; Oarg="$2"; shift;
        shift;;
    -P)
        echo [P] OM API port     "'"$2"'"; Parg="$2"; shift;
        shift;;
    --)
        shift; break;;
  esac
done
echo target is "'"$target"'"

WHOAMI=/usr/bin/whoami

#- Script starts -------------------------------------------------------------

case "$target" in

  verify)
    echo ">>> [Test-App] Verify"
    $WHOAMI
    echo "<<< [Test-App] verified"
    exit 1
    ;;

  conf)
    echo ">>> [Test-App] Configuration"
    whoami
    echo "<<< [Test-App] configured"
    ;;

  run)
    echo ">>> [Test-App] Run"
    whoami
    echo "<<< [Test-App] started"
    ;;

  pid)
    ;;

  kill)
    echo ">>> [Test-App] Kill"
    whoami
    echo "<<< [Test-App] killed"
    ;;

  cleanup)
    echo ">>> [Test-App] Cleanup"
    whoami
    echo "<<< [Test-App] cleaned"
    ;;

  install)
    echo ">>> [Test-App] Install"
    whoami
    echo "<<< [Test-App] installed"
    ;;

  deinstall)
    echo ">>> [Test-App] Deinstall"
    echo "<<< [Test-App] deinstalled"
    ;;

esac

exit 0


syntax highlighted by Code2HTML, v. 0.9.1