Howdy Sis Developers,

I've written a bash version of the Systemimager installer.pl that I'd like to submit to the project. This is, of course released under the GPL (or even freeware).

It _only_ knows how to download the stable software (I'm assuming a developer knows how to install the Perl dependencies to get installer.pl working), but maybe the first time or new user would find it helpful to have a bash script that doesn't depend on anything (well, it needs wget) to download the stable software.

--K

#!/bin/bash
#
#       installer.bash -- Duplicates most of installer.pl program in BASH
#
#               Installs (only) the latest stable using BASH script
#       (only requires the "wget" program). Does not actually install
#       the software. Requires the user to type "rpm" command after packages
#       are downloaded.
#
#              Released under the GPL.
#
#
stable="http://sisuite.org/tags/stable.txt";
url="http://sisuite.org/tags/stable.txt";
directory="/tmp/sis-packages"

help () {
echo "
installer [--help] [--verbose]
         [--bootarch {none|all|i386|ia64|ppc64|ppc64-iSeries}]
         [ --install {client|server|both} ]

--help
--verbose
--location Use alternative download directory (defaults to
\'/tmp/sis-packages\')
--install TYPE Install packages for this type of system. TYPE can be
\"client\", \"server\", or \"both\".
--bootarch TYPE Download the boot rpm(s) for the specified arch. \'all\'
downloads all available. Defaults to architecture of the
host machine.
"
}


calculate_arch () {
arch=`uname -p`
case $arch in
        i.86) arch="i386" ;;
       ppc64)
             if [ -d /proc/iSeries ]; then
              arch="ppc64-iSeries"
              fi
       ;;
       *) arch="i386" ;;
esac
}


download_package_list () { which wget > /dev/null if [ "$?" -eq 1 ]; then echo "$0: Please install the wget program to use $0." exit 1 fi rm -f $local_list_name if [ "$verbose" = "y" ]; then echo "Downloading packages using verbose mode." cmd="wget --timestamping -O $local_list_name $url" else cmd="wget --quiet --timestamping -O $local_list_name $url" fi $cmd if [ "$?" -eq 0 ]; then if [ "$verbose" = "y" ]; then echo "$0: Successfully downloaded $url to $local_list_name." fi else echo "$0: Couldn't download package list from $url!"; echo "$0: Are you able to see $url from your browser?"; exit 1; fi }

should_download () {
# Returns 0 if the selected bootarch ($arch) variable
# indicates this file (url) should be downloaded.
echo $@
case $arch in
 all) return 0;;
 none) return 1;;
 *)
   # basename =~ /systemimager-(.*)boot/
   echo $@ | grep "systemimager-".*"boot" > /dev/null
   if [ "$?" -eq 0 ]; then
    # Okay to download the arch specific boot RPMS
    echo $@ | grep $arch > /dev/null
    RETVAL=$?
    return $RETVAL
   else
    # Always okay (as far as we are concerned)
    # to download non-boot RPMS.
    return 0
   fi
   ;;
esac
}

download_packages () {
if [ "$verbose" = "y" ]; then
#wget_opts="--continue --timestamping"
wget_opts=" --timestamping"
else
wget_opts="--quiet --continue --timestamping"
fi
cd $directory
while read line
do
type=`echo $line | awk '{printf "%s\n",$1}'`
url=`echo $line | awk '{printf "%s\n",$2}'`
cmd="wget $wget_opts $url"
if [ "$type" = "common" ]; then
$cmd
if [ "$?" -ne 0 ]; then
echo "$0: $cmd failed!"
exit 1
fi
else
if [ "$install" = "$type" -o "$install" = "both" -o "$install" = "all" ]; then
# Matched on client/server/common line, now check if the
# selected architecture (for boot files really) still
# permits us to download the file.
should_download $line
should=$?
if [ "$should" -eq 0 ]; then
$cmd
if [ "$?" -ne 0 ]; then
echo "$0: $cmd failed!"
exit 1
fi
fi
fi
fi
done<${local_list_name}
}



# --------- M A I N -----------


# Getoptions
while :
do
   case "$1" in
       --help|-help|-h) help ; exit;;
       --verbose|-verbose|-v) verbose="y"; shift;;
        --location|-location|-l) directory=$2 ; shift ; shift;;
        --install|-install|-i) install=$2 ; shift ; shift;;
        --bootarch|-bootarch|-b) arch=$2 ; shift ; shift;;
       -*) help; exit 1;;
       *) break ;;
   esac
done

# Validation of options

# install
if [ ! "$install" ]; then
install="all"
fi
case $install in
client|server|both) : ;;
*) help; exit;;
esac

# location
if [ ! -e $directory ]; then
mkdir $directory
if [ "$?" -ne 0 ]; then
echo "$0: Could not create $directory."
exit 1
fi
fi
if [ ! -d $directory ]; then
echo "$0: $directory not a directory."
exit 1
fi
cd $directory
if [ "$?" -ne 0 ];then
echo "$0: Cannot change directory to $directory."
exit 1
fi
local_list_name=`echo $directory/stable.txt`
# echo "Local_list_name is $local_list_name"
touch $local_list_name
if [ "$?" -ne 0 ];then
echo "$0: Cannot create $local_list_name."
exit 1
fi

# bootarch
if [ ! "$arch" ]; then
calculate_arch
fi
case $arch in
none|all|i386|ppc64|ppc64-iSeries) : ;;
*) echo "$0: Error --bootarch must be one of {none|all|i386|ia64|ppc64|ppc64-iSeries}" ;;
esac



# Syntax must be okay -- Go get the software download_package_list download_packages

rm $local_list_name

# Parting message
echo "
################################################################################

Thanks for using System Installation Suite. Please send any questions to
[EMAIL PROTECTED] If you are using a development release,
please send constructive feedback to [EMAIL PROTECTED]


You can find documentation on SystemInstaller, SystemImager, and System
Configurator (the three components of System Installation Suite) in the
/usr/share/doc directory on your system, or at the following websites:

  http://systeminstaller.sourceforge.net/
  http://systemimager.org/
  http://systemconfig.sourceforge.net/

More information on System Installation Suite, the meta-project, can be found
at http://sisuite.org/.


################################################################################

The System Installation Suite packages have been downloaded to:

$directory

To install, simply:

  cd $directory
  rpm -Uvh *rpm

################################################################################
"

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail




-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Sisuite-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/sisuite-devel

Reply via email to