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