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