dtinfo other files
[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" = "linux" ]
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/sh -f
232         sleep 2
233       fi
234     else    
235       ps -ef | grep $i | grep -v grep >/tmp/tmppsout
236       if [ -s /tmp/tmppsout ]
237       then
238         awk '{print "kill " $2}' /tmp/tmppsout | /bin/csh -f
239         sleep 2
240       fi
241     fi
242   done
243   rm -f /tmp/tmppsout
244 }
245
246 RestartInetd()
247 {
248   HASH now restart inetd
249
250   OLDPWD=`pwd`
251   cd /
252   if [ "$PLATFORM" = "sun" -o "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ]
253   then
254     /usr/sbin/inetd -s
255   elif [ "$PLATFORM" = "aix" ]
256   then
257     startsrc -s inetd >>$LOGFILE 2>&1
258   elif [ "$PLATFORM" = "dec" ]
259   then
260     /usr/sbin/inetd
261   elif [ "$PLATFORM" = "openbsd" ]
262   then
263     /etc/rc.d/inetd start >/dev/null
264   elif [ "$PLATFORM" = "freebsd" ]
265   then
266     /etc/rc.d/inetd onestart
267   elif [ "$PLATFORM" = "linux" ]
268   then
269     /etc/init.d/openbsd-inetd start >/dev/null 2>&1
270   else
271 #ifdef hpV4
272     /usr/sbin/inetd 
273 #else
274     /etc/inetd
275 #endif
276   fi
277   cd $OLDPWD
278 }
279
280 CheckForActualLocations()
281 {
282 XCOMM
283 XCOMM if different actual locations specified, set up the links
284 XCOMM
285
286
287   if [ "$CLEAN_DAEMONS" = "yes" ]
288   then
289     CleanDaemons
290   fi
291
292   HASH remove the contents of the installation directory then the directory
293   HASH itself
294
295   if [ "$CLEANING" = "yes" ]
296   then
297     Log "Removing $INSTALL_LOCATION contents... "
298     if [ -d $INSTALL_LOCATION ]
299     then
300       rm -rf $INSTALL_LOCATION/STAR
301       if [ "$LeaveLinks" = "yes" ]
302       then
303         if [ ! -L $INSTALL_LOCATION ]
304         then
305           rm -rf $INSTALL_LOCATION
306         fi
307       else
308         if [ -L $INSTALL_LOCATION ]
309         then
310           rm -f $INSTALL_LOCATION
311         else
312           rm -rf $INSTALL_LOCATION
313         fi
314       fi
315     fi
316   fi
317
318   if [ "$CONFIGURE_ONLY" = "no" ]
319   then
320     if [ "$ACTUAL_INSTALLATION_LOC" != "" ]
321     then
322
323       HASH
324       HASH first create the actual directory - if not there
325       HASH
326
327       if [ ! -d $ACTUAL_INSTALLATION_LOC ]
328       then
329         mkdir -p $ACTUAL_INSTALLATION_LOC
330         if [ ! -d $ACTUAL_INSTALLATION_LOC ]
331         then
332           Log "cannot create $ACTUAL_INSTALLATION_LOC directory"
333           exit 1
334         fi
335       fi
336
337       ln -s $ACTUAL_INSTALLATION_LOC $INSTALL_LOCATION
338
339     else
340       if [ ! -d $INSTALL_LOCATION -a ! -L $INSTALL_LOCATION ]; 
341       then
342         mkdir -p $INSTALL_LOCATION
343       fi
344     fi
345   fi
346
347   if [ "$CLEAN_DAEMONS" = "yes" ]
348   then
349     RestartInetd
350   fi
351
352   HASH remove the contents of the configuration directory
353
354   if [ "$CLEANING_ETC" = "yes" ]
355   then
356     Log "Removing $CONFIGURE_LOCATION contents... "
357     if [ -d $CONFIGURE_LOCATION ]
358     then
359       rm -rf $CONFIGURE_LOCATION/STAR
360       if [ "$LeaveLinks" = "yes" ]
361       then
362         if [ ! -L $CONFIGURE_LOCATION ]
363         then
364           rm -rf $CONFIGURE_LOCATION
365         fi
366       else
367         if [ -L $CONFIGURE_LOCATION ]
368         then
369           rm -f $CONFIGURE_LOCATION
370         else
371           rm -rf $CONFIGURE_LOCATION
372         fi
373       fi
374     fi
375   fi
376         
377   if [ "$ACTUAL_CONFIGURATION_LOC" != "" ]
378   then
379     if [ ! -d $ACTUAL_CONFIGURATION_LOC ]
380     then
381       mkdir -p $ACTUAL_CONFIGURATION_LOC
382       if [ ! -d $ACTUAL_CONFIGURATION_LOC ]
383       then
384         Log "cannot create $ACTUAL_CONFIGURATION_LOC directory"
385         exit 1
386       fi
387     fi
388
389     ln -s $ACTUAL_CONFIGURATION_LOC $CONFIGURE_LOCATION
390
391   else
392     if [ ! -d $CONFIGURE_LOCATION -a ! -L $CONFIGURE_LOCATION ];
393     then
394       mkdir -p $CONFIGURE_LOCATION
395     fi
396   fi
397
398   if [ "$CLEANING" = "yes" ]
399   then
400     Log "Removing $LOGFILES_LOCATION contents... "
401     if [ -d $LOGFILES_LOCATION ]
402     then
403       rm -rf $LOGFILES_LOCATION/STAR
404       if [ "$LeaveLinks" = "yes" ]
405       then
406         if [ ! -L $LOGFILES_LOCATION ]
407         then
408           rm -rf $LOGFILES_LOCATION
409         fi
410       else
411         if [ -L $LOGFILES_LOCATION ]
412         then
413           rm -f $LOGFILES_LOCATION
414         else
415           rm -rf $LOGFILES_LOCATION
416         fi
417       fi
418     fi
419   fi
420
421   if [ "$ACTUAL_VAR_LOC" != "" ]
422   then
423     if [ ! -d $ACTUAL_VAR_LOC ]
424     then
425       mkdir -p $ACTUAL_VAR_LOC
426       if [ ! -d $ACTUAL_VAR_LOC ]
427       then
428         Log "cannot create $ACTUAL_VAR_LOC directory"
429         exit 1
430       fi
431     fi
432
433     ln -s $ACTUAL_VAR_LOC $LOGFILES_LOCATION
434     
435   else
436     if [ ! -d $LOGFILES_LOCATION -a ! -L $LOGFILES_LOCATION ]; 
437     then
438       mkdir -p $LOGFILES_LOCATION
439     fi
440   fi
441
442   Log " "
443 }
444
445 USAGE()
446 {
447 echo -e "Usage: $(basename $0) {-s <source>|-z <package>} [options]"
448 echo -e ""
449 echo -e "\t-s <source>\t\t\tthe top of the build tree"
450 echo -e "\t-z <package>\t\tthe desktop install package"
451 echo -e ""
452 echo -e "\tOptions:"
453 echo -e ""
454 echo -e "\t[-t <package_destination>]\tif specified create an"
455 echo -e "\t\t\t\t\tinstall package and store it in the"
456 echo -e "\t\t\t\t\tdestination."
457 echo -e "\t[-pI <actual install location>]\twhere" CDE_INSTALLATION_TOP "will be linked to."
458 echo -e "\t[-pC <actual config location>]\twhere" CDE_CONFIGURATION_TOP "will be linked to."
459 echo -e "\t[-pV <actual var location>]\twhere" CDE_LOGFILES_TOP "will be linked to."
460 echo -e ""
461 echo -e "\t[-a <udb directory>]\t\talternate place to get the"
462 echo -e "\t\t\t\t\tudb files from."
463 echo -e "\t[-f <filesets>]\t\t\tspecify filesets to be loaded."
464 echo -e "\t\t\t\t\tThe list should be double-quoted,"
465 echo -e "\t\t\t\t\tspace-separated, with no .udb"
466 echo -e "\t\t\t\t\textensions."
467 echo -e ""
468 echo -e "\t[-clean]\t\t\tremove the temporary, configuration, and"
469 echo -e "\t\t\t\t\tinstallation directory"
470 echo -e "\t[-cleanTwo]\t\t\tremove the temporary and installation "
471 echo -e "\t\t\t\t\tdirectory, but NOT the configuration directory"
472 echo -e "\t[-cleanEtc]\t\t\tremove the configuration directory, but "
473 echo -e "\t\t\t\t\NOT the temporary and installation directories"
474 echo -e "\t[-prog]\t\t\t\tload only the development environment"
475 echo -e "\t[-runtime]\t\t\tload only the runtime environment"
476 echo -e "\t[-relative]\t\t\trun the relative-located config scripts"
477 echo -e "\t[-pack]\t\t\t\tcreate a packing list"
478 echo -e "\t[-pseudo]\t\t\tdo not configure desktop when installing"
479 echo -e "\t[-nocompress]\t\t\tdo not compress tarball when creating package"
480 echo -e "\t[-lang LANG]\t\t\tspecify LANG to load appropriate localized"
481 echo -e "\t\t\t\t\tfilesets"
482 echo -e "\t[-LeaveLinks]\t\t\t\tdo not delete the links after cleaning"
483 echo -e ""
484 echo -e "\t[-LinkStepOnly]\t\t\tset up the -pI, -pC, and -pV links"
485 echo -e "\t\t\t\t\tthen exit"
486 echo -e "\t[-DontRunScripts]\t\tstop after installation"
487 echo -e "\t[-RunScriptsOnly]\t\tonly execute the scripts"
488 echo -e "\t[-configureOnly]\t\tonly configure the desktop"
489 echo -e ""
490 echo -e "\tExamples:"
491 echo -e ""
492 echo -e "\tinstallCDE -s /x/cde_hp700_90"
493 echo -e "\tinstallCDE -s /x/cde_aix_32 -f \"CDE_MIN CDE-SHLIBS\""
494 echo -e "\tinstallCDE -s /x/cde_sun_52 -pI /bigdisk/opt/dt -clean"
495 echo -e "\tinstallCDE -s /x/cde_sun_52 -pI /dtinstall -clean\\"
496 echo -e "\t\t-pseudo -t /dtpackages -nocompress"
497 }
498
499 XCOMM
500 XCOMM LoadFileSet() - load a UDB file
501 XCOMM $1 - fileset number
502 XCOMM $2 - fileset name
503 XCOMM
504 LoadFileSet()
505 {
506   if [ "$1" = "" ]; then
507     num=""
508   else
509     num="$1."
510   fi
511
512 XCOMM don't bother if the fileset doesn't exist
513   if [ ! -e $DATABASE_DIR/${2}.udb ]
514   then
515         return
516   fi
517
518   Log "  $num installing database $2"
519   Log "      - creating ${2}.lst file"
520   KORNSHELL $TOOL_DIR/udbToAny.ksh  -toLst -ReleaseStream $PLATFORM \
521             $DATABASE_DIR/${2}.udb >  /tmp/${2}.lst
522   Log "      - installing ... "
523   KORNSHELL $TOOL_DIR/mkProd -D / -S $BUILD_TREE /tmp/${2}.lst \
524             2>/tmp/${2}.err 1>/tmp/${2}.good
525   Log "        done."
526
527   Log "      - checking for errors ..."
528   rm -f /tmp/${2}.missing
529   awk '{if ($1 == "ERROR:") print "           " $4}' \
530             /tmp/${2}.err >> /tmp/${2}.missing
531   if [ -s /tmp/${2}.missing ]
532   then
533     Log "      - missing files:"
534     cat /tmp/${2}.missing | tee -a $LOGFILE
535   fi
536 }
537
538 ORIGINAL_COMMAND_LINE="$*"
539
540 XCOMM Set which system we are on
541 BUILDSYSTEM=$(uname)
542
543 PLATFORM=""
544 PLATFORM_SCRIPT_DIR=""
545
546 XCOMM
547 XCOMM Set system
548 XCOMM 
549   if [ $BUILDSYSTEM = "AIX" ];
550   then
551     PLATFORM=aix
552     PLATFORM_SCRIPT_DIR=ibm
553   elif [ $BUILDSYSTEM = "SunOS" ];
554   then
555     PLATFORM=sun
556     PLATFORM_SCRIPT_DIR=sun
557   elif [ $BUILDSYSTEM = "UNIX_SV" ];
558   then
559     PLATFORM=usl
560     PLATFORM_SCRIPT_DIR=usl
561   elif [ $BUILDSYSTEM = "UNIX_System_V" ];
562   then
563     PLATFORM=uxp
564     PLATFORM_SCRIPT_DIR=uxp
565   elif [ $BUILDSYSTEM = "OSF1" ];
566   then
567     PLATFORM=dec
568     PLATFORM_SCRIPT_DIR=dec
569   elif [ $BUILDSYSTEM = "Linux" ];
570   then
571     PLATFORM="linux"
572     PLATFORM_SCRIPT_DIR="linux"
573   elif [ $BUILDSYSTEM = "FreeBSD" ];
574   then
575     PLATFORM="freebsd"
576     PLATFORM_SCRIPT_DIR="freebsd"
577   elif [ $BUILDSYSTEM = "OpenBSD" ];
578   then
579     PLATFORM="openbsd"
580     PLATFORM_SCRIPT_DIR="openbsd"
581   else                  # Build system = HP
582     PLATFORM=hp-ux
583     PLATFORM_SCRIPT_DIR=hp
584   fi
585
586   if [ "$PLATFORM" = "aix" ];
587   then
588     USER=`/bin/whoami`
589   elif [ "$PLATFORM" = "sun" -o "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ];
590   then
591     USER=`/usr/ucb/whoami`
592   else
593     USER=`/usr/bin/whoami`
594   fi
595
596   if [ "$USER" != "root" ];
597   then
598     echo ""
599     echo "You should be root to run this script.  Continuing anyway."
600     echo ""
601   fi
602
603   if [ "$PLATFORM" = "usl" -o "$PLATFORM" = "uxp" ]
604   then
605     umask 000
606   fi
607
608   unset TMPDIR
609
610   CLEANING="no"
611   CLEANING_ETC="no"
612   TARBALL="no"
613   COMPRESS_TARBALL="yes"
614   USE_ALTERNATE_UDB_DIR="no"
615   DEVELOP_ENV="no"
616   RUNTIME_ENV="no"
617   USE_RELATIVE="no"
618   STARTING_DIR=$PWD
619   ACTUAL_INSTALLATION_LOC=""
620   ACTUAL_CONFIGURATION_LOC=""
621   ACTUAL_VAR_LOC=""
622   CREATE_PACKING_LIST="no"
623   DO_LINK_STEP_ONLY="no"
624   DO_INSTALL_ONLY="no"
625   RUN_SCRIPTS="yes"
626   RUN_SCRIPTS_ONLY="no"
627   DATABASE_FILES=""
628   BUILD_TREE=""
629   TAR_DIR=""
630   LeaveLinks="no"
631   REMOVE_LINKS="no"
632   CLEAN_DAEMONS="yes"
633   theLang=""
634   CONFIGURE_ONLY="no"
635
636   rm -f $LOGFILE
637
638   Log "Options specified..."
639   while [ $# -ne 0 ]; do
640     case $1 in
641         -s) Log "  - get the build tree to extract from"
642             shift;
643             [ $# -ne 0 ] || {
644                 USAGE
645                 exit 1;
646             }
647             BUILD_TREE=$1
648             shift;
649             ;;
650         -z) Log "  - get the install package to extract from"
651             shift;
652             [ $# -ne 0 ] || {
653                 USAGE
654                 exit 1;
655             }
656             TAR_TREE=$1
657             shift;
658             ;;
659         -t) Log "  - where to put the install package"
660             shift;
661             [ $# -ne 0 ] || {
662                 USAGE
663                 exit 1;
664             }
665             if [ "$SOURCE_TAR_FILE" = "" ]
666             then
667                 TARBALL="yes"
668                 TARBALL_LOCATION=$1
669             fi
670             shift;
671             ;;
672         -a) Log "  - alternate place to get the udb files from"
673             shift;
674             [ $# -ne 0 ] || {
675                 USAGE
676                 exit 1;
677             }
678             ALTERNATE_UDB_DIR=$1
679             USE_ALTERNATE_UDB_DIR="yes"
680             shift;
681             ;;
682         -f) Log "  - load specific filesets"
683             shift;
684             [ $# -ne 0 ] || {
685                 USAGE
686                 exit 1;
687             }
688             DATABASE_FILES=$1
689             shift;
690             ;;
691         -p) Log "  - get all locations"
692             shift;
693             [ $# -ne 0 ] || {
694                 USAGE
695                 exit 1;
696             }
697             ACTUAL_INSTALLATION_LOC=$1
698             ACTUAL_CONFIGURATION_LOC=$1
699             ACTUAL_VAR_LOC=$1
700             shift;
701             ;;
702         -pI) Log "  - get actual installation location"
703             shift;
704             [ $# -ne 0 ] || {
705                 USAGE
706                 exit 1;
707             }
708             ACTUAL_INSTALLATION_LOC=$1
709             shift;
710             ;;
711         -pC) Log "  - get actual configuration location"
712             shift;
713             [ $# -ne 0 ] || {
714                 USAGE
715                 exit 1;
716             }
717             ACTUAL_CONFIGURATION_LOC=$1
718             shift;
719             ;;
720         -pV) Log "  - get actual var location"
721             shift;
722             [ $# -ne 0 ] || {
723                 USAGE
724                 exit 1;
725             }
726             ACTUAL_VAR_LOC=$1
727             shift;
728             ;;
729         -clean) Log "  - delete all three cde directories"
730             CLEANING="yes"
731             CLEANING_ETC="yes"
732             shift;
733             ;;
734         -cleanTwo) Log "  - delete only temporary and installation directories"
735             CLEANING="yes"
736             shift;
737             ;;
738         -cleanEtc) Log "  - delete only the configuration directory"
739             CLEANING_ETC="yes"
740             shift;
741             ;;
742         -prog) Log "  - load only the development environment"
743             DEVELOP_ENV="yes"
744             RUNTIME_ENV="no"
745             shift;
746             ;;
747         -runtime) Log "  - load only the runtime environment"
748             RUNTIME_ENV="yes"
749             DEVELOP_ENV="no"
750             shift;
751             ;;
752         -relative) Log "  - run the relative-located config scripts"
753             USE_RELATIVE="yes"
754             shift;
755             ;;
756         -pack) Log "  - create a packing list"
757             CREATE_PACKING_LIST="yes"
758             shift;
759             ;;
760         -LeaveLinks) Log "  - do not remove the links"
761             LeaveLinks="yes"
762             shift;
763             ;;
764         -LinkStepOnly) Log "  - do link step only"
765             DO_LINK_STEP_ONLY="yes"
766             shift;
767             ;;
768         -DontRunScripts) Log "  - stop after installation"
769             DO_INSTALL_ONLY="yes"
770             shift;
771             ;;
772         -RunScriptsOnly) Log "  - only run scripts"
773             RUN_SCRIPTS_ONLY="yes"
774             shift;
775             ;;
776         -pseudo) Log "  - pseudo install"
777             RUN_SCRIPTS="no"
778             REMOVE_LINKS="yes"
779             CLEAN_DAEMONS="no"
780             shift;
781             ;; 
782         -nocompress) Log "  - do not compress tarball"
783             COMPRESS_TARBALL="no"
784             shift;
785             ;;
786         -lang) Log "  - load localized filesets"
787             shift;
788             [ $# -ne 0 ] || {
789                 USAGE
790                 exit 1;
791             }
792             theLang=$1
793             shift;
794             ;;
795         -configureOnly) Log "  - Configure only"
796             CONFIGURE_ONLY="yes"
797             CLEAN_DAEMONS="yes"
798             shift;
799             ;;
800         *) Log "  - unknown option"
801             USAGE
802             exit 1;
803             ;;
804         esac
805   done
806
807   echo ""
808
809   if [ -z "$BUILD_TREE" -a -z "$TAR_TREE" ]
810   then
811     USAGE
812     exit 1
813   fi
814
815   if [ "$BUILD_TREE" != "" -a ! -d "$BUILD_TREE" ]
816   then
817     Log "Build tree does not exist."
818     exit 1
819   fi
820
821   if [ "$TAR_TREE" != "" -a ! -d "$TAR_TREE" ]
822   then
823     Log "Tar tree does not exist."
824     exit 1
825   fi
826
827   CDEPACKAGE=dt.pkg
828   CDETARFILE=dt.tar
829   CDETARFILEZ=dttar.Z
830   CDECONFIGDIR=config
831
832 XCOMM
833 XCOMM get the current time stamp if going to create a tarball
834 XCOMM
835
836   if [ $TARBALL = "yes" ]; 
837   then
838     set -- `/bin/date`
839     DATE=$2_$3_$4_$6
840   fi
841
842   if [ -z "$BUILD_TREE" -a ${0##STAR/} = INSTALL.CDE ]; then
843     typeset -u CDEPACKAGE
844     typeset -u CDETARFILE
845     typeset -u CDETARFILEZ
846     typeset -u CDECONFIGDIR
847   fi
848
849   TOOL_DIR=$BUILD_TREE/admin/IntegTools/dbTools
850   if [ "$USE_RELATIVE" = "yes" ]
851   then
852     POST_INSTALL_DIR=../post_install
853   else
854     if [ -z "$BUILD_TREE" ]
855     then
856       POST_INSTALL_DIR=$TAR_TREE/$CDECONFIGDIR
857     else
858       POST_INSTALL_DIR=$BUILD_TREE/admin/IntegTools/post_install
859     fi
860   fi
861
862   if [ "$USE_ALTERNATE_UDB_DIR" = "yes" ]
863   then
864     DATABASE_DIR=$ALTERNATE_UDB_DIR/databases
865   else
866     DATABASE_DIR=$BUILD_TREE/databases
867   fi
868
869   if [ "$DATABASE_FILES" = "" ]
870   then
871     if [ "$DEVELOP_ENV" = "yes" ]
872     then
873       DATABASE_FILES="CDE-HELP-PRG CDE-PRG CDE-INC CDE-DEMOS \
874                       CDE-MAN-DEV CDE-SHLIBS"
875     elif [ "$RUNTIME_ENV" = "yes" ]
876     then
877       DATABASE_FILES="CDE-RUN CDE-MIN CDE-TT CDE-MAN CDE-HELP-RUN CDE-C \
878                       CDE-HELP-C CDE-MSG-C CDE-SHLIBS CDE-ICONS CDE-FONTS \
879                       CDE-INFO CDE-INFOLIB-C"
880     else
881       DATABASE_FILES="CDE-RUN CDE-MIN CDE-TT CDE-MAN CDE-HELP-RUN CDE-C \
882                       CDE-MSG-C CDE-HELP-C CDE-SHLIBS CDE-HELP-PRG \
883                       CDE-PRG CDE-INC CDE-DEMOS CDE-MAN-DEV CDE-ICONS \
884                       CDE-FONTS CDE-INFO CDE-INFOLIB-C"
885     fi
886
887     HASH now load any localized filesets
888     if [ "$DEVELOP_ENV" != "yes" ]
889     then
890       if [ "$theLang" != "" ]
891       then
892         DATABASE_FILES="$DATABASE_FILES CDE-$theLang CDE-MSG-$theLang \
893                         CDE-HELP-$theLang"
894       else
895         HASH load all current (working) languages
896         DATABASE_FILES="$DATABASE_FILES \
897                                         CDE-DE \
898                                         CDE-MSG-DE \
899                                         CDE-HELP-DE \
900                                         CDE-ES \
901                                         CDE-MSG-ES \
902                                         CDE-HELP-ES \
903                                         CDE-FR \
904                                         CDE-MSG-FR \
905                                         CDE-HELP-FR \
906                                         CDE-IT \
907                                         CDE-MSG-IT \
908                                         CDE-HELP-IT "
909       fi
910     fi
911   fi
912
913   [ -z "$INSTALL_LOCATION" ] && INSTALL_LOCATION=CDE_INSTALLATION_TOP
914   [ -z "$CONFIGURE_LOCATION" ] && CONFIGURE_LOCATION=CDE_CONFIGURATION_TOP
915   [ -z "$LOGFILES_LOCATION" ] && LOGFILES_LOCATION=CDE_LOGFILES_TOP
916
917   if [ -L $INSTALL_LOCATION -a "$CONFIGURE_ONLY" != "yes" ]
918   then
919     touch $INSTALL_LOCATION/foo >/dev/null 2>/dev/null
920     if [ ! -f $INSTALL_LOCATION/foo ]
921     then
922       Log "Insufficient permissions to install CDE files in $INSTALL_LOCATION"
923       exit 1
924     fi
925     if [ ! -O $INSTALL_LOCATION/foo ]
926     then
927       Log "Root access to $INSTALL_LOCATION is required for CDE installation."
928       exit 1
929     fi
930     rm $INSTALL_LOCATION/foo
931   fi
932
933   if [ -d $INSTALL_LOCATION ]
934   then
935     if [ -x $INSTALL_LOCATION/bin -a ! -d $INSTALL_LOCATION/bin ]
936     then
937         rm -f $INSTALL_LOCATION/bin
938     fi
939   fi
940
941   if [ "$CONFIGURE_ONLY" = "yes" ]
942   then
943     CheckForActualLocations
944     DoScripts
945     Log "Configuration completed."
946     exit 0
947   fi
948
949   if [ "$RUN_SCRIPTS_ONLY" = "yes" ]
950   then
951     DoScripts
952     exit 0
953   fi
954
955   CheckForActualLocations
956
957   if [ "$DO_LINK_STEP_ONLY" = "yes" ]
958   then
959     exit 0
960   fi
961
962   if [ "$CREATE_PACKING_LIST" = "yes" ]
963   then
964     CreatePackingList
965     exit 0
966   fi
967
968 XCOMM
969 XCOMM we are ready to load the environment ...
970 XCOMM
971
972   if [ "$BUILD_TREE" != "" ]
973   then
974     Log "Load the Desktop from $BUILD_TREE"
975
976     cd $STARTING_DIR
977     let j=1
978     for i in `echo $DATABASE_FILES`
979     do
980       LoadFileSet "$j" "$i"
981       let j=j+1
982     done
983   else
984     Log "Load the Desktop from $TAR_TREE"
985     compressed=$(awk '/COMPRESSED: /{print $2}' $TAR_TREE/$CDEPACKAGE)
986     if [ "$compressed" = "yes" ]; then
987       uncompress <$TAR_TREE/$CDETARFILEZ | tar xvf - $INSTALL_LOCATION
988     else
989       tar -xvf $TAR_TREE/$CDETARFILE $INSTALL_LOCATION
990     fi 
991     DATABASE_FILES=$(awk 'BEGIN {FS=":"} /FILESETS: /{print $2}' $TAR_TREE/$CDEPACKAGE)
992   fi
993
994   Log " "
995   Log "Desktop installed in $INSTALL_LOCATION"
996
997   if [ "$DO_INSTALL_ONLY" = "yes" ]
998   then
999     exit 0
1000   fi
1001
1002   if [ $TARBALL = "yes" ]; 
1003   then
1004     MakeTarball
1005   fi
1006
1007   cd $STARTING_DIR
1008
1009   if [ "$RUN_SCRIPTS" = "yes" ]
1010   then
1011     DoScripts
1012   fi
1013   
1014   if [ "$REMOVE_LINKS" = "yes" ]
1015   then
1016     [ -L /usr/dt ] && rm /usr/dt
1017     [ -L /etc/dt ] && rm /etc/dt
1018     [ -L /var/dt ] && rm /var/dt
1019   fi
1020
1021   echo "Done."
1022   echo ""
1023   echo "See $LOGFILE for a log of this install session."
1024   echo ""