dtinfo other files
[oweals/cde.git] / cde / admin / IntegTools / post_install / hp / configMin
1 #! /bin/ksh
2 ########
3 #  Product: CDE
4 #  Fileset: CDE-MIN
5 #  configure
6 #  @(#) $XConsortium: configMin /main/1 1995/09/15 17:48:04 cde-hp $
7 ########
8 #
9 # (c) Copyright Hewlett-Packard Company, 1993
10 #
11 ########
12
13
14
15 PRODUCT=CDE
16 FILESET=CDE-MIN
17 DT_TEMP_TOP=/var/dt
18 retval=0
19 hostname=`hostname`
20 DO_CONFIGURATION=""
21
22
23 CreateVarDtDirectory()
24 {
25     if [ -x /bin/getcontext ]
26     then
27         if [ `/bin/getcontext | awk '{print $1}'` != "standalone" ]
28         then
29             base=${DT_TEMP_TOP%/*}
30             if [ ! -d $base ]
31             then
32                 mkdir -p $base
33             fi
34             if [ ! -d $DT_TEMP_TOP ]
35             then
36
37                 exec 3< /etc/clusterconf
38                 oldIFS=$IFS
39                 IFS=:
40                 CONTEXT=""
41                 while read -u3 lanid node name id num1 num2
42                 do
43                     if [ "$name" != "" ]
44                     then
45                         CONTEXT="$CONTEXT -c $name"
46                     fi
47                 done
48                 IFS=$oldIFS
49                 exec 3<&-
50
51                 mkdir -p $DT_TEMP_TOP
52                 makecdf $CONTEXT $DT_TEMP_TOP
53             fi
54         fi
55     fi
56 }
57
58 FixEtcServices()
59 {
60 FILE="/etc/services"
61 TMPFILE="/tmp/etc-services"
62
63 #
64 # check for existence of /etc/services
65 #
66
67     if [ ! -f $FILE ]   # highly unlikely
68     then
69         echo "" >$FILE
70     fi
71
72 #
73 # see if it already exists
74 #
75
76     awk '{if ($1 == "dtspc")
77                 print $0 > "/tmp/dtspc-already-there"
78          }' $FILE >/dev/null
79
80     if [ ! -f /tmp/dtspc-already-there ]
81     then
82         echo "dtspc\t6112/tcp\t#subprocess control" >>$FILE
83     else
84         rm /tmp/dtspc-already-there
85     fi
86
87 #
88 # remove legacy entries like dtspcd
89 #
90
91     awk '{if ($1 == "dtspcd" || $1 == "#dtspcd")
92                 ;
93           else
94                 print $0
95          }' $FILE >$TMPFILE
96
97     mv $TMPFILE $FILE
98
99 }
100
101 UnfixEtcServices()
102 {
103 FILE="/etc/services"
104 TMPFILE="/tmp/etc-services"
105
106     awk '{if ($1 == "dtspc" && $2 == "6112/tcp")
107                 ;
108           else
109                 print $0
110          }' $FILE >$TMPFILE
111
112     mv $TMPFILE $FILE
113 }
114
115 FixInetdDotConf()
116 {
117 FILE="/etc/inetd.conf"
118 TMPFILE="/tmp/inetd.conf.$$"
119
120 #
121 # check for existence of /etc/inetd.conf
122 #
123
124     if [ ! -f $FILE ]   # highly unlikely
125     then
126         echo "" >$FILE
127     fi
128
129     awk '{if ($1 == "dtspc" || $1 == "dtspcd" || $1 == "#dtspcd")
130                 ;
131           else
132                 print $0
133          }' $FILE >$TMPFILE
134
135     mv $FILE $FILE.old
136     mv $TMPFILE $FILE
137
138     DTSPCD=/usr/dt/bin/dtspcd
139
140     echo "dtspc stream tcp nowait root $DTSPCD $DTSPCD -mount_point $DTMOUNTPOINT" >>$FILE
141 }
142
143 UnfixInetdDotConf()
144 {
145 FILE="/etc/inetd.conf"
146 TMPFILE="/tmp/inetd.conf"
147
148     awk '{if ($1 == "dtspc")
149                 ;
150           else
151                 print $0
152          }' $FILE >$TMPFILE
153
154     mv $TMPFILE $FILE
155 }
156
157 FixInetdDotSec()
158 {
159 FILE="/usr/adm/inetd.sec"
160 TMPFILE="/tmp/new-inetd.sec"
161
162 #
163 # check for existence of /usr/adm/inetd.sec
164 #
165
166     if [ ! -f $FILE ]   # highly unlikely
167     then
168         echo "" >$FILE
169     fi
170
171 #
172 # remove legacy entries
173 #
174
175     awk '{if ($1 == "dtspcd")
176                 ;
177           else
178                 print $0
179          }' $FILE >$TMPFILE
180
181     mv $TMPFILE $FILE
182
183 #
184 # see if it already exists
185 #
186
187     awk '{if ($1 == "dtspc")
188                 print $0 > "/tmp/dtspc-already-there"
189          }' $FILE >/dev/null
190
191     if [ ! -f /tmp/dtspc-already-there ]
192     then
193         echo "dtspc\tallow\t127.0.0.1\t$hostname" >>$FILE
194     else
195         status=`grep -q $hostname /tmp/dtspc-already-there`
196         if [[ $status -ne 0 ]]
197         then
198             cat /tmp/dtspc-already-there >> $FILE
199             awk -v hname=$hostname \
200                 '{if ($1 != "dtspc")
201                         print $0;
202                   else
203                         print $0 hname
204                 }' $FILE > $TMPFILE
205
206             mv $FILE ${FILE}.old
207             mv $TMPFILE $FILE
208         fi
209         rm /tmp/dtspc-already-there
210     fi
211
212 }
213
214 UnfixInetdDotSec()
215 {
216 FILE="/usr/adm/inetd.sec"
217 TMPFILE="/tmp/new-inetd.sec"
218
219     awk '{if ($1 == "dtspc")
220                 ;
221           else
222                 print $0
223          }' $FILE >$TMPFILE
224
225     mv $TMPFILE $FILE
226 }
227
228 RemoveMinFiles()
229 {
230     while read SRC
231     do
232       if [ "$SRC" != "" ]
233       then
234         rm -f $SRC
235         dirname=${SRC%/*}
236         if [ -d $dirname ]
237         then
238           cd $dirname
239           while [ "$dirname" != "$CDE_TOP" ]
240           do
241             cd ..
242             rmdir ${dirname##*/} >/dev/null 2>/dev/null
243             dirname=${dirname%/*}
244           done
245         fi
246       fi
247     done <<-EOF
248 /usr/dt/copyright
249 /usr/dt/lib/dtksh/DtFuncs.dtsh
250 /usr/dt/bin/dtspcd
251 /usr/dt/bin/dtappintegrate
252 /usr/dt/bin/dtksh
253 /usr/dt/bin/suid_exec
254 /usr/dt/app-defaults/C/Dtksh
255 /usr/dt/config/dtspcdenv
256 /usr/dt/bin/dtexec
257         EOF
258 }
259
260 VerifyInstalledFiles()
261 {
262     echo "Status   mode    owner   group   filename"
263     echo "-----------------------------------------"
264 #         exists  correct correct correct  /usr/dt/foo1
265 #         MISSING  WRONG   WRONG   WRONG   /usr/dt/foo2
266 #        exists    the link is correct    /usr/dt/link
267
268     while read SRC
269     do
270       if [ "$SRC" != "" ]
271       then
272         set -A tokens $SRC
273         if [ "${tokens[3]}" = "file" ]
274         then
275           if [ -f ${tokens[0]} ]
276           then
277             echo "exists  \c"
278           else
279             echo "MISSING or REMOVED               \c"
280             echo "${tokens[0]}"
281             continue
282           fi
283         elif [ "${tokens[3]}" = "sym_link" ]
284         then
285           if [ -L ${tokens[0]} ]
286           then
287             echo "exists  \c"
288           else
289             echo "MISSING or REMOVED               \c"
290             echo "${tokens[0]}"
291             continue
292           fi
293         fi
294
295         if [ "${tokens[3]}" = "file" ]
296         then
297           touch /tmp/config-test
298           chmod ${tokens[1]} /tmp/config-test
299           tmpperms=`ls -l /tmp/config-test | awk '{print $1}'`
300           realperms=`ls -l ${tokens[0]} | awk '{print $1}'`
301
302           if [ "$tmpperms" = "$realperms" ]
303           then
304             echo "correct \c"
305           else
306             echo " WRONG  \c"
307           fi
308
309           owner=`ls -l ${tokens[0]} | awk '{print $3}'`
310
311           if [ "$owner" = "${tokens[4]}" ]
312           then
313             echo "correct \c"
314           else
315             echo " WRONG  \c"
316           fi
317
318           group=`ls -l ${tokens[0]} | awk '{print $4}'`
319
320           if [ "$group" = "${tokens[5]}" ]
321           then
322             echo "correct  \c"
323           else
324             echo " WRONG   \c"
325           fi
326         elif [ "${tokens[3]}" = "sym_link" ]
327         then
328           linkto=`ls -l ${tokens[0]} | awk '{print $11}'`
329           if [ "${tokens[2]}" = "$linkto" ]
330           then
331             echo "  the link is correct    \c"
332           else
333             echo "  the link is WRONG      \c"
334           fi
335         fi
336         echo "${tokens[0]}"
337       fi
338     done <<-EOF
339 /usr/dt/copyright 0444 copyright file bin bin di---- 378 cde_dt
340 /usr/dt/lib/dtksh/DtFuncs.dtsh 0444 cde1/dtksh/DtFuncs.sh file bin bin di---- 378 cde_dt
341 /usr/dt/bin/dtspcd 0555 cde1/dtspcd/dtspcd file bin bin di---- 378 cde_dt
342 /usr/dt/bin/dtappintegrate 0555 cde1/dtappintegrate/dtappintegrate file bin bin di---- 378 cde_dt
343 /usr/dt/bin/dtksh 0555 cde1/dtksh/dtksh file bin bin di---- 378 cde_dt
344 /usr/dt/bin/suid_exec 0555 cde1/dtksh/ksh93/bin/suid_exec file root bin di---- 378 cde_dt
345 /usr/dt/app-defaults/C/Dtksh 0444 cde1/dtksh/Dtksh file bin bin di---- 378 cde_dt
346 /usr/dt/config/dtspcdenv 0444 cde1/dtspcd/dtspcdenv file bin bin di---- 378 cde_dt
347 /usr/dt/bin/dtexec 0555 cde1/dtexec/dtexec file bin bin di---- 378 cde_dt
348         EOF
349 }
350
351 ShowSize()
352 {
353     typeset -i total;
354     let total=0
355
356     echo "Size\t\tfilename"
357     echo "-----------------------------------------"
358
359     while read SRC
360     do
361       if [ "$SRC" != "" ]
362       then
363         set -A tokens $SRC
364         if [ "${tokens[3]}" = "file" ]
365         then
366           if [ -f ${tokens[0]} ]
367           then
368             filesize=`ls -l ${tokens[0]} | awk '{print $5}'`
369             echo "$filesize\t\t\c"
370             echo "${tokens[0]}"
371             let total=total+filesize
372           fi
373         fi
374       fi
375     done <<-EOF
376 /usr/dt/copyright 0444 copyright file bin bin di---- 378 cde_dt
377 /usr/dt/lib/dtksh/DtFuncs.dtsh 0444 cde1/dtksh/DtFuncs.sh file bin bin di---- 378 cde_dt
378 /usr/dt/bin/dtspcd 0555 cde1/dtspcd/dtspcd file bin bin di---- 378 cde_dt
379 /usr/dt/bin/dtappintegrate 0555 cde1/dtappintegrate/dtappintegrate file bin bin di---- 378 cde_dt
380 /usr/dt/bin/dtksh 0555 cde1/dtksh/dtksh file bin bin di---- 378 cde_dt
381 /usr/dt/bin/suid_exec 0555 cde1/dtksh/ksh93/bin/suid_exec file root bin di---- 378 cde_dt
382 /usr/dt/app-defaults/C/Dtksh 0444 cde1/dtksh/Dtksh file bin bin di---- 378 cde_dt
383 /usr/dt/config/dtspcdenv 0444 cde1/dtspcd/dtspcdenv file bin bin di---- 378 cde_dt
384 /usr/dt/bin/dtexec 0555 cde1/dtexec/dtexec file bin bin di---- 378 cde_dt
385         EOF
386     echo "Total fileset size is $total"
387 }
388 HandleOption()
389 {
390   while [ $# -ne 0 ]; do
391     case $1 in
392         -e) OPERATION="configure"
393             shift;
394             ;;
395         -d) OPERATION="deconfigure"
396             shift;
397             ;;
398         -v) OPERATION="verify"
399             shift;
400             ;;
401         -s) OPERATION="size"
402             shift;
403             ;;
404     esac
405   done
406 }
407
408 #####################################################################
409 #
410 # Main body
411 #
412 #####################################################################
413
414
415   HandleOption $*
416
417   if [ "$OPERATION" = "configure" ]
418   then
419     echo "Configuring for CDE-MIN"
420
421     FixEtcServices
422
423 #
424 # source in /etc/src.sh to get the DTMOUNTPOINT value
425 #
426
427     . /etc/src.sh
428
429     FixInetdDotConf
430
431     FixInetdDotSec
432
433 #
434 # force inetd to reread its configuration file
435 #
436
437     /etc/inetd -c
438
439 #
440 #  create the /var/dt/tmp directory for the dtspcd
441 #
442
443     CreateVarDtDirectory
444
445     if [ ! -d /var/dt/tmp ]
446     then
447         mkdir -p /var/dt/tmp
448         chmod -R 755 /var/dt/tmp
449     fi
450
451     chmod 755 /usr/dt /etc/dt
452
453   elif [ "$OPERATION" = "deconfigure" ]
454   then
455     echo "de-Configuring CDE-MIN"
456
457     UnfixEtcServices
458
459     UnfixInetdDotConf
460
461     UnfixInetdDotSec
462
463 #
464 # force inetd to reread its configuration file
465 #
466
467     /etc/inetd -c
468
469     RemoveMinFiles
470
471     VerifyInstalledFiles
472
473   elif [ "$OPERATION" = "verify" ]
474   then
475
476     VerifyInstalledFiles
477
478   elif [ "$OPERATION" = "size" ]
479   then
480
481     ShowSize
482
483   fi
484
485   return $retval