#!/bin/sh tool=$0 usage() { echo "" echo "usage: `/bin/basename $tool` -d configdir -p [-l|-v ] [-f] " echo "" echo " -d : the location of config files" echo " -p : get software for : n2" echo " -l : lists all available versions" echo " -v : get version " echo " -f : force create of " echo "" echo " Get of Solaris for and put it in directory" echo " . The directory is expected to not exist." echo " Use -f if the already exists." echo " Use -l to see the available Solaris versions for processor." echo "" } len () { echo $# } err () { echo "Error: $1" usage exit 2 } # Where we keep all the images for solaris # that are and have known to work. configdir="" processor="" get="solaris" version="" force=0 list=/bin/false while getopts d:hp:lv:f OPT; do case $OPT in d) configdir="$configdir $OPTARG" ;; p) processor="$processor $OPTARG" ;; l) list=/bin/true ;; v) version="$version $OPTARG" ;; f) force=1 ;; h) usage exit 0 ;; *) usage exit 2 ;; esac done shift `/bin/expr $OPTIND - 1` # make sure we have config files' location if [ "`len $configdir`" != "1" ]; then err "I need config files' location." fi # Make sure we have a processor if [ "`len $processor`" != "1" ]; then err "I need exactly one -p argument." fi processor=`echo $processor` root=$configdir/$processor if [ ! -d $root ]; then err "I don't have any software for this processor: $processor" fi root=$root/$get installdir=$1 # List versions or check the passed version if $list ; then l="" for v in ${root}/* ; do l="$l `/bin/basename $v`" done echo "Use -v with one of: $l" exit 0 fi if [ "`len $version`" != "1" ]; then err "I need exactly one version please." fi version=`echo $version` if [ ! -d ${root}/$version ]; then err "Version '$version' is not available for $get on $processor" fi # Check we have a directory to install the software if [ "$installdir" = "" ]; then err "Missing directory to install $get to at end of the command line." fi if [ "$force" = "0" -a -d $installdir ]; then err "Directory $installdir already exists, need a new directory name, or use -f." fi # Finally /bin/mkdir -p $installdir ( cd $installdir # create symbolic links for simulate script /bin/ln -s ${root}/${version}/.simulate.sh . /bin/ln -s ${root}/${version}/* . )