I try to do local repo for solaris 11. This is the script.
Code:
#!/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 ckfile=""
typeset CKSUM=/usr/bin/md5sum
Usage () {
cat << EOF
USAGE:
install-repo.ksh -d dest [-s zipsrc] [-i image-name] [-c] [-v] [-I]
-d dest = destination directory to hold repository
-s zipsrc = full path to directory holding zip files. default: current
directory
-i image = name of image: e.g. sol-11_2-26. default: name found in directory
-c = compare checksums of downloaded zip files
-v = verify repo after unzipping
-I = create an ISO image
Destination directory will contain top-level ISO files including README.
Repository is directly under destination.
ISO image is created in current directory, or zipsrc directory from -s argument.
EOF
}
if [ $# -eq 0 ]; then
Usage
exit 1
fi
typeset ZIPLOC=$(pwd)
while getopts Ii:s:d:vch char; do
case $char in
s) ZIPLOC=$OPTARG
if [ ! -d $ZIPLOC ] ; then
echo "$ZIPLOC: directory does not exist. Aborting."
exit 1
fi
[[ "$ZIPLOC" == /* ]] || {
echo "\n$ZIPLOC must use absolute pathname \c"
echo "starting with /. Aborting."
exit 1
}
;;
d) typeset REPOLOC=$OPTARG
if [ ! -d $REPOLOC ] ; then
echo "$REPOLOC: directory does not exist. Aborting."
exit 1
fi
[[ "$REPOLOC" == . ]] && typeset REPOLOC=$(pwd)
;;
v) typeset verify=true;;
i) typeset image=$OPTARG;;
I) typeset mkiso=true;;
c) typeset checkmd=true;;
h) Usage
exit ;;
\?) echo "use -h option for usage."
exit 1
;;
:) echo "Option -$OPTARG requires a value"
echo "use -h option for usage."
exit 1
;;
esac
done
if [ -z "$REPOLOC" ]; then
echo "ERROR: Missing -d argument for repository directory."
Usage
exit 1
fi
if [ -z "$image" ]; then
# Determine latest download name by default
typeset zip1=$(ls -t $ZIPLOC/*[_-]1of?.zip 2> /dev/null | head -1)
if [ -z "$zip1" ];then
echo "Cannot locate first \"1of*.zip\" archive segment."
exit 1
fi
typeset image=$(echo $zip1 | sed "s|.*/\(.*\)1of.*|\1|" | head -1)
if [ "$image" != sol-*-repo- ]; then
# get standard image name to use later
typeset solimage=$(ls -t $ZIPLOC/sol-*-repo-md5sums.txt | \
head -1 | sed -n "s|.*/\(.*\)-md5sums.txt|\1|p")-
# link original format names to download names
fi
else
if [ -f $ZIPLOC/${image}_1of* ]; then
image=${image}_
elif [ -f $ZIPLOC/${image}-1of* ];then
image=${image}-
else
echo "Cannot find zip images withe $image name."
exit 1
fi
fi
# define solimage to be same as image if not already set above
[[ -z "$solimage" ]] && typeset solimage=$image
typeset -i zipnum=1
typeset rebuild=false
# check if repo already exists, give option to abort
if [ -d $REPOLOC/publisher/solaris ]; then
currentrepo=$(pkg info -g $REPOLOC entire | \
sed -n "s/.*Branch: //p")
echo "IPS repository exists at destination $REPOLOC"
echo "Current version: $currentrepo"
echo "Do you want to add to this repository? (y/n) \c"
read answer
case $answer in
y|Y|yes|Yes) ;;
*)
echo "Please choose a different destination. Aborting."
exit 1
;;
esac
typeset rebuild=true
typeset zipreplace="-o"
fi
typeset -i ZIPCNT=$(ls $ZIPLOC/$image*of*.zip | wc -w | awk '{print $1}')
# validate zip files
# need to compare .zip files with md5 sums
if [ "$checkmd" == "true" ]; then
ckfile=$ZIPLOC/${solimage}md5sums.txt
if [ ! -f $ckfile ]; then
echo "Cannot find checksum file $ckfile. Aborting."
exit 1
fi
echo "\nComparing checksums of downloaded files...\c"
if [ "$image" != "$solimage" ]; then
sed "s/$solimage/$image/" $ckfile > /tmp/cksumbase$$
else
cp $ckfile /tmp/cksumbase$$
fi
(cd $ZIPLOC; $CKSUM $image*.zip) > /tmp/cksumdl$$
diff /tmp/cksumbase$$ /tmp/cksumdl$$ || {
echo "Checksums do not match. Please retry download on\c"
echo "mismatched files."
rm -f /tmp/cksum*$$
exit 1
}
echo "done. Checksums match.\n"
rm -f /tmp/cksum*$$
fi
typeset -i zipnum=1
while [ ! $zipnum -gt $ZIPCNT ]; do
zipname=$image${zipnum}of$ZIPCNT.zip
if [ ! -f $ZIPLOC/$zipname ]; then
echo file missing: $zipname
exit
fi
echo "Uncompressing $zipname...\c"
unzip -qd $REPOLOC $zipreplace $ZIPLOC/$zipname || exit 1
echo "done."
zipnum=zipnum+1
done
echo "Repository can be found in $REPOLOC."
# if adding to existing repo, rebuild catalog and index
if [ "$rebuild" == "true" ]; then
pkgrepo -s $REPOLOC rebuild || exit 1
fi
# pkgrepo verify is only available on s11.1.7 and above
if [ "$verify" == true ]; then
pkgrepo -s $REPOLOC verify || exit 1
fi
if [ "$mkiso" == true ]; then
echo "Building ISO image...\c"
solimage=${solimage%-}
VNAME=$(echo $solimage | /usr/gnu/bin/tr 'a-z' 'A-Z' |
sed "s/-REPO/_REPO/")
cd $REPOLOC
# Use the graft-points option to allow relocation of the repository itself
# into a repo subdirectory on the ISO
/usr/bin/mkisofs -o $ZIPLOC/$solimage.iso -no-limit-pathtables \
-l -allow-leading-dots -A "Oracle Solaris $solimage Release Repository" \
-publisher "Copyright 2014 Oracle and/or its affiliates. All rights reserved." \
-p pkg-inquiry_ww@oracle.com -R -uid 0 -gid 0 -V ${VNAME} -v -graft-points \
repo/publisher=publisher repo/pkg5.repository=pkg5.repository COPYRIGHT \
NOTICES README-repo-iso.txt > $ZIPLOC/mkiso.log 2>& 1
if [ $? -gt 0 ]; then
echo "\nError generating ISO file. Please check\c"
echo "$ZIPLOC/mkiso.log for errors."
fi
echo "done."
echo "ISO image and instructions for using the ISO image are at:"
echo "$ZIPLOC/${solimage}.iso"
echo "$ZIPLOC/README-repo-iso.txt"
fi
It's said some ^M missing.
Can anyone test on solaris machine? I'm offsite now.
Last edited by mzainal; 12-07-2014 at 12:29 AM..
Reason: test script
First of all, I want to salute everybody.
Since a week ago I put myself many troubles. :)
I decide to install Solaris 7, in a sun sparcstation 5, with raid5.
And I don't know almost anything about unix systems, not only Solaris. :)
I want to install mysql, apache, php4.
I'm not... (4 Replies)
08-11-2005, 03:23 PM I posted the below thread in UNIX for dummies Questions and Answers.
I thank the guy who posted a proposition to resolve my problem.
I decided to repost the problem here. Who knows :)
So, here it goes:
Since a week ago I put myself many troubles.
I decide to... (6 Replies)
I know that Sun make s a version of Solaris for Sparc platforms and also an x86 (Intel/AMD) release of Solaris. Can an application that runs on Solaris/Sparc also run on a PC running the x86 release of Solaris? Would a different release be required or any re-compling of the application?
jim (1 Reply)
am a newbie to solaris. can some one tell me whether solaris v10.0 comes with GUI or not?
if there is GUI, how do we switch between GUI and commandline.. (2 Replies)
I am having a hard time trying to find a repository that supports Gutsy 7.10 SPARC (I'm running a Sun Blade 1000 with an Ultra SPARC processor). Any idea how i can get a gui on my machine?
Thanks in advance for the help (2 Replies)
Hello there:-
Firstly, I think its probably a good idea to tell you i'm a bit of a Unix novice coming from the world of Windows but i'm getting there. I've had Ubuntu working at home on VirtualBox with a nice GUI, but i'm having an issue with Solaris 10.
I have at work a Solaris 10 machine... (6 Replies)