5a62a342481f13ffe31f505294ccd0d18f414415
[oweals/cde.git] / cde / admin / IntegTools / dbTools / installCDE.src
1 XCOMM! KORNSHELL
2 XCOMM $XConsortium: installCDE.src /main/20 1996/11/25 14:21:13 drk $
3
4 XCOMM
5 XCOMM This script uses the 'CDE' databases to install either the Desktop
6 XCOMM environment on a specified machine or creates a tar ball to be used
7 XCOMM in an install process.
8 XCOMM
9 XCOMM this script accepts the following parameters:
10 XCOMM       -s <source>         -- The top of build tree where the files are
11 XCOMM                              gathered from.
12 XCOMM       -z <package>        -- The desktop install package
13 XCOMM
14 XCOMM      Optional parameters:
15 XCOMM
16 XCOMM       -t  <package destination>     -- where to store install package
17 XCOMM       -pI <actual install location> -- where CDE_INSTALLATION_TOP will be linked to.
18 XCOMM       -pC <actual config location>  -- where CDE_CONFIGURATION_TOP will be linked to.
19 XCOMM       -pV <actual var location>     -- where CDE_LOGFILES_TOP will be linked to.
20 XCOMM    -a  <alternate udb directory>
21 XCOMM       -f  <filesets>                -- a quoted, space-separated list of 
22 XCOMM                                        filesets to load. The .udb extension
23 XCOMM                                        is not required.
24 XCOMM
25 XCOMM       -clean   -- remove the temporary, configuration and installation 
26 XCOMM                   directories
27 XCOMM       -cleanTwo-- remove the temporary and installation directories
28 XCOMM                   but NOT the configuration directory
29 XCOMM       -cleanEtc-- remove the configuration directories
30 XCOMM       -prog    -- load only the development environment
31 XCOMM       -runtime -- load only the runtime environment
32 XCOMM       -pack    -- create packing list
33 XCOMM       -pseudo  -- don't configure the desktop
34 XCOMM       -nocompress -- don't compress the tarball (-t only)
35 XCOMM
36 XCOMM       -Lang           -- load the localized filesets
37 XCOMM       -LinkStepOnly   -- set up the -pI, -pC, and -pV links
38 XCOMM                          then exit
39 XCOMM       -DontRunScripts -- stop after installation
40 XCOMM       -RunScriptsOnly -- only execute the scripts
41 XCOMM       -configureOnly -- only configure the desktop
42 XCOMM
43 XCOMM ##########################################################################
44
45 #define HASH #
46 #define STAR *
47
48 LOGFILE="installCDE.$$.log"
49
50 REVISION="$(echo "$Revision: /main/20 $" | awk '{print $2}')"
51
52 Log()
53 {
54   /bin/echo "$1" | tee -a $LOGFILE
55 }
56
57 MakeTarball()
58 {
59     Log "\nGenerating UNIX Desktop install package $DATE in $TARBALL_LOCATION"
60     HASH
61     HASH create installable tarball
62     HASH
63     Log "Creating tarball..."
64
65     if [ $PLATFORM = "usl" -o "$PLATFORM" = "uxp" ]
66     then
67       ulimit -f unlimited
68     fi
69
70     DIRNAME=build.$DATE
71     mkdir -p $TARBALL_LOCATION/$DIRNAME
72     cd /
73     echo $DATE >$LOGFILES_LOCATION/.build.$DATE
74     chown bin $LOGFILES_LOCATION/.build.$DATE
75
76     if [ "$COMPRESS_TARBALL" = "yes" ]; then
77       tar -cf - $INSTALL_LOCATION/STAR \
78         2>$TARBALL_LOCATION/$DIRNAME/extract.err |
79         compress -c >$TARBALL_LOCATION/$DIRNAME/dttar.Z
80     else
81       tar -cf $TARBALL_LOCATION/$DIRNAME/dt.tar \
82         $INSTALL_LOCATION/STAR \
83         2>$TARBALL_LOCATION/$DIRNAME/extract.err 2>&1
84     fi
85
86     if [ "$ACTUAL_INSTALLATION_LOC" = "" ]; then
87       actualInstallDir=$INSTALL_LOCATION
88     else
89       actualInstallDir=$ACTUAL_INSTALLATION_LOC
90     fi 
91     let size=$(du -s $actualInstallDir | awk '{print $1}')*512
92
93     HASH load installation fileset *after* tarball generated
94     LoadFileSet "" "CDE-INSTALL"
95
96     HASH create config dir
97     destPost=$TARBALL_LOCATION/$DIRNAME/config
98     mkdir $destPost
99
100     HASH copy config and platform config scripts
101     src=$INSTALL_LOCATION/install/$PLATFORM_SCRIPT_DIR
102     cp $src/config/STAR.cfg $destPost
103    
104     HASH copy this script and install.dt platform overrides
105     cp $src/install.dto $TARBALL_LOCATION/$DIRNAME/install.dto
106     cp $src/install.cde $TARBALL_LOCATION/$DIRNAME/install.cde
107     chmod 755 $TARBALL_LOCATION/$DIRNAME/install.cde
108
109     cd /
110
111     Log "done."
112
113     cat >$TARBALL_LOCATION/$DIRNAME/dt.pkg <<FIN
114 PLATFORM: $PLATFORM
115 VERSION: $REVISION
116 TS: $DATE
117 COMPRESSED: $COMPRESS_TARBALL
118 SIZE: $size
119 CL: $ORIGINAL_COMMAND_LINE
120 FILESETS: $DATABASE_FILES
121 FIN
122
123     cat >$TARBALL_LOCATION/$DIRNAME/build.status <<FIN
124 The UNIX Desktop
125
126 BUILD: $DATE
127 OVERALL STATUS: <not yet tested>
128 OVERALL PERFORMANCE: <not yet tested>
129 MAJOR PROBLEMS: <not yet tested>
130
131 FIN
132
133     chmod g+w $TARBALL_LOCATION/$DIRNAME/build.status
134 }
135
136 DoFilesetScript()
137 {
138   typeset ScriptName
139
140   FilesetName=$1
141   if [ "$BUILD_TREE" = "" ]; then
142     ScriptName=$3       # use short config file name (foo.cfg)
143   else
144     ScriptName=$2       # use long config file name (configFoo)
145   fi
146
147   if [ $CDECONFIGDIR = "CONFIG" ]; then
148     typeset -u ScriptName
149   fi
150
151   test_string=${DATABASE_FILES#*$FilesetName}
152   if (( ${#DATABASE_FILES} > ${#test_string} ))
153   then
154     if [ -x $POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName ]
155     then
156         Log "Executing $PLATFORM specific $FilesetName customize script"
157         KORNSHELL $POST_INSTALL_DIR/$PLATFORM_SCRIPT_DIR/$ScriptName -e 2>&1 | \
158                                 tee -a $LOGFILE
159     elif [ -x $POST_INSTALL_DIR/$ScriptName ]
160     then
161         Log "Executing $FilesetName customize script" 
162         KORNSHELL $POST_INSTALL_DIR/$ScriptName -e 2>&1 | tee -a $LOGFILE
163     fi
164   fi
165 }
166
167 DoScripts()
168 {
169   Log " "
170
171   DoFilesetScript CDE-TT       configTT      tt.cfg
172   DoFilesetScript CDE-MIN      configMin     min.cfg
173   DoFilesetScript CDE-SHLIBS   configShlibs  shlibs.cfg
174   DoFilesetScript CDE-RUN      configRun     run.cfg
175 }
176
177 CreatePackingList()
178 {
179     Log " "
180     Log "Creating packing list."
181     touch $INSTALL_LOCATION/Packing_list
182     for i in `echo $DATABASE_FILES`
183     do
184       Log "  for $i"
185       KORNSHELL $TOOL_DIR/udbToAny.ksh -toDB -ReleaseStream $PLATFORM $DATABASE_DIR/${i}.udb > /tmp/${i}.db
186       if [ -r /tmp/${i}.db ]
187       then
188         for file in `fgrep install_target /tmp/${i}.db | cut -sf 2 -d \: ` 
189         do
190           echo "$file" >>$INSTALL_LOCATION/Packing_list
191         done
192       fi
193     done
194 }
195
196 CleanDaemons()
197 {
198   HASH kill these processes so that they can be removed and new ones
199   HASH installed
200
201   for i in inetd rpc.ttdbserver rpc.cmsd
202   do
203     if [ "$PLATFORM" = "aix" -a $i = "inetd" ]
204     then
205       lssrc -s inetd >/dev/null 2>&1
206       if [ $? = "0" ]
207       then
208         stopsrc -s inetd >>$LOGFILE 2>&1
209       fi
210     elif [ "$PLATFORM" = "openbsd" ]
211     then
212       ps axo pid,comm | grep $i > /tmp/tmppsout
213       if [ -s /tmp/tmppsout ]
214       then
215         awk '{print "kill " $1}' /tmp/tmppsout | /bin/csh -f
216         sleep 2
217       fi
218     elif [ "$PLATFORM" = "freebsd" ]
219     then
220       ps axo pid,comm | grep $i > /tmp/tmppsout
221       if [ -s /tmp/tmppsout ]
222       then
223         awk '{print "kill " $1}' /tmp/tmppsout | /bin/csh -f
224         sleep 2
225       fi
226     elif [ "$PLATFORM" = "netbsd" ]
227     then
228       ps axo pid,comm | grep $i > /tmp/tmppsout
229       if [ -s /tmp/tmppsout ]
230       then
231         awk '{print "kill " $1}' /tmp/tmppsout | /bin/csh -f
232         sleep 2
233       fi
234     elif [ "$PLATFORM" = "linux" ]
235     then
236       ps axo pid,comm | grep $i > /tmp/tmppsout
237       if [ -s /tmp/tmppsout ]
238       then
239         awk '{print "kill " $1}' /tmp/tmppsout | /bin/sh -f
240         sleep 2
241       fi
242     else    
243       ps -ef | grep $i | grep -v grep >/tmp/tmppsout
244       if [ -s /tmp/tmppsout ]
245       then
246         awk '{print "kill " $2}' /tmp/tmppsout | /bin/csh -f
247         sleep 2
248       fi
249     fi
250   done
251   rm -f /tmp/tmppsout
252 }
253
254 RestartInetd()
255 {
256   HASH now restart inetd
257
258   OLDPWD=`pwd`
259   cd /
260   if [ "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ]
261   then
262     /usr/sbin/inetd -s
263   elif [ "$PLATFORM" = "sun" ]
264   then
265     /usr/sbin/svcadm refresh svc:/network/inetd:default
266     /usr/sbin/svcadm restart svc:/network/inetd:default
267   elif [ "$PLATFORM" = "aix" ]
268   then
269     startsrc -s inetd >>$LOGFILE 2>&1
270   elif [ "$PLATFORM" = "dec" ]
271   then
272     /usr/sbin/inetd
273   elif [ "$PLATFORM" = "openbsd" ]
274   then
275     /etc/rc.d/inetd start >/dev/null
276   elif [ "$PLATFORM" = "freebsd" ]
277   then
278     /etc/rc.d/inetd onestart
279   elif [ "$PLATFORM" = "netbsd" ]
280   then
281     /etc/rc.d/inetd start >/dev/null
282   elif [ "$PLATFORM" = "linux" ]
283   then
284     /etc/init.d/openbsd-inetd start >/dev/null 2>&1
285   else
286 #ifdef hpV4
287     /usr/sbin/inetd 
288 #else
289     /etc/inetd
290 #endif
291   fi
292   cd $OLDPWD
293 }
294
295 CheckForActualLocations()
296 {
297 XCOMM
298 XCOMM if different actual locations specified, set up the links
299 XCOMM
300
301
302   if [ "$CLEAN_DAEMONS" = "yes" ]
303   then
304     CleanDaemons
305   fi
306
307   HASH remove the contents of the installation directory then the directory
308   HASH itself
309
310   if [ "$CLEANING" = "yes" ]
311   then
312     Log "Removing $INSTALL_LOCATION contents... "
313     if [ -d $INSTALL_LOCATION ]
314     then
315       rm -rf $INSTALL_LOCATION/STAR
316       if [ "$LeaveLinks" = "yes" ]
317       then
318         if [ ! -L $INSTALL_LOCATION ]
319         then
320           rm -rf $INSTALL_LOCATION
321         fi
322       else
323         if [ -L $INSTALL_LOCATION ]
324         then
325           rm -f $INSTALL_LOCATION
326         else
327           rm -rf $INSTALL_LOCATION
328         fi
329       fi
330     fi
331   fi
332
333   if [ "$CONFIGURE_ONLY" = "no" ]
334   then
335     if [ "$ACTUAL_INSTALLATION_LOC" != "" ]
336     then
337
338       HASH
339       HASH first create the actual directory - if not there
340       HASH
341
342       if [ ! -d $ACTUAL_INSTALLATION_LOC ]
343       then
344         mkdir -p $ACTUAL_INSTALLATION_LOC
345         if [ ! -d $ACTUAL_INSTALLATION_LOC ]
346         then
347           Log "cannot create $ACTUAL_INSTALLATION_LOC directory"
348           exit 1
349         fi
350       fi
351
352       ln -s $ACTUAL_INSTALLATION_LOC $INSTALL_LOCATION
353
354     else
355       if [ ! -d $INSTALL_LOCATION -a ! -L $INSTALL_LOCATION ]; 
356       then
357         mkdir -p $INSTALL_LOCATION
358       fi
359     fi
360   fi
361
362   if [ "$CLEAN_DAEMONS" = "yes" ]
363   then
364     RestartInetd
365   fi
366
367   HASH remove the contents of the configuration directory
368
369   if [ "$CLEANING_ETC" = "yes" ]
370   then
371     Log "Removing $CONFIGURE_LOCATION contents... "
372     if [ -d $CONFIGURE_LOCATION ]
373     then
374       rm -rf $CONFIGURE_LOCATION/STAR
375       if [ "$LeaveLinks" = "yes" ]
376       then
377         if [ ! -L $CONFIGURE_LOCATION ]
378         then
379           rm -rf $CONFIGURE_LOCATION
380         fi
381       else
382         if [ -L $CONFIGURE_LOCATION ]
383         then
384           rm -f $CONFIGURE_LOCATION
385         else
386           rm -rf $CONFIGURE_LOCATION
387         fi
388       fi
389     fi
390   fi
391         
392   if [ "$ACTUAL_CONFIGURATION_LOC" != "" ]
393   then
394     if [ ! -d $ACTUAL_CONFIGURATION_LOC ]
395     then
396       mkdir -p $ACTUAL_CONFIGURATION_LOC
397       if [ ! -d $ACTUAL_CONFIGURATION_LOC ]
398       then
399         Log "cannot create $ACTUAL_CONFIGURATION_LOC directory"
400         exit 1
401       fi
402     fi
403
404     ln -s $ACTUAL_CONFIGURATION_LOC $CONFIGURE_LOCATION
405
406   else
407     if [ ! -d $CONFIGURE_LOCATION -a ! -L $CONFIGURE_LOCATION ];
408     then
409       mkdir -p $CONFIGURE_LOCATION
410     fi
411   fi
412
413   if [ "$CLEANING" = "yes" ]
414   then
415     Log "Removing $LOGFILES_LOCATION contents... "
416     if [ -d $LOGFILES_LOCATION ]
417     then
418       rm -rf $LOGFILES_LOCATION/STAR
419       if [ "$LeaveLinks" = "yes" ]
420       then
421         if [ ! -L $LOGFILES_LOCATION ]
422         then
423           rm -rf $LOGFILES_LOCATION
424         fi
425       else
426         if [ -L $LOGFILES_LOCATION ]
427         then
428           rm -f $LOGFILES_LOCATION
429         else
430           rm -rf $LOGFILES_LOCATION
431         fi
432       fi
433     fi
434   fi
435
436   if [ "$ACTUAL_VAR_LOC" != "" ]
437   then
438     if [ ! -d $ACTUAL_VAR_LOC ]
439     then
440       mkdir -p $ACTUAL_VAR_LOC
441       if [ ! -d $ACTUAL_VAR_LOC ]
442       then
443         Log "cannot create $ACTUAL_VAR_LOC directory"
444         exit 1
445       fi
446     fi
447
448     ln -s $ACTUAL_VAR_LOC $LOGFILES_LOCATION
449     
450   else
451     if [ ! -d $LOGFILES_LOCATION -a ! -L $LOGFILES_LOCATION ]; 
452     then
453       mkdir -p $LOGFILES_LOCATION
454     fi
455   fi
456
457   Log " "
458 }
459
460 USAGE()
461 {
462 echo -e "Usage: $(basename $0) {-s <source>|-z <package>} [options]"
463 echo -e ""
464 echo -e "\t-s <source>\t\t\tthe top of the build tree"
465 echo -e "\t-z <package>\t\tthe desktop install package"
466 echo -e ""
467 echo -e "\tOptions:"
468 echo -e ""
469 echo -e "\t[-t <package_destination>]\tif specified create an"
470 echo -e "\t\t\t\t\tinstall package and store it in the"
471 echo -e "\t\t\t\t\tdestination."
472 echo -e "\t[-pI <actual install location>]\twhere" CDE_INSTALLATION_TOP "will be linked to."
473 echo -e "\t[-pC <actual config location>]\twhere" CDE_CONFIGURATION_TOP "will be linked to."
474 echo -e "\t[-pV <actual var location>]\twhere" CDE_LOGFILES_TOP "will be linked to."
475 echo -e ""
476 echo -e "\t[-a <udb directory>]\t\talternate place to get the"
477 echo -e "\t\t\t\t\tudb files from."
478 echo -e "\t[-f <filesets>]\t\t\tspecify filesets to be loaded."
479 echo -e "\t\t\t\t\tThe list should be double-quoted,"
480 echo -e "\t\t\t\t\tspace-separated, with no .udb"
481 echo -e "\t\t\t\t\textensions."
482 echo -e ""
483 echo -e "\t[-clean]\t\t\tremove the temporary, configuration, and"
484 echo -e "\t\t\t\t\tinstallation directory"
485 echo -e "\t[-cleanTwo]\t\t\tremove the temporary and installation "
486 echo -e "\t\t\t\t\tdirectory, but NOT the configuration directory"
487 echo -e "\t[-cleanEtc]\t\t\tremove the configuration directory, but "
488 echo -e "\t\t\t\t\NOT the temporary and installation directories"
489 echo -e "\t[-prog]\t\t\t\tload only the development environment"
490 echo -e "\t[-runtime]\t\t\tload only the runtime environment"
491 echo -e "\t[-relative]\t\t\trun the relative-located config scripts"
492 echo -e "\t[-pack]\t\t\t\tcreate a packing list"
493 echo -e "\t[-pseudo]\t\t\tdo not configure desktop when installing"
494 echo -e "\t[-nocompress]\t\t\tdo not compress tarball when creating package"
495 echo -e "\t[-lang LANG]\t\t\tspecify LANG to load appropriate localized"
496 echo -e "\t\t\t\t\tfilesets"
497 echo -e "\t[-LeaveLinks]\t\t\t\tdo not delete the links after cleaning"
498 echo -e ""
499 echo -e "\t[-LinkStepOnly]\t\t\tset up the -pI, -pC, and -pV links"
500 echo -e "\t\t\t\t\tthen exit"
501 echo -e "\t[-DontRunScripts]\t\tstop after installation"
502 echo -e "\t[-RunScriptsOnly]\t\tonly execute the scripts"
503 echo -e "\t[-configureOnly]\t\tonly configure the desktop"
504 echo -e ""
505 echo -e "\tExamples:"
506 echo -e ""
507 echo -e "\tinstallCDE -s /x/cde_hp700_90"
508 echo -e "\tinstallCDE -s /x/cde_aix_32 -f \"CDE_MIN CDE-SHLIBS\""
509 echo -e "\tinstallCDE -s /x/cde_sun_52 -pI /bigdisk/opt/dt -clean"
510 echo -e "\tinstallCDE -s /x/cde_sun_52 -pI /dtinstall -clean\\"
511 echo -e "\t\t-pseudo -t /dtpackages -nocompress"
512 }
513
514 XCOMM
515 XCOMM LoadFileSet() - load a UDB file
516 XCOMM $1 - fileset number
517 XCOMM $2 - fileset name
518 XCOMM
519 LoadFileSet()
520 {
521   if [ "$1" = "" ]; then
522     num=""
523   else
524     num="$1."
525   fi
526
527 XCOMM don't bother if the fileset doesn't exist
528   if [ ! -e $DATABASE_DIR/${2}.udb ]
529   then
530         return
531   fi
532
533   Log "  $num installing database $2"
534   Log "      - creating ${2}.lst file"
535   KORNSHELL $TOOL_DIR/udbToAny.ksh  -toLst -ReleaseStream $PLATFORM \
536             $DATABASE_DIR/${2}.udb >  /tmp/${2}.lst
537   Log "      - installing ... "
538   KORNSHELL $TOOL_DIR/mkProd -D / -S $BUILD_TREE /tmp/${2}.lst \
539             2>/tmp/${2}.err 1>/tmp/${2}.good
540   Log "        done."
541
542   Log "      - checking for errors ..."
543   rm -f /tmp/${2}.missing
544   awk '{if ($1 == "ERROR:") print "           " $4}' \
545             /tmp/${2}.err >> /tmp/${2}.missing
546   if [ -s /tmp/${2}.missing ]
547   then
548     Log "      - missing files:"
549     cat /tmp/${2}.missing | tee -a $LOGFILE
550   fi
551 }
552
553 ORIGINAL_COMMAND_LINE="$*"
554
555 XCOMM Set which system we are on
556 BUILDSYSTEM=$(uname)
557
558 PLATFORM=""
559 PLATFORM_SCRIPT_DIR=""
560
561 XCOMM
562 XCOMM Set system
563 XCOMM 
564   if [ $BUILDSYSTEM = "AIX" ];
565   then
566     PLATFORM=aix
567     PLATFORM_SCRIPT_DIR=ibm
568   elif [ $BUILDSYSTEM = "SunOS" ];
569   then
570     PLATFORM=sun
571     PLATFORM_SCRIPT_DIR=sun
572   elif [ $BUILDSYSTEM = "UNIX_SV" ];
573   then
574     PLATFORM=usl
575     PLATFORM_SCRIPT_DIR=usl
576   elif [ $BUILDSYSTEM = "UNIX_System_V" ];
577   then
578     PLATFORM=uxp
579     PLATFORM_SCRIPT_DIR=uxp
580   elif [ $BUILDSYSTEM = "OSF1" ];
581   then
582     PLATFORM=dec
583     PLATFORM_SCRIPT_DIR=dec
584   elif [ $BUILDSYSTEM = "Linux" ];
585   then
586     PLATFORM="linux"
587     PLATFORM_SCRIPT_DIR="linux"
588   elif [ $BUILDSYSTEM = "FreeBSD" ];
589   then
590     PLATFORM="freebsd"
591     PLATFORM_SCRIPT_DIR="freebsd"
592   elif [ $BUILDSYSTEM = "OpenBSD" ];
593   then
594     PLATFORM="openbsd"
595     PLATFORM_SCRIPT_DIR="openbsd"
596   elif [ $BUILDSYSTEM = "NetBSD" ];
597   then
598     PLATFORM="netbsd"
599     PLATFORM_SCRIPT_DIR="netbsd"
600   else                  # Build system = HP
601     PLATFORM=hp-ux
602     PLATFORM_SCRIPT_DIR=hp
603   fi
604
605   if [ "$PLATFORM" = "aix" ];
606   then
607     USER=`/bin/whoami`
608   elif [ "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ];
609   then
610     USER=`/usr/ucb/whoami`
611   else
612     USER=`/usr/bin/whoami`
613   fi
614
615   if [ "$USER" != "root" ];
616   then
617     echo ""
618     echo "You should be root to run this script.  Continuing anyway."
619     echo ""
620   fi
621
622   if [ "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ]
623   then
624     umask 000
625   fi
626
627   unset TMPDIR
628
629   CLEANING="no"
630   CLEANING_ETC="no"
631   TARBALL="no"
632   COMPRESS_TARBALL="yes"
633   USE_ALTERNATE_UDB_DIR="no"
634   DEVELOP_ENV="no"
635   RUNTIME_ENV="no"
636   USE_RELATIVE="no"
637   STARTING_DIR=$PWD
638   ACTUAL_INSTALLATION_LOC=""
639   ACTUAL_CONFIGURATION_LOC=""
640   ACTUAL_VAR_LOC=""
641   CREATE_PACKING_LIST="no"
642   DO_LINK_STEP_ONLY="no"
643   DO_INSTALL_ONLY="no"
644   RUN_SCRIPTS="yes"
645   RUN_SCRIPTS_ONLY="no"
646   DATABASE_FILES=""
647   BUILD_TREE=""
648   TAR_DIR=""
649   LeaveLinks="no"
650   REMOVE_LINKS="no"
651   CLEAN_DAEMONS="yes"
652   theLang=""
653   CONFIGURE_ONLY="no"
654
655   rm -f $LOGFILE
656
657   Log "Options specified..."
658   while [ $# -ne 0 ]; do
659     case $1 in
660         -s) Log "  - get the build tree to extract from"
661             shift;
662             [ $# -ne 0 ] || {
663                 USAGE
664                 exit 1;
665             }
666             BUILD_TREE=$1
667             shift;
668             ;;
669         -z) Log "  - get the install package to extract from"
670             shift;
671             [ $# -ne 0 ] || {
672                 USAGE
673                 exit 1;
674             }
675             TAR_TREE=$1
676             shift;
677             ;;
678         -t) Log "  - where to put the install package"
679             shift;
680             [ $# -ne 0 ] || {
681                 USAGE
682                 exit 1;
683             }
684             if [ "$SOURCE_TAR_FILE" = "" ]
685             then
686                 TARBALL="yes"
687                 TARBALL_LOCATION=$1
688             fi
689             shift;
690             ;;
691         -a) Log "  - alternate place to get the udb files from"
692             shift;
693             [ $# -ne 0 ] || {
694                 USAGE
695                 exit 1;
696             }
697             ALTERNATE_UDB_DIR=$1
698             USE_ALTERNATE_UDB_DIR="yes"
699             shift;
700             ;;
701         -f) Log "  - load specific filesets"
702             shift;
703             [ $# -ne 0 ] || {
704                 USAGE
705                 exit 1;
706             }
707             DATABASE_FILES=$1
708             shift;
709             ;;
710         -p) Log "  - get all locations"
711             shift;
712             [ $# -ne 0 ] || {
713                 USAGE
714                 exit 1;
715             }
716             ACTUAL_INSTALLATION_LOC=$1
717             ACTUAL_CONFIGURATION_LOC=$1
718             ACTUAL_VAR_LOC=$1
719             shift;
720             ;;
721         -pI) Log "  - get actual installation location"
722             shift;
723             [ $# -ne 0 ] || {
724                 USAGE
725                 exit 1;
726             }
727             ACTUAL_INSTALLATION_LOC=$1
728             shift;
729             ;;
730         -pC) Log "  - get actual configuration location"
731             shift;
732             [ $# -ne 0 ] || {
733                 USAGE
734                 exit 1;
735             }
736             ACTUAL_CONFIGURATION_LOC=$1
737             shift;
738             ;;
739         -pV) Log "  - get actual var location"
740             shift;
741             [ $# -ne 0 ] || {
742                 USAGE
743                 exit 1;
744             }
745             ACTUAL_VAR_LOC=$1
746             shift;
747             ;;
748         -clean) Log "  - delete all three cde directories"
749             CLEANING="yes"
750             CLEANING_ETC="yes"
751             shift;
752             ;;
753         -cleanTwo) Log "  - delete only temporary and installation directories"
754             CLEANING="yes"
755             shift;
756             ;;
757         -cleanEtc) Log "  - delete only the configuration directory"
758             CLEANING_ETC="yes"
759             shift;
760             ;;
761         -prog) Log "  - load only the development environment"
762             DEVELOP_ENV="yes"
763             RUNTIME_ENV="no"
764             shift;
765             ;;
766         -runtime) Log "  - load only the runtime environment"
767             RUNTIME_ENV="yes"
768             DEVELOP_ENV="no"
769             shift;
770             ;;
771         -relative) Log "  - run the relative-located config scripts"
772             USE_RELATIVE="yes"
773             shift;
774             ;;
775         -pack) Log "  - create a packing list"
776             CREATE_PACKING_LIST="yes"
777             shift;
778             ;;
779         -LeaveLinks) Log "  - do not remove the links"
780             LeaveLinks="yes"
781             shift;
782             ;;
783         -LinkStepOnly) Log "  - do link step only"
784             DO_LINK_STEP_ONLY="yes"
785             shift;
786             ;;
787         -DontRunScripts) Log "  - stop after installation"
788             DO_INSTALL_ONLY="yes"
789             shift;
790             ;;
791         -RunScriptsOnly) Log "  - only run scripts"
792             RUN_SCRIPTS_ONLY="yes"
793             shift;
794             ;;
795         -pseudo) Log "  - pseudo install"
796             RUN_SCRIPTS="no"
797             REMOVE_LINKS="yes"
798             CLEAN_DAEMONS="no"
799             shift;
800             ;; 
801         -nocompress) Log "  - do not compress tarball"
802             COMPRESS_TARBALL="no"
803             shift;
804             ;;
805         -lang) Log "  - load localized filesets"
806             shift;
807             [ $# -ne 0 ] || {
808                 USAGE
809                 exit 1;
810             }
811             theLang=$1
812             shift;
813             ;;
814         -configureOnly) Log "  - Configure only"
815             CONFIGURE_ONLY="yes"
816             CLEAN_DAEMONS="yes"
817             shift;
818             ;;
819         *) Log "  - unknown option"
820             USAGE
821             exit 1;
822             ;;
823         esac
824   done
825
826   echo ""
827
828   if [ -z "$BUILD_TREE" -a -z "$TAR_TREE" ]
829   then
830     USAGE
831     exit 1
832   fi
833
834   if [ "$BUILD_TREE" != "" -a ! -d "$BUILD_TREE" ]
835   then
836     Log "Build tree does not exist."
837     exit 1
838   fi
839
840   if [ "$TAR_TREE" != "" -a ! -d "$TAR_TREE" ]
841   then
842     Log "Tar tree does not exist."
843     exit 1
844   fi
845
846   CDEPACKAGE=dt.pkg
847   CDETARFILE=dt.tar
848   CDETARFILEZ=dttar.Z
849   CDECONFIGDIR=config
850
851 XCOMM
852 XCOMM get the current time stamp if going to create a tarball
853 XCOMM
854
855   if [ $TARBALL = "yes" ]; 
856   then
857     set -- `/bin/date`
858     DATE=$2_$3_$4_$6
859   fi
860
861   if [ -z "$BUILD_TREE" -a ${0##STAR/} = INSTALL.CDE ]; then
862     typeset -u CDEPACKAGE
863     typeset -u CDETARFILE
864     typeset -u CDETARFILEZ
865     typeset -u CDECONFIGDIR
866   fi
867
868   TOOL_DIR=$BUILD_TREE/admin/IntegTools/dbTools
869   if [ "$USE_RELATIVE" = "yes" ]
870   then
871     POST_INSTALL_DIR=../post_install
872   else
873     if [ -z "$BUILD_TREE" ]
874     then
875       POST_INSTALL_DIR=$TAR_TREE/$CDECONFIGDIR
876     else
877       POST_INSTALL_DIR=$BUILD_TREE/admin/IntegTools/post_install
878     fi
879   fi
880
881   if [ "$USE_ALTERNATE_UDB_DIR" = "yes" ]
882   then
883     DATABASE_DIR=$ALTERNATE_UDB_DIR/databases
884   else
885     DATABASE_DIR=$BUILD_TREE/databases
886   fi
887
888   if [ "$DATABASE_FILES" = "" ]
889   then
890     if [ "$DEVELOP_ENV" = "yes" ]
891     then
892       DATABASE_FILES="CDE-HELP-PRG CDE-PRG CDE-INC CDE-DEMOS \
893                       CDE-MAN-DEV CDE-SHLIBS"
894     elif [ "$RUNTIME_ENV" = "yes" ]
895     then
896       DATABASE_FILES="CDE-RUN CDE-MIN CDE-TT CDE-MAN CDE-HELP-RUN CDE-C \
897                       CDE-HELP-C CDE-MSG-C CDE-SHLIBS CDE-ICONS CDE-FONTS \
898                       CDE-INFO CDE-INFOLIB-C"
899     else
900       DATABASE_FILES="CDE-RUN CDE-MIN CDE-TT CDE-MAN CDE-HELP-RUN CDE-C \
901                       CDE-MSG-C CDE-HELP-C CDE-SHLIBS CDE-HELP-PRG \
902                       CDE-PRG CDE-INC CDE-DEMOS CDE-MAN-DEV CDE-ICONS \
903                       CDE-FONTS CDE-INFO CDE-INFOLIB-C"
904     fi
905
906     HASH now load any localized filesets
907     if [ "$DEVELOP_ENV" != "yes" ]
908     then
909       if [ "$theLang" != "" ]
910       then
911         DATABASE_FILES="$DATABASE_FILES CDE-$theLang CDE-MSG-$theLang \
912                         CDE-HELP-$theLang"
913       else
914         HASH load all current (working) languages
915         DATABASE_FILES="$DATABASE_FILES \
916                                         CDE-DE \
917                                         CDE-MSG-DE \
918                                         CDE-HELP-DE \
919                                         CDE-ES \
920                                         CDE-MSG-ES \
921                                         CDE-HELP-ES \
922                                         CDE-FR \
923                                         CDE-MSG-FR \
924                                         CDE-HELP-FR \
925                                         CDE-IT \
926                                         CDE-MSG-IT \
927                                         CDE-HELP-IT "
928       fi
929     fi
930   fi
931
932   [ -z "$INSTALL_LOCATION" ] && INSTALL_LOCATION=CDE_INSTALLATION_TOP
933   [ -z "$CONFIGURE_LOCATION" ] && CONFIGURE_LOCATION=CDE_CONFIGURATION_TOP
934   [ -z "$LOGFILES_LOCATION" ] && LOGFILES_LOCATION=CDE_LOGFILES_TOP
935
936   if [ -L $INSTALL_LOCATION -a "$CONFIGURE_ONLY" != "yes" ]
937   then
938     touch $INSTALL_LOCATION/foo >/dev/null 2>/dev/null
939     if [ ! -f $INSTALL_LOCATION/foo ]
940     then
941       Log "Insufficient permissions to install CDE files in $INSTALL_LOCATION"
942       exit 1
943     fi
944     if [ ! -O $INSTALL_LOCATION/foo ]
945     then
946       Log "Root access to $INSTALL_LOCATION is required for CDE installation."
947       exit 1
948     fi
949     rm $INSTALL_LOCATION/foo
950   fi
951
952   if [ -d $INSTALL_LOCATION ]
953   then
954     if [ -x $INSTALL_LOCATION/bin -a ! -d $INSTALL_LOCATION/bin ]
955     then
956         rm -f $INSTALL_LOCATION/bin
957     fi
958   fi
959
960   if [ "$CONFIGURE_ONLY" = "yes" ]
961   then
962     CheckForActualLocations
963     DoScripts
964     Log "Configuration completed."
965     exit 0
966   fi
967
968   if [ "$RUN_SCRIPTS_ONLY" = "yes" ]
969   then
970     DoScripts
971     exit 0
972   fi
973
974   CheckForActualLocations
975
976   if [ "$DO_LINK_STEP_ONLY" = "yes" ]
977   then
978     exit 0
979   fi
980
981   if [ "$CREATE_PACKING_LIST" = "yes" ]
982   then
983     CreatePackingList
984     exit 0
985   fi
986
987 XCOMM
988 XCOMM we are ready to load the environment ...
989 XCOMM
990
991   if [ "$BUILD_TREE" != "" ]
992   then
993     Log "Load the Desktop from $BUILD_TREE"
994
995     cd $STARTING_DIR
996     let j=1
997     for i in `echo $DATABASE_FILES`
998     do
999       LoadFileSet "$j" "$i"
1000       let j=j+1
1001     done
1002   else
1003     Log "Load the Desktop from $TAR_TREE"
1004     compressed=$(awk '/COMPRESSED: /{print $2}' $TAR_TREE/$CDEPACKAGE)
1005     if [ "$compressed" = "yes" ]; then
1006       uncompress <$TAR_TREE/$CDETARFILEZ | tar xvf - $INSTALL_LOCATION
1007     else
1008       tar -xvf $TAR_TREE/$CDETARFILE $INSTALL_LOCATION
1009     fi 
1010     DATABASE_FILES=$(awk 'BEGIN {FS=":"} /FILESETS: /{print $2}' $TAR_TREE/$CDEPACKAGE)
1011   fi
1012
1013   Log " "
1014   Log "Desktop installed in $INSTALL_LOCATION"
1015
1016   if [ "$DO_INSTALL_ONLY" = "yes" ]
1017   then
1018     exit 0
1019   fi
1020
1021   if [ $TARBALL = "yes" ]; 
1022   then
1023     MakeTarball
1024   fi
1025
1026   cd $STARTING_DIR
1027
1028   if [ "$RUN_SCRIPTS" = "yes" ]
1029   then
1030     DoScripts
1031   fi
1032   
1033   if [ "$REMOVE_LINKS" = "yes" ]
1034   then
1035     [ -L /usr/dt ] && rm /usr/dt
1036     [ -L /etc/dt ] && rm /etc/dt
1037     [ -L /var/dt ] && rm /var/dt
1038   fi
1039
1040   echo "Done."
1041   echo ""
1042   echo "See $LOGFILE for a log of this install session."
1043   echo ""