Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
/bin/ksh
# install-repo.ksh
# unpacks and installs Solaris IPS repository
# args:
# location of zip files
# filesystem to set up repo
typeset mkiso=false
typeset imageopt=false
typeset verify=false
typeset ignoredeps=""
typeset chkdigest=false
typeset sumcomp=""
typeset singlezip=false
typeset firstpiece="_1of"
typeset isziprepo=""
typeset solimage=""
typeset ckfile=""
typeset autoadd=false
typeset DIGESTALG="sha256"
typeset DIGEST="/usr/bin/digest -a $DIGESTALG -v"
typeset OSTOPLEVEL="COPYRIGHT NOTICES"
Usage () {
cat << EOF
USAGE:
install-repo.ksh -d dest [-s zipsrc] [-i image-name] [-c] [-v] [-I] [-y]
if [ $# -eq 0 ]; then
Usage
exit 1
fi
typeset ZIPLOC=$(pwd)
shift OPTIND-1
if [ $# -gt 0 ]; then
echo "Too many arguments: $@"
Usage
exit 1
fi
if [ -z "$REPOLOC" ]; then
echo "ERROR: Missing -d argument for repository directory."
Usage
exit 1
fi
if [ -z "$image" ]; then
# -i option not used: need to determine which image to operate on
# Have to assume that latest zipped repo file is correct.
# Otherwise, no way of determining which to use.
# get list of all zip archives that may be the initial repo archive
typeset ziplist=$(ls -t $ZIPLOC/*.zip 2> /dev/null |
grep -v _[2-9]of 2> /dev/null)
# no zip files in directory
if [ -z "$ziplist" ];then
echo "Cannot locate any initial zip archive segments in \c"
echo "$ZIPLOC."
echo "Exiting."
exit 1
fi
if [ -z "$zip1" ];then
# cannot find any zip file containing publisher directory
echo "Cannot locate any initial zip archive segments in \c"
echo "$ZIPLOC."
echo "Exiting."
exit 1
fi
if [ -z "$solimage" ]; then
# define solimage to be same as image if not already set above
# it would not be defined if neither the -i nor -c option is used
typeset solimage=$image
# print out name of Solaris image to avoid confusion
[[ $imageopt == false ]] && echo "Using ${image} download."
else
# print out name of download image to avoid confusion
[[ $imageopt == false ]] &&
echo "Using ${image} files for ${solimage} download."
fi
typeset -i zipnum=1
typeset rebuild=false
typeset existingpubs=false
if [ -z "$ZIPCNT" ]; then
typeset -i ZIPCNT=$(ls $ZIPLOC/${image}_*of*.zip | wc -w | awk '{print $1}')
fi
# validate zip files
# need to compare .zip files with digests
if [ "$chkdigest" == true ]; then
if [ ! -f "$ckfile" ]; then
echo "Cannot find digest file $ckfile. Exiting."
exit 1
fi
# get first zip files, digest value, if not already defined
if [ -z "$sumcomp" ]; then
sumcomp=$($DIGEST $ZIPLOC/${image}${firstpiece}*.zip |
awk '{print $NF}')
fi
echo "\nComparing digests of downloaded files...\c"
if [ "$image" != "$solimage" ]; then
# since digest file is shipped with "solaris"-style naming,
# the file needs to be edited to use actual zip filenames
sed "s/$solimage/$image/" $ckfile > /tmp/cksumbase$$
else
cp $ckfile /tmp/cksumbase$$
fi
# generate digest values of downloaded files
(cd $ZIPLOC; $DIGEST $image*.zip) > /tmp/cksumdl$$
diff /tmp/cksumbase$$ /tmp/cksumdl$$ > /tmp/cksumdiff$$ || {
echo "\n< actual"
echo "> expected"
cat /tmp/cksumdiff$$
echo "Digests do not match. Please confirm that \c"
echo "${image} files exist"
echo "and should be used, or retry downloading mismatched files."
rm -f /tmp/cksum*$$
echo "Exiting."
exit 1
}
echo "done. Digests match.\n"
rm -f /tmp/cksum*$$
fi