[355] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 |
|
---|
| 4 | ##########################################################################
|
---|
| 5 | # SETUP for Mondo/Mindi installation CD, by Hugo Rabson
|
---|
| 6 | #
|
---|
| 7 | #
|
---|
| 8 | # 07/14
|
---|
| 9 | # - added SLES support
|
---|
| 10 | # - added NNA support
|
---|
| 11 | #
|
---|
| 12 | # 06/29/2004
|
---|
| 13 | # - if finals and snapshots are present, use snapshots
|
---|
| 14 | #
|
---|
| 15 | # 06/20/2004
|
---|
| 16 | # - patch by Geofuz@netscape.com
|
---|
| 17 | #
|
---|
| 18 | # 06/08/2004
|
---|
| 19 | # - upgraded to Mondo 2.0, Mindi 1.0
|
---|
| 20 | # - fixed bug related to softlinks (xxx.86-64 --> xxxx.amd64)
|
---|
| 21 | #
|
---|
| 22 | # 05/23/2004
|
---|
| 23 | # - added SuSE 9.1 (64-bit) slang/newt workaround
|
---|
| 24 | #
|
---|
| 25 | # 04/25/2004
|
---|
| 26 | # - fixed bug which stopped RPM-based distros whose dirs are softlinks
|
---|
| 27 | # from having their dependencies resolved properly
|
---|
| 28 | #
|
---|
| 29 | # 04/15/2004
|
---|
| 30 | # - fixed RHT9-specific Mondo/Mindi installation bug
|
---|
| 31 | #
|
---|
| 32 | # 04/02/2004
|
---|
| 33 | # - added RHE2.1 support
|
---|
| 34 | #
|
---|
| 35 | # 03/29/2004
|
---|
| 36 | # - added Fedora 2 and SuSE 8.1 support (thanks, Mike Roark, for slang RPM)
|
---|
| 37 | #
|
---|
| 38 | # 03/25/2004
|
---|
| 39 | # - changed $command from 'rpm -Uvh ...' to just '...'; now, it's called
|
---|
| 40 | # as 'rpm -Uvh $command' not '$command' --- required for SuSE 9
|
---|
| 41 | # compatibility
|
---|
| 42 | #
|
---|
| 43 | # 03/23/2004
|
---|
| 44 | # - added Knoppix 3.3 preliminary support
|
---|
| 45 | #
|
---|
| 46 | # 02/22/2004
|
---|
| 47 | # - added Mitel 6.0 support (a.k.a. SME 6.0)
|
---|
| 48 | #
|
---|
| 49 | # 01/15/2004
|
---|
| 50 | # - added RHE 3.0 to the mix
|
---|
| 51 | #
|
---|
| 52 | # 01/02/2004
|
---|
| 53 | # - FindMissingRPMs() was installing finals, not snapshots, under
|
---|
| 54 | # certain circumstances - FIXED
|
---|
| 55 | #
|
---|
| 56 | # 11/18/2003
|
---|
| 57 | # - make sure to remove all _old_ mindi, mondo stuff from HDD
|
---|
| 58 | #
|
---|
| 59 | # 10/20/2003
|
---|
| 60 | # - added Fedore Core support
|
---|
| 61 | #
|
---|
| 62 | # 10/19/2003
|
---|
| 63 | # - added code to distinguish zisofs from zisofs-tools when looking
|
---|
| 64 | # for missing RPMs
|
---|
| 65 | #
|
---|
| 66 | # 10/16/2003
|
---|
| 67 | # - friendlier messages re: umount /mnt/cdrom
|
---|
| 68 | #
|
---|
| 69 | # 10/06/2003
|
---|
| 70 | # - better handling of dirs w/ final & snapshot in them at same time
|
---|
| 71 | #
|
---|
| 72 | # 09/22/2003
|
---|
| 73 | # - added SuSE and Trustix to the mix
|
---|
| 74 | # - uninstall cdrecord if version is < 1.10
|
---|
| 75 | #
|
---|
| 76 | # 09/08/2003
|
---|
| 77 | # - added partimagehack to the mix
|
---|
| 78 | #
|
---|
| 79 | # 07/31/2003
|
---|
| 80 | # - fixed input param bug
|
---|
| 81 | #
|
---|
| 82 | # 05/20/2003
|
---|
| 83 | # - added code to deal with mindi-kernel rpm
|
---|
| 84 | #
|
---|
| 85 | # 05/03/2003
|
---|
| 86 | # - copy self to /tmp/$RANDOM.$RANDOM.txt and run from there
|
---|
| 87 | # - unmount (if not supermount) and eject CD at end of install
|
---|
| 88 | #
|
---|
| 89 | # 04/25/2003
|
---|
| 90 | # - pause before exiting, even Die()'ing
|
---|
| 91 | #
|
---|
| 92 | # 01/10/2003
|
---|
| 93 | # - misc bugs fixed
|
---|
| 94 | #
|
---|
| 95 | # 12/10/2002
|
---|
| 96 | # - misc bugs fixed
|
---|
| 97 | #
|
---|
| 98 | # 12/07/2002
|
---|
| 99 | # - changed ALX to ARK (ArkLinux)
|
---|
| 100 | #
|
---|
| 101 | # 11/31/2002
|
---|
| 102 | # - report success/failure at end
|
---|
| 103 | #
|
---|
| 104 | # 11/29/2002
|
---|
| 105 | # - tweaked it to automount; also to look for mondo/mindi RPMs in
|
---|
| 106 | # the distro's directory before trying the vanilla RPMs
|
---|
| 107 | #
|
---|
| 108 | # 08/12/2002
|
---|
| 109 | # - minor tweaks
|
---|
| 110 | #
|
---|
| 111 | # 03/29/2002
|
---|
| 112 | # - started keeping a changelog in here
|
---|
| 113 | ##########################################################################
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | InBkgd() {
|
---|
| 117 | cd /
|
---|
| 118 | sleep 1
|
---|
| 119 | umount $1
|
---|
| 120 | eject $2
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | # ------------------------- main -------------------------
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | LOGFILE=/tmp/mondo-setup.log
|
---|
| 127 | STABLE_BRANCH=2.0
|
---|
| 128 | DEVEL_BRANCH=2.1
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | Die() {
|
---|
| 134 | LogIt "$1"
|
---|
| 135 | LogIt ""
|
---|
| 136 | echo -en "Press ENTER to abort." 2> /dev/stderr
|
---|
| 137 | read line
|
---|
| 138 | cd /
|
---|
| 139 | exit 1
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | GetDistroBanner() {
|
---|
| 145 | local fname res
|
---|
| 146 |
|
---|
| 147 | if uname -a | grep Knoppix > /dev/null ; then
|
---|
[1526] | 148 | echo "Knoppix LiveCD"
|
---|
| 149 | return
|
---|
[355] | 150 | fi
|
---|
| 151 |
|
---|
[911] | 152 | res=`cat /etc/issue.net 2>/dev/null | grep -i turbolinux | head -n1`
|
---|
[355] | 153 | if [ "$res" != "" ] ; then
|
---|
| 154 | echo "$res"
|
---|
| 155 | return
|
---|
| 156 | fi
|
---|
| 157 |
|
---|
[1526] | 158 | for fname in `find /etc -maxdepth 1 | grep -E 'release|issue'` ; do
|
---|
[911] | 159 | res=`cat $fname 2>/dev/null | grep -i "linux" | head -n1 | tr -s '\t' ' '`
|
---|
[355] | 160 | [ "$res" = "" ] && res=`cat $fname |head -n1 | tr -s '\t' ' '`
|
---|
| 161 | if [ "$res" != "" ] ; then
|
---|
| 162 | echo "$res"
|
---|
| 163 | return
|
---|
| 164 | fi
|
---|
| 165 | done
|
---|
| 166 | #echo "fname = $fname" > /dev/stderr
|
---|
| 167 |
|
---|
| 168 | echo "UNKNOWN"
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | #GetDistroBanner
|
---|
| 172 | #exit 0
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | GetDistroName() {
|
---|
| 176 | local banner name
|
---|
| 177 | banner="`GetDistroBanner`"
|
---|
| 178 | name="X" ;# unknown
|
---|
| 179 | #echo "banner = $banner" >> /dev/stderr
|
---|
| 180 | StrStr "`cat /etc/issue.net 2> /dev/null | head -n1`" "SuSE Linux Openexchange" && name=SLX; # SuSE Openexchange
|
---|
| 181 | StrStr "`cat /etc/issue.net 2> /dev/null | head -n1`" "SuSE SLES" && name=SLE; # SLES
|
---|
| 182 | StrStr "$banner" "OpenNA" && name="NNA" ;# OpenNA
|
---|
| 183 | StrStr "$banner" "Fedora" && name="FDR" ;# Fedora
|
---|
| 184 | StrStr "$banner" "Red Hat" && name="RHT" ;# Red Hat
|
---|
| 185 | StrStr "$banner" "Red Hat Linux Advanced" && name="RHE" ;# Red Hat E
|
---|
| 186 | StrStr "$banner" "Red Hat Linux Enterprise" &&name="RHE" ;# Red Hat E
|
---|
| 187 | StrStr "$banner" "Red Hat Advanced" && name="RHE"
|
---|
| 188 | StrStr "$banner" "Red Hat Enterprise" && name="RHE"
|
---|
| 189 | StrStr "$banner" "White Box Enterprise" && name="RHE";# Red Hat Enterpr.
|
---|
| 190 | StrStr "$banner" "Red Hat Enterprise" && name="RHE"
|
---|
| 191 | StrStr "$banner" "Mandrake" && name="MDK" ;# Mandrake
|
---|
| 192 | StrStr "$banner" "e-Smith" && name="SME" ;# e-Smith / SME
|
---|
| 193 | StrStr "$banner" "SME Server" && name="SME" ;# e-Smith / SME
|
---|
| 194 | StrStr "$banner" "Mitel" && name="SME" ;# Mitel a.k.a. SME
|
---|
| 195 | StrStr "$banner" "SuSE" && name="SUS" ;# SuSE
|
---|
| 196 | StrStr "$banner" "Trustix" && name="TSL" ;# Trustix
|
---|
| 197 | uname -a | grep Knoppix > /dev/null && name="KPX" ;# Knoppix
|
---|
| 198 | if StrStr "$banner" "Turbolinux" ; then
|
---|
| 199 | StrStr "$banner" "Server" && name="TLS" ;# TurboLinux Server
|
---|
| 200 | StrStr "$banner" "Server" || name="TLW" ;# TurboLinux WorkSt'n
|
---|
| 201 | fi
|
---|
| 202 | if StrStr "$banner" "Caldera" ; then
|
---|
| 203 | StrStr "$banner" "Server" && name="CALe";# Caldera e-Server
|
---|
| 204 | StrStr "$banner" "Server" || name="CALo";# Caldera OpenLinux
|
---|
| 205 | fi
|
---|
| 206 | if [ "$name" != "RHE" ] ; then
|
---|
| 207 | for i in "ArkLinux ARK" "Gentoo GEN" "RedHat RHT" "Mandrake MDK" ; do
|
---|
| 208 | d=`echo "$i" | cut -d' ' -f1`
|
---|
| 209 | e=`echo "$i" | cut -d' ' -f2`
|
---|
| 210 | if strings /etc/ld.so.cache | grep -i "$d" &> /dev/null ; then
|
---|
| 211 | echo $e
|
---|
| 212 | return
|
---|
| 213 | fi
|
---|
| 214 | done
|
---|
| 215 | fi
|
---|
| 216 | echo "$name"
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 |
|
---|
| 220 |
|
---|
| 221 | FindMissingRPMs() {
|
---|
| 222 | local i pkg missing_packages j todo k blah q
|
---|
| 223 | missing_packages=""
|
---|
| 224 | todo=`find $1/*.rpm | grep -v mondo | grep -v mindi`
|
---|
| 225 | if [ "`GetDistroName`" = "NNA" ] ; then
|
---|
| 226 | echo "Sorry - no mindi-kernel or partimagehack for OpenNNA" > /dev/stderr
|
---|
| 227 | else
|
---|
| 228 | for i in mindi-kernel partimagehack ; do
|
---|
| 229 | # "mindi-$MINDI_BRANCH" "mondo-$MY_BRANCH" ; do
|
---|
| 230 | [ "`echo "$i" | grep mindi`" ] && qq=head || qq=tail
|
---|
| 231 | j=`find $1/ -type f -maxdepth 1 | grep "$i" | $qq -n1`
|
---|
[911] | 232 | [ ! "$j" ] && j=`find RPMS/ -type f -maxdepth 1 | grep -F "$i" | $qq -n1`
|
---|
[355] | 233 | if [ ! "$j" ] ; then
|
---|
| 234 | echo "Looking for $i" >> /dev/stderr
|
---|
| 235 | echo "Looking in $1" >> /dev/stderr
|
---|
| 236 | echo "pwd = `pwd`" >> /dev/stderr
|
---|
| 237 | echo "I ran 'find $1 -type f -maxdepth 1 | grep $i" >> /dev/stderr
|
---|
| 238 | Die "Unable to find $i in $1 or RPMS/"
|
---|
| 239 | fi
|
---|
| 240 | todo="$todo $j"
|
---|
| 241 | done
|
---|
| 242 | fi
|
---|
| 243 |
|
---|
| 244 | # echo "todo = '$todo'" >> /dev/stderr
|
---|
| 245 |
|
---|
| 246 | for i in $todo ; do
|
---|
| 247 | # echo "i = $i" > /dev/stderr
|
---|
| 248 | [ -d "$i" ] && continue
|
---|
| 249 | StrStr "$i" ".rpm" || continue
|
---|
| 250 | i=`basename $i`
|
---|
| 251 | j=`echo "$i" | tr '.' '#' | sed s/#rpm// | sed s/#i[3-8]86// | tr -s '#' '.'`
|
---|
| 252 | k=`echo "$j" | cut -d'-' -f1`
|
---|
| 253 | for blah in devel doc http kernel libs newt theme tools ; do
|
---|
| 254 | if echo "$j" | grep "\-$blah" &> /dev/null ; then
|
---|
| 255 | k=`echo "$j" | cut -d'-' -f1,2`
|
---|
[911] | 256 | if echo "$j" | grep -E '^[A-Z,a-Z]*-[A-Z,a-Z]*-[A-Z,a-z]*-.*$' &> /dev/null ; then
|
---|
[355] | 257 | k=`echo "$j" | cut -d'-' -f1,2,3`
|
---|
| 258 | fi
|
---|
| 259 | fi
|
---|
| 260 | done
|
---|
| 261 | rpm -q $k &> /dev/null && continue
|
---|
| 262 | ## remove xmondo thingy
|
---|
| 263 | echo "$i" | grep xmondo &> /dev/null && continue
|
---|
| 264 | missing_packages="$missing_packages $i"
|
---|
| 265 | done
|
---|
| 266 | echo "$missing_packages"
|
---|
| 267 | }
|
---|
| 268 |
|
---|
| 269 |
|
---|
| 270 |
|
---|
| 271 | GetDistroVersion() {
|
---|
| 272 | local banner i res j
|
---|
| 273 | banner="`GetDistroBanner`"
|
---|
| 274 | res=""
|
---|
| 275 | j="`cat /etc/issue.net 2> /dev/null | head -n1`"
|
---|
| 276 | if StrStr "$j" "Openexchange" || StrStr "$j" "SLES" ; then
|
---|
| 277 | banner="$j"
|
---|
| 278 | fi
|
---|
| 279 | # echo "banner = $banner" >> /dev/stderr
|
---|
| 280 | for i in $banner ; do
|
---|
[911] | 281 | j=`echo $i | grep -E '^[v|V][0-9]+*.*$'`
|
---|
| 282 | [ ! "$j" ] && j=`echo $i | grep -E '^[0-9]+*.*$'`
|
---|
| 283 | echo "$j" | grep -E '^[0-9]*)$' > /dev/null && continue
|
---|
[355] | 284 | [ "$j" ] && res=`echo $j | sed s/v// | sed s/V//`
|
---|
| 285 | done
|
---|
| 286 | [ "$res" = "2.1AS" ] && res="2.1"
|
---|
| 287 | if echo "$banner" | grep SLES &> /dev/null ; then
|
---|
| 288 | res="`echo "$banner" | sed s/SLES/#/ | cut -d'#' -f2 | cut -d' ' -f2`"
|
---|
| 289 | # echo "banner = $banner"
|
---|
| 290 | # echo "res = $res"
|
---|
| 291 | fi
|
---|
| 292 | [ "$res" ] && echo "$res"
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 |
|
---|
| 296 | GetDistroArchitecture() {
|
---|
| 297 | local arch
|
---|
| 298 | for arch in x86_64 x86-64 amd64 opteron ia64 ; do
|
---|
| 299 | if grep -i "$arch" /etc/issue.net &> /dev/null ; then
|
---|
| 300 | # [ "$arch" = "x86_64" ] && arch=amd64; # hack - FIXME
|
---|
| 301 | echo $arch
|
---|
| 302 | return 0
|
---|
| 303 | fi
|
---|
| 304 | done
|
---|
| 305 |
|
---|
| 306 | for arch in itanium ; do
|
---|
| 307 | if grep -i "$arch" /etc/issue.net &> /dev/null ; then
|
---|
| 308 | echo itan
|
---|
| 309 | return 0
|
---|
| 310 | fi
|
---|
| 311 | done
|
---|
| 312 |
|
---|
| 313 | echo ia32
|
---|
| 314 | return 0
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 |
|
---|
| 318 |
|
---|
| 319 |
|
---|
| 320 |
|
---|
| 321 | InstallFromRpms() {
|
---|
| 322 | local distro_TLA distro_ver distro_title replacement ch res q distro_arch rpms_path
|
---|
| 323 | distro_TLA=$1
|
---|
| 324 | distro_ver=$2
|
---|
| 325 | distro_arch=$3
|
---|
| 326 | # Look in directory 'RPMS/$distro_TLA' for a file called 'name' which contains
|
---|
| 327 | # the user-friendly name of this distribution.
|
---|
| 328 | distro_title=`cat RPMS/$distro_TLA/name`
|
---|
| 329 | echo "InstallFromRPMS($distro_TLA,$distro_ver,$distro_arch) --- title = $distro_title" >> $LOGFILE
|
---|
| 330 | # $CDPATH/
|
---|
| 331 | rpms_path=RPMS/$distro_TLA/$distro_ver
|
---|
| 332 | [ "$distro_arch" != "ia32" ] && rpms_path=$rpms_path.$distro_arch
|
---|
| 333 |
|
---|
| 334 | # Find a (compatible) version closest or identical to this user's version.
|
---|
| 335 | if [ ! -d "$rpms_path" ] ; then
|
---|
| 336 | replacement=`find RPMS/$distro_TLA -type d | tail -n1`
|
---|
| 337 | replacement=`basename $replacement`
|
---|
| 338 | echo -en "Version $distro_ver is not supported. Would $replacement do? "
|
---|
| 339 | read ch
|
---|
| 340 | StrStr "YyYESyesYes" "$ch" && distro_ver=$replacement || Die "Please install Mondo manually.\nType 'cd $CDPATH/RPMS/$distro_TLA and \ninstall the RPMs of your choice."
|
---|
| 341 | fi
|
---|
| 342 | # Install RPMs from this directory.
|
---|
| 343 | LogIt "Locating and installing packages suitable for $distro_title v $distro_ver"
|
---|
| 344 | for q in XMondo mondo mindi mindi-kernel partimagehack bootsplash-theme-SuSE ; do
|
---|
| 345 | echo -en "."
|
---|
| 346 | rpm -q $q &> /dev/null && rpm --erase $q --nodeps 2>> $LOGFILE >> $LOGFILE
|
---|
| 347 | done
|
---|
| 348 | # make list of and install missing packages
|
---|
| 349 | if rpm -q cdrecord 2> /dev/null | grep "cdrecord-1\.[5-8]" ; then
|
---|
| 350 | echo -en "Uninstalling outdated cdrecord package..."
|
---|
| 351 | rpm --erase --nodeps cdrecord
|
---|
| 352 | echo "Done."
|
---|
| 353 | fi
|
---|
| 354 | echo -en "."
|
---|
| 355 |
|
---|
| 356 | rm -Rf /usr/local/share/mondo /usr/share/mondo /usr/local/share/mindi /usr/share/mindi
|
---|
| 357 |
|
---|
| 358 | # remove packages which could be broken, then upgrade them
|
---|
| 359 | if find $rpms_path/*slang*rpm > /dev/null 2> /dev/null ; then
|
---|
| 360 | rpm --erase --nodeps slang 2> /dev/null
|
---|
| 361 | rpm --erase --nodeps slang-devel 2> /dev/null
|
---|
| 362 | rpm -i --nodeps $rpms_path/*slang*rpm
|
---|
| 363 | fi
|
---|
| 364 | if find $rpms_path/*newt*rpm > /dev/null 2> /dev/null ; then
|
---|
| 365 | rpm --erase --nodeps newt 2> /dev/null
|
---|
| 366 | rpm --erase --nodeps newt-devel 2> /dev/null
|
---|
| 367 | rpm --erase --nodeps lib64newt0.50 2> /dev/null
|
---|
| 368 | rpm --erase --nodeps lib64newt0.51 2> /dev/null
|
---|
| 369 | fi
|
---|
| 370 |
|
---|
| 371 | for i in mondoarchive mondorestore mindi ; do
|
---|
| 372 | for j in 1 2 3 ; do
|
---|
| 373 | which $i &> /dev/null && rm -f `which $i`
|
---|
| 374 | done
|
---|
| 375 | done
|
---|
| 376 |
|
---|
| 377 | # install missing pkgs
|
---|
| 378 |
|
---|
| 379 | # echo "rpms_path = $rpms_path" >> /dev/stderr
|
---|
| 380 | [ "$rpms_path" = "RPMS/SUS/9.1.x86-64" ] && ln -sf libnewt.so.0.51 /usr/lib64/libnewt.so.0.50
|
---|
| 381 | if [ "$rpms_path" = "RPMS/SUS/9.1" ] ; then
|
---|
| 382 | ln -sf libnewt.so.0.51 /usr/lib/libnewt.so.0.50
|
---|
| 383 | if ! ls /usr/lib/libslang-utf8* &> /dev/null ; then
|
---|
| 384 | ln -sf libslang.so.1 /usr/lib/libslang-utf8.so.1
|
---|
| 385 | fi
|
---|
| 386 | fi
|
---|
| 387 | # [ "$rpms_path" = "RPMS/SLE/8" ] && ln -sf libslang-utf8.so.1 /usr/lib/libslang.so.1
|
---|
| 388 | if ls $rpms_path/mondo* &> /dev/null ; then
|
---|
| 389 | InstallMissingPackages $rpms_path $rpms_path
|
---|
| 390 | else
|
---|
| 391 | InstallMissingPackages $rpms_path RPMS
|
---|
| 392 | fi
|
---|
| 393 | res=$?
|
---|
| 394 | # PostInstallSanityChecks
|
---|
| 395 | # res=$(($res+$?))
|
---|
| 396 | return $res
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 |
|
---|
| 400 | UntarAndMakeMindi() {
|
---|
| 401 | local tarball res builddir pkg q branch tarball outdir bindir
|
---|
| 402 |
|
---|
| 403 | pkg=mindi
|
---|
| 404 | branch=$1
|
---|
| 405 | builddir=/tmp/setup.$$
|
---|
| 406 | mkdir -p $builddir
|
---|
| 407 | cd $builddir
|
---|
| 408 |
|
---|
| 409 | tarball=`find $CDPATH/TGZS/$pkg-$branch*tgz | tail -n1`
|
---|
| 410 | [ -e "$tarball" ] || return 1
|
---|
| 411 | tar -zxf $tarball || return 1
|
---|
| 412 | if uname -a | grep Knoppix > /dev/null ; then
|
---|
| 413 | stub=`echo "$tarball" | gawk -F '/' '{print $NF;}' | cut -d'.' -f1,2`
|
---|
| 414 | # echo "stub = $stub"
|
---|
| 415 | outdir=/ramdisk/tmp/$pkg
|
---|
| 416 | mkdir -p $outdir || return 1
|
---|
| 417 | tar -zxf $tarball -C $outdir
|
---|
| 418 | cd $outdir
|
---|
| 419 | cd $outdir/$stub
|
---|
| 420 | # cp -f /mnt/mondostuff/mondocvs/mindi-devel/install.sh . 2> /dev/null
|
---|
| 421 | # cp -f /mnt/mondostuff/mondocvs/mindi-devel/mindi . 2> /dev/null
|
---|
| 422 | ./install.sh || return 1
|
---|
| 423 | else
|
---|
| 424 | Die "Not written yet"
|
---|
| 425 | fi
|
---|
| 426 |
|
---|
| 427 | cd /tmp
|
---|
| 428 | [ "$builddir" ] && [ -d "$builddir" ] && rm -Rf $builddir
|
---|
| 429 | return 0
|
---|
| 430 | }
|
---|
| 431 |
|
---|
| 432 |
|
---|
| 433 |
|
---|
| 434 | UntarAndMakeMondo() {
|
---|
| 435 | local tarball res builddir pkg q branch tarball q outdir bindir
|
---|
| 436 |
|
---|
| 437 | pkg=mondo
|
---|
| 438 | branch=$1
|
---|
| 439 | builddir=/tmp/setup.$$
|
---|
| 440 | mkdir -p $builddir
|
---|
| 441 | cd $builddir
|
---|
| 442 |
|
---|
| 443 | tarball=`find $CDPATH/TGZS/$pkg-$branch*tgz | tail -n1`
|
---|
| 444 | [ -e "$tarball" ] || return 1
|
---|
| 445 | tar -zxf $tarball || return 1
|
---|
| 446 | if uname -a | grep Knoppix > /dev/null ; then
|
---|
| 447 | stub=`echo "$tarball" | gawk -F '/' '{print $NF;}' | cut -d'.' -f1,2`
|
---|
| 448 | # echo "stub = $stub"
|
---|
| 449 | outdir=/ramdisk/usr/local/share/$pkg
|
---|
| 450 | bindir=/ramdisk/usr/bin
|
---|
| 451 | mkdir -p $bindir
|
---|
| 452 | mkdir -p $outdir || return 1
|
---|
| 453 | rm -Rf $outdir/*
|
---|
| 454 | tar -zxf $tarball -C $outdir $stub/$pkg/{restore-scripts,do-not-compress-these}
|
---|
| 455 | mv $outdir/$stub/$pkg/* $outdir
|
---|
| 456 | rm -Rf $outdir/$stub
|
---|
| 457 | for q in mondoarchive mondorestore ; do
|
---|
| 458 | cp -f $CDPATH/stuff/$q.static $outdir/$q || Die "Can't copy static $q"
|
---|
| 459 | ln -sf $outdir/$q $bindir/$q
|
---|
| 460 | done
|
---|
| 461 | else
|
---|
| 462 | tar -zxf $tarball || return 1
|
---|
| 463 | dir=`find $pkg-$branch* -type d`
|
---|
| 464 | echo hi > test.txt
|
---|
| 465 | cd $builddir/$dir || return 1
|
---|
| 466 | ./configure || return 1
|
---|
| 467 | make VERSION=$MY_BRANCH -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT || return 1
|
---|
| 468 | make install || return 1
|
---|
| 469 | fi
|
---|
| 470 | cd /tmp
|
---|
| 471 | [ "$builddir" ] && [ -d "$builddir" ] && rm -Rf $builddir
|
---|
| 472 | return 0
|
---|
| 473 | }
|
---|
| 474 |
|
---|
| 475 |
|
---|
| 476 |
|
---|
| 477 |
|
---|
| 478 | InstallPIH() {
|
---|
| 479 | local pkg branch builddir tarball
|
---|
| 480 | pkg=partimagehack
|
---|
| 481 | branch=$1
|
---|
| 482 | builddir=/tmp/setup.$$
|
---|
| 483 | outdir=/ramdisk/usr/bin
|
---|
| 484 | mkdir -p $builddir
|
---|
| 485 | cd $builddir
|
---|
| 486 |
|
---|
| 487 | tarball=`find $CDPATH/TGZS/$pkg-$branch*bz2 | tail -n1`
|
---|
| 488 | [ -e "$tarball" ] || return 1
|
---|
| 489 |
|
---|
| 490 | if uname -a | grep Knoppix > /dev/null ; then
|
---|
| 491 | stub=`echo "$tarball" | gawk -F '/' '{print $NF;}' | cut -d'.' -f1,2,3`
|
---|
| 492 | # echo "stub = $stub"
|
---|
| 493 | tar -jxf $tarball -C $outdir $stub/partimagehack || return 1
|
---|
| 494 | mv -f $outdir/$stub/partimagehack $outdir
|
---|
| 495 | else
|
---|
| 496 | Die "InstallPIH doesn't work for non-Knoppix systems yet"
|
---|
| 497 | fi
|
---|
| 498 | cd /tmp
|
---|
| 499 | return 0
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 |
|
---|
| 503 |
|
---|
| 504 |
|
---|
| 505 | #CDPATH=/mnt/mondostuff/MondoCD
|
---|
| 506 | #InstallPIH 0.6
|
---|
| 507 | #UntarAndMakeMondo 1.7
|
---|
| 508 | #UntarAndMakeMindi 0.9
|
---|
| 509 | #exit 0
|
---|
| 510 |
|
---|
| 511 |
|
---|
| 512 | InstallFromTgzs() {
|
---|
| 513 | local res old_pwd
|
---|
| 514 |
|
---|
| 515 | old_pwd=`pwd`
|
---|
| 516 | res=0
|
---|
| 517 | if uname -a | grep Knoppix > /dev/null && [ "$MY_BRANCH" = "1.6" ] ; then
|
---|
| 518 | Die "Only mondo-devel supports Knoppix."
|
---|
| 519 | fi
|
---|
| 520 |
|
---|
| 521 | UntarAndMakeMondo $MY_BRANCH || Die "Failed to build mondo $MY_BRANCH"
|
---|
| 522 | UntarAndMakeMindi $MINDI_BRANCH || Die "Failed to build mindi $MINDI_BRANCH"
|
---|
| 523 | InstallPIH 0.6 || Die "Failed to install partimagehack from tarball"
|
---|
| 524 | cd $old_pwd
|
---|
| 525 | return $res
|
---|
| 526 | }
|
---|
| 527 |
|
---|
| 528 |
|
---|
| 529 |
|
---|
| 530 |
|
---|
| 531 | InstallMissingPackages() {
|
---|
| 532 | local res pkg missing_packages command packages_path mindimondo_path possible_packages c2
|
---|
| 533 | packages_path=$1
|
---|
| 534 | mindimondo_path=$2
|
---|
| 535 | # echo "mindimondo_path = $2" >> /dev/stderr
|
---|
| 536 | missing_packages=`FindMissingRPMs $1`
|
---|
| 537 | echo "missing_packages =$missing_packages" >> $LOGFILE
|
---|
| 538 | sync
|
---|
| 539 |
|
---|
| 540 | # echo -en "Press ENTER to continue." ; read line
|
---|
| 541 |
|
---|
| 542 | command=""
|
---|
| 543 | for pkg in $missing_packages ; do
|
---|
| 544 | echo -en "."
|
---|
| 545 | if [ -e "$packages_path/$pkg" ] ; then
|
---|
| 546 | command="$command $packages_path/$pkg"
|
---|
| 547 | elif [ -e "RPMS/$pkg" ] ; then
|
---|
| 548 | command="$command RPMS/$pkg"
|
---|
| 549 | else
|
---|
| 550 | Die "Cannot find local path of $pkg - it's neither at RPMS nor at $packages_path"
|
---|
| 551 | fi
|
---|
| 552 | done
|
---|
| 553 |
|
---|
| 554 | # echo "\$2 = '$2'" >> /dev/stderr
|
---|
| 555 |
|
---|
| 556 | c2="`find $mindimondo_path/mindi-$MINDI_BRANCH*rpm 2> $LOGFILE | tail -n1` `find $mindimondo_path/mondo-$MY_BRANCH*rpm 2>> $LOGFILE | tail -n1`"
|
---|
| 557 |
|
---|
| 558 | # echo "c2 = '$c2'" >> /dev/stderr
|
---|
| 559 |
|
---|
| 560 | command="`echo "$command" | tr ' ' '\n' | sort -u | tr '\n' ' '`"
|
---|
| 561 | if echo "$c2" | grep mondo &> /dev/null && echo "$command" | grep mondo &> /dev/null ; then
|
---|
| 562 | # echo "command was $command"
|
---|
| 563 | command="`echo "$command" | tr ' ' '\n' | grep -v mondo | tr '\n' ' '`"
|
---|
| 564 | # echo "command is now $command"
|
---|
| 565 | fi
|
---|
| 566 | command="`echo "$command $c2" | tr ' ' '\n' | sort -u | tr '\n' ' '`"
|
---|
| 567 | echo "Calling 'rpm -Uvh $command'" >> $LOGFILE
|
---|
| 568 | echo -en "\r"
|
---|
| 569 | rpm -Uvh $command
|
---|
| 570 | res=$?
|
---|
| 571 | [ "$res" -ne "0" ] && Die "Some packages failed to be installed."
|
---|
| 572 | return $res
|
---|
| 573 | }
|
---|
| 574 |
|
---|
| 575 |
|
---|
| 576 |
|
---|
| 577 | LogIt() {
|
---|
| 578 | echo -e "$1" >> /dev/stderr
|
---|
| 579 | echo -e "$1" >> $LOGFILE
|
---|
| 580 | }
|
---|
| 581 |
|
---|
| 582 |
|
---|
| 583 |
|
---|
| 584 | PostInstallSanityChecks()
|
---|
| 585 | {
|
---|
| 586 | local res
|
---|
| 587 | res=0
|
---|
| 588 | if which /usr/local/mondo/mondo-archive &> /dev/null ; then
|
---|
| 589 | echo "mondo-archive available to be executed" >> $LOGFILE
|
---|
| 590 | else
|
---|
| 591 | LogIt "mondo-archive --help failed"
|
---|
| 592 | res=$(($res+1))
|
---|
| 593 | fi
|
---|
| 594 | if [ "`/usr/local/mondo/mondo-tarme --wu-tang`" = "dollar dollar bill, y'all" ]; then
|
---|
| 595 | echo "mondo-tarme executable intact" >> $LOGFILE
|
---|
| 596 | else
|
---|
| 597 | LogIt "mondo-tarme executable not available"
|
---|
| 598 | res=$(($res+1))
|
---|
| 599 | fi
|
---|
| 600 | if [ "`/usr/local/mondo/mondo-restore --cream`" = "dollar dollar bill, y'all" ] ; then
|
---|
| 601 | echo "mondo-restore executable intact" >> $LOGFILE
|
---|
| 602 | else
|
---|
| 603 | LogIt "mondo-restore executable not available"
|
---|
| 604 | res=$(($res+1))
|
---|
| 605 | fi
|
---|
| 606 | return $res
|
---|
| 607 | }
|
---|
| 608 |
|
---|
| 609 |
|
---|
| 610 |
|
---|
| 611 | StrStr() {
|
---|
[911] | 612 | [ "`echo "$1" | grep -Fi "$2"`" ] && return 0 || return 1
|
---|
[355] | 613 | }
|
---|
| 614 |
|
---|
| 615 |
|
---|
| 616 |
|
---|
| 617 | WelcomeMessage() {
|
---|
| 618 | LogIt ""
|
---|
| 619 | LogIt "Welcome to the Mondo Rescue installer! This script"
|
---|
| 620 | LogIt "will install Mondo and any missing dependencies."
|
---|
| 621 | LogIt "--------------------------------------------------"
|
---|
| 622 | echo "banner=`GetDistroBanner`" >> $LOGFILE
|
---|
| 623 | echo "name =`GetDistroName`" >> $LOGFILE
|
---|
| 624 | echo "ver =`GetDistroVersion`" >> $LOGFILE
|
---|
| 625 | echo "arch =`GetDistroArchitecture`" >> $LOGFILE
|
---|
| 626 | }
|
---|
| 627 |
|
---|
| 628 |
|
---|
| 629 | InstallXmondoFromRpms() {
|
---|
| 630 | rpm -i RPMS/XMondo-1*rpm
|
---|
| 631 | return $?
|
---|
| 632 | }
|
---|
| 633 |
|
---|
| 634 |
|
---|
| 635 |
|
---|
| 636 | InstallXmondoFromTgz() {
|
---|
| 637 | echo "InstallXmondoFromTgz() --- not written yet"
|
---|
| 638 | return 1
|
---|
| 639 | }
|
---|
| 640 |
|
---|
| 641 |
|
---|
| 642 |
|
---|
| 643 |
|
---|
| 644 | # ------------------------------- main -------------------------------
|
---|
| 645 |
|
---|
| 646 |
|
---|
| 647 |
|
---|
| 648 | cd `dirname $0`
|
---|
| 649 | CDPATH=`pwd`
|
---|
| 650 | if [ "$#" -ge "1" ] ; then
|
---|
| 651 | if [ "`pwd`" != "/tmp" ] ; then
|
---|
| 652 | rm -f /tmp/mondo-cd-setup.*
|
---|
| 653 | new_fname="/tmp/mondo-cd-setup.$RANDOM.$RANDOM.$$.sh"
|
---|
| 654 | cat $0 > $new_fname
|
---|
| 655 | chmod +x $new_fname
|
---|
| 656 | cd /
|
---|
| 657 | exec sh $new_fname $0
|
---|
| 658 | fi
|
---|
| 659 | cd `dirname $1`
|
---|
| 660 | fi
|
---|
| 661 |
|
---|
| 662 | > $LOGFILE
|
---|
| 663 | echo "pwd=`pwd`" >> $LOGFILE
|
---|
| 664 | [ -e "/usr/local/mondo.devel" ] && [ -e "/usr/local/mindi" ] && Die "Noooo! Hugo, type 'mv /usr/local/mindi /usr/local/mindi.orig' first, please."
|
---|
| 665 | MY_BRANCH=$STABLE_BRANCH
|
---|
| 666 | MINDI_BRANCH=1.0
|
---|
| 667 | WelcomeMessage
|
---|
| 668 |
|
---|
| 669 | #echo "distr=`GetDistroName`"
|
---|
| 670 | #echo "version=`GetDistroVersion`"
|
---|
| 671 | #echo "arch=`GetDistroArchitecture`"
|
---|
| 672 | #exit 1
|
---|
| 673 |
|
---|
| 674 | echo -en "Do you want to install the (S)table or the (D)evelopment branch of Mondo? "
|
---|
| 675 | read ch
|
---|
[911] | 676 | if [ "`echo "development" | grep -Fi "$ch"`" ] ; then
|
---|
[355] | 677 | MY_BRANCH=$DEVEL_BRANCH
|
---|
| 678 | MINDI_BRANCH=1.1
|
---|
| 679 | # XMONDO=yes
|
---|
| 680 | fi
|
---|
| 681 | [ "$MY_BRANCH" = "$STABLE_BRANCH" ] && LogIt "Installing stable branch." || LogIt "Installing development branch."
|
---|
| 682 | # LogIt "I see you are running `GetDistroBanner`"
|
---|
| 683 | distro=`GetDistroName`
|
---|
| 684 | version=`GetDistroVersion`
|
---|
| 685 | architecture=`GetDistroArchitecture`
|
---|
| 686 | LogIt "distro=$distro version=$version arch=$architecture"
|
---|
| 687 |
|
---|
| 688 | [ "$distro" = "ARK" ] && version=1.0
|
---|
| 689 | # patch by Geofuz@netscape.com
|
---|
| 690 | if [ "$distro" = "FDR" ] ; then
|
---|
| 691 | if [ "$version" = "2" ] || [ "$version" = "1.90" ] ; then
|
---|
| 692 | version=2.0
|
---|
| 693 | else
|
---|
| 694 | version=1.0
|
---|
| 695 | fi
|
---|
| 696 | fi
|
---|
| 697 | # end patch
|
---|
| 698 | [ "$distro" = "KPX" ] && version=3.3; # Knoppix
|
---|
| 699 | [ ! "$version" ] && Die "Distro=$distro but I cannot ascertain version of distro"
|
---|
| 700 | if [ ! -d "RPMS/$distro" ] && rpm --version &> /dev/null && [ "$distro" != "KPX" ] ; then
|
---|
| 701 | LogIt "You are using an unknown version but you have RPM available, which means"
|
---|
| 702 | LogIt "I could try installing the Red Hat 7.2-compatible stuff. It will probably work."
|
---|
| 703 | echo -en "Shall I do that (y/n)? "
|
---|
| 704 | read ch
|
---|
[911] | 705 | if [ "`echo "YESyesYes" | grep -F "$ch"`" ] ; then
|
---|
[355] | 706 | distro=RHT
|
---|
| 707 | version=7.2
|
---|
| 708 | fi
|
---|
| 709 | fi
|
---|
| 710 | res=0
|
---|
| 711 | if [ -d "RPMS/$distro" ] ; then
|
---|
| 712 | InstallFromRpms "$distro" "$version" "$architecture"
|
---|
| 713 | res=$(($res+$?))
|
---|
| 714 | if [ "$XMONDO" ] ; then
|
---|
| 715 | InstallXmondoFromRpms
|
---|
| 716 | res=$(($res+$?))
|
---|
| 717 | fi
|
---|
| 718 | elif [ -d "TGZS/$distro" ] ; then
|
---|
| 719 | InstallFromTgzs "$distro" "$version" "$architecture"
|
---|
| 720 | res=$(($res+$?))
|
---|
| 721 | if [ "$XMONDO" ] ; then
|
---|
| 722 | InstallXmondoFromTgzs
|
---|
| 723 | res=$(($res+$?))
|
---|
| 724 | fi
|
---|
| 725 | else
|
---|
| 726 | LogIt "`GetDistroBanner` is not supported by this script."
|
---|
| 727 | LogIt "RPMs are stored in /RPMS and the tarballs are in /TGZS, both on the CD."
|
---|
| 728 | Die "Please install Mondo manually."
|
---|
| 729 | fi
|
---|
| 730 | if [ "$res" -eq "0" ] ; then
|
---|
| 731 | LogIt "Running 'ldconfig' to refresh library cache..."
|
---|
| 732 | ldconfig
|
---|
| 733 | LogIt "End of install. Mondo was installed OK."
|
---|
| 734 | else
|
---|
| 735 | LogIt "End of install. Errors occurred."
|
---|
| 736 | fi
|
---|
| 737 |
|
---|
| 738 | cd /
|
---|
| 739 | if [ "$#" -ge "1" ] ; then
|
---|
| 740 | mountpt=`dirname $1`
|
---|
| 741 | dev=`mount | tr -s '\t' ' ' | grep "$mountpt " | awk '{print $1;}'`
|
---|
| 742 | if [ ! "$dev" ] || [ "$dev" = "none" ] ; then
|
---|
| 743 | dev=`mount | tr -s '\t' ' ' | grep "$mountpt " | tr -s ',' '\n' | sed s/dev=// | grep /dev`
|
---|
| 744 | mountpt=""; # supermount - don't unmount it :)
|
---|
| 745 | fi
|
---|
| 746 | [ "$mountpt" ] && umount $mountpt
|
---|
| 747 | [ "$dev" ] && eject $dev
|
---|
| 748 | echo "mountpt=$mountpt; dev=$dev" >> $LOGFILE
|
---|
| 749 | else
|
---|
| 750 | LogIt "Please type:-"
|
---|
| 751 | LogIt " cd /"
|
---|
| 752 | LogIt " umount $CDPATH"
|
---|
| 753 | LogIt "Then remove the Mondo installation CD."
|
---|
| 754 | fi
|
---|
| 755 |
|
---|
| 756 | LogIt "Refer to Mondo's manual for instructions"
|
---|
| 757 | LogIt "on the care and feeding of Mondo Rescue."
|
---|
| 758 | LogIt ""
|
---|
| 759 | #if fdisk -l | grep -w 7 &> /dev/null || fdisk -l | grep -wi ntfs &> /dev/null ; then
|
---|
| 760 | # LogIt "To backup your NTFS partition, you must first install"
|
---|
| 761 | # LogIt "partimagehack. This is in the CD's /TGZS directory as"
|
---|
| 762 | # LogIt "partimagehack-0.6.2.tar.bz2, FYI."
|
---|
| 763 | # which partimagehack &> /dev/null & LogIt "...Oh my, I think you already have. Good show!"
|
---|
| 764 | #fi
|
---|
| 765 | #LogIt ""
|
---|
| 766 | LogIt "Log in as root and type 'mondoarchive' to backup your PC."
|
---|
| 767 | LogIt ""
|
---|
| 768 | echo -en "Press ENTER to finish."
|
---|
| 769 | read line
|
---|
| 770 | exit $res
|
---|