dtinfo other files
[oweals/cde.git] / cde / admin / IntegTools / post_install / dec / configRun.src
1 XCOMM! /bin/ksh
2 XCOMM #######
3 XCOMM  Product: CDE
4 XCOMM  Fileset: CDE-RUN
5 XCOMM  configure
6 XCOMM  @(#) $XConsortium: configRun.src /main/4 1996/10/18 16:25:41 drk $
7 XCOMM #######
8
9 #define HASH #
10 #define STAR *
11
12 PRODUCT=CDE
13 FILESET=CDE-RUN
14 DO_CONFIGURATION=""
15 retval=0
16
17 FixInetdDotConf()
18 {
19 FILE=/etc/inetd.conf
20 TMPFILE=/tmp/inetd.conf
21 CMSD=CDE_INSTALLATION_TOP/bin/rpc.cmsd
22
23 XCOMM
24 XCOMM desired inetd.conf entry:
25 XCOMM cmsd/2-5 dgram rpc/udb wait root /usr/dt/bin/rpc.cmsd rpc.cmsd
26 XCOMM
27
28 XCOMM first make an awk script and put it in a file.
29 XCOMM
30
31 XCOMM comment out any non-cde cmsd lines
32 XCOMM
33
34     nawk -v cmsd=$CMSD \
35         '{if ($1 == "cmsd/2-4" && $6 != cmsd)
36                 print "#cde " $0;
37           else
38                 print $0
39          }' $FILE >$TMPFILE
40
41     cp $TMPFILE $FILE
42     rm $TMPFILE
43
44 XCOMM remove any cde 2-4 cmsd
45 XCOMM
46
47     nawk -v cmsd=$CMSD \
48         '{if ($1 == "cmsd/2-4" && $6 == cmsd)
49                 ;
50           else
51                 print $0
52          }' $FILE >$TMPFILE
53
54     cp $TMPFILE $FILE
55     rm $TMPFILE
56
57 XCOMM
58 XCOMM now run an awk script to see if there is an occurrence of 2-5 cmsd
59 XCOMM
60
61     nawk -v cmsd=$CMSD \
62         '{if ($6 == cmsd && $1 == "cmsd/2-5")
63                 print $0 > "/tmp/cmsd-already-there"
64          }' $FILE >/dev/null
65
66 XCOMM
67 XCOMM if it is not there, add it
68 XCOMM
69
70     if [ ! -f /tmp/cmsd-already-there ]
71     then
72         echo "cmsd/2-5 dgram rpc/udp wait root $CMSD rpc.cmsd" >>$FILE
73     else
74         rm /tmp/cmsd-already-there
75     fi
76
77 }
78
79 UnfixInetdDotConf()
80 {
81 FILE=/etc/inetd.conf
82 TMPFILE=/tmp/inetd.conf
83 CMSD=CDE_INSTALLATION_TOP/bin/rpc.cmsd
84
85     HASH first remove the CDE cmsd entry
86
87     nawk -v cmsd=$CMSD \
88         '{if (($1 == "cmsd/2-4" || $1 == "cmsd/2-5") && $6 == cmsd)
89                 ;
90           else
91                 print $0
92          }' $FILE >$TMPFILE
93
94     cp $TMPFILE $FILE
95     rm $TMPFILE
96
97     HASH now uncomment any previously existing 100068 entry
98
99     awk '{if ($1 == "#cde") {
100                 if ($2 == "cmsd/2-4") {
101                         $1 = $2;
102                         $2 = ""
103                 }
104           }
105           print $0
106          }' $FILE >$TMPFILE
107
108     cp $TMPFILE $FILE
109     rm $TMPFILE
110 }
111
112 FixEtcRpc()
113 {
114 XCOMM
115 XCOMM now check to see if the proper entry is in /etc/rpc
116 XCOMM
117
118     RPCFILE=/etc/rpc
119     TMPFILE=/tmp/etc-rpc
120
121     if [ ! -f $RPCFILE ]
122     then
123         HASH if the file doesn't exist (highly unlikely), make one
124         HASH with the proper entry
125         HASH
126
127         echo "cmsd     100068  dtcalendar" >$RPCFILE
128
129     else
130         HASH
131         HASH check to see if the entry is already there
132         HASH
133
134         awk '{if ($1 == "cmsd" && $2 == "100068")
135                 print $0 > "/tmp/etc-rpc-already-there"
136              }' $RPCFILE >/dev/null
137
138         if [ ! -f /tmp/etc-rpc-already-there ]
139         then
140             HASH
141             HASH if it isn't, check to see if either term already
142             HASH exists
143             HASH
144
145             awk '{if ($1 == "cmsd" || $2 == "100068")
146                         print $0 > "/tmp/etc-rpc-already-there"
147                  }' $RPCFILE >/dev/null
148
149             HASH
150             HASH if either one does they need to be commented out
151             HASH
152
153             if [ ! -f /tmp/etc-rpc-already-there ]
154             then
155                 echo "cmsd     100068  dtcalendar" >>$RPCFILE
156             else
157                 awk '{if ($1 == "cmsd" || $2 == "100068")
158                         print "#cde " $0;
159                       else 
160                         print $0
161                      }' $RPCFILE >$TMPFILE
162
163                 echo "cmsd     100068  dtcalendar" >>$TMPFILE
164                 mv $TMPFILE $RPCFILE
165                 rm /tmp/etc-rpc-already-there
166             fi
167         else
168             rm /tmp/etc-rpc-already-there
169         fi
170     fi
171
172 }
173
174 UnfixEtcRpc()
175 {
176 FILE="/etc/rpc"
177 TMPFILE="/tmp/etc-rpc"
178
179     awk '{if ($1 == "cmsd" && $2 == "100068")
180                 ;
181           else
182                 print $0
183          }' $FILE >$TMPFILE
184
185     mv $TMPFILE $FILE
186
187     awk '{if ($1 == "#cde" && ($2 == "cmsd" || $3 == "100068"))
188                 ;
189           else
190                 print $0
191          }' $FILE >$TMPFILE
192
193     mv $TMPFILE $FILE
194 }
195
196 FixXlogin()
197 {
198     if [ -L /sbin/rc3.d/S95xdm ]
199     then
200         /bin/cp -f CDE_INSTALLATION_TOP/bin/xlogin /sbin/init.d/xlogin
201         /bin/chown bin:bin /sbin/init.d/xlogin
202         /bin/chmod 750 /sbin/init.d/xlogin
203         /bin/ln -f -s ../init.d/xlogin /sbin/rc3.d/S95xdm
204     fi
205 }
206
207 UnfixXlogin()
208 {
209     if [ -L /sbin/rc3.d/S95xdm ]
210     then
211         /bin/ln -f -s ../init.d/xdm /sbin/rc3.d/S95xdm
212         if [ -e /sbin/init.d/xlogin ]
213         then
214             /bin/rm -f /sbin/init.d/xlogin
215         fi
216     fi
217 }
218
219 CreateAppConfigDirectory()
220 {
221   HASH
222   HASH Create the APPCONFIG directory inside DT_CONFIG_TOP and create
223   HASH all of its subdirectories
224   HASH
225
226     cd $DT_CONFIG_TOP
227     if [ ! -d $APPCONFIG ]
228     then
229         mkdir $APPCONFIG
230     fi
231
232     cd $APPCONFIG
233
234     for i in $APPCONFIG_DIRS
235     do
236         if [ ! -d $i ]
237         then
238             mkdir $i
239         fi
240         cd $i
241         HASH
242         HASH for each locale
243         HASH
244         for j in $DT_TOP/$APPCONFIG/$i/STAR
245         do
246             if [ ! -d `basename $j` ]
247             then
248                 mkdir `basename $j`
249             fi
250         done
251         cd ..
252     done
253
254 }
255
256 doDttermTerminfo()
257 {
258     if [ -f $DT_TOP/config/dtterm.ti ]
259     then
260         /bin/tic $DT_TOP/config/dtterm.ti
261         if [ -f /usr/share/lib/terminfo/d/dtterm ]
262         then
263             /bin/chown bin:bin /usr/share/lib/terminfo/d/dtterm
264             /bin/chmod 644 /usr/share/lib/terminfo/d/dtterm
265         else
266             echo "Unable to compile $DT_TOP/config/dtterm.ti"
267         fi
268     else
269         echo "Unable to find $DT_TOP/config/dtterm.ti"
270     fi
271 }
272
273 RemoveRunFiles()
274 {
275     while read SRC
276     do
277       if [ "$SRC" != "" ]
278       then
279         rm -f $SRC
280         dirname=${SRC%/STAR}
281         if [ -d $dirname ]
282         then
283           cd $dirname
284           while [ "$dirname" != "$CDE_TOP" ]
285           do
286             cd ..
287             rmdir ${dirname##STAR/} >/dev/null 2>/dev/null
288             dirname=${dirname%/STAR}
289           done
290         fi
291       fi
292     done <<-EOF
293 #include "CDE-RUN.list"
294         EOF
295 }
296
297
298 VerifyInstalledFiles()
299 {
300     echo "Status   mode    owner   group   filename"
301     echo "-----------------------------------------"
302 XCOMM     exists  correct correct correct  /usr/dt/foo1
303 XCOMM     MISSING  WRONG   WRONG   WRONG   /usr/dt/foo2
304 XCOMM        exists    the link is correct    /usr/dt/link
305
306     while read SRC
307     do
308 #include "../verify.func"
309     done <<-EOF
310 #include "CDE-RUN.lst"
311         EOF
312 }
313
314 #include "../option.func"
315
316 XCOMM ##########################################################################
317 XCOMM
318 XCOMM                           Main Body
319 XCOMM
320 XCOMM ##########################################################################
321
322 PRODUCT=CDE
323 FILESET=CDE-RUN
324
325 DT_TOP=CDE_INSTALLATION_TOP
326 DT_CONFIG_TOP=CDE_CONFIGURATION_TOP
327 DT_TEMP_TOP=CDE_LOGFILES_TOP
328 ROOT=/
329
330 retval=0
331
332 APPCONFIG=appconfig
333 APPCONFIG_DIRS="appmanager help icons types"
334 PRINTERS=""
335 DEFAULT_PRINTER="DtPrint"
336
337   HandleOption $*
338
339   if [ "$OPERATION" = "configure" ]
340   then
341
342     HASH
343     HASH create the CDE_LOGFILES_TOP directory
344     HASH
345
346     if [ ! -d $DT_TEMP_TOP/$APPCONFIG/appmanager ]
347     then
348         mkdir -p $DT_TEMP_TOP/$APPCONFIG/appmanager
349     fi
350
351     cd $DT_TEMP_TOP
352     mv $APPCONFIG/appmanager .hidden-appmanager
353     chmod -R 755 *
354     chmod 755 .hidden-appmanager
355     chown -R bin *
356     chgrp -R bin *
357     mv .hidden-appmanager $APPCONFIG/appmanager
358     chmod 755 .
359     chown bin .
360     chgrp bin .
361
362     HASH
363     HASH create the CDE_CONFIGURATION_TOP and its config directory
364     HASH
365     if [ ! -d $DT_CONFIG_TOP ]
366     then
367         mkdir -p $DT_CONFIG_TOP
368     fi
369     if [ ! -d $DT_CONFIG_TOP/config ]
370     then
371         mkdir -p $DT_CONFIG_TOP/config
372     fi
373
374     CreateAppConfigDirectory
375
376     HASH
377     HASH ConfigurePrintersDir
378     HASH
379     env LANG=C LD_LIBRARY_PATH=$DT_TOP/lib:/usr/shlib:/usr/lib $DT_TOP/bin/dtprintinfo -populate
380
381     HASH
382     HASH Configure Xsession.d
383     HASH
384
385     cd $DT_CONFIG_TOP/config
386     if [ ! -d Xsession.d ]
387     then
388         mkdir Xsession.d
389     fi
390
391     cd $DT_CONFIG_TOP
392     chmod -R 755 *
393
394     FixInetdDotConf
395
396     FixEtcRpc
397
398     FixXlogin
399
400     doDttermTerminfo
401
402   elif [ "$OPERATION" = "deconfigure" ]
403   then
404
405     UnfixXlogin
406
407     UnfixEtcRpc
408
409     UnfixInetdDotConf
410
411     rm -f /usr/share/lib/terminfo/d/dtterm
412
413     RemoveRunFiles
414
415     VerifyInstalledFiles
416
417   elif [ "$OPERATION" = "verify" ]
418   then
419
420     VerifyInstalledFiles
421
422   fi
423
424   if [ "$OPERATION" != "verify" ]
425   then
426
427     HASH issue a SIGHUP to the inetd process
428
429     ps -ef | grep inetd | grep -v grep >/tmp/tmppsout
430     if [ -s /tmp/tmppsout ]
431     then
432         awk '{print "kill -1 " $2}' /tmp/tmppsout | /bin/csh
433     else
434         /usr/sbin/inetd -s
435     fi
436   fi
437
438   return $retval