dtinfo other files
[oweals/cde.git] / cde / admin / IntegTools / post_install / dec / configTT.src
1 XCOMM! /bin/ksh
2 XCOMM #######
3 XCOMM  Product: CDE
4 XCOMM  Fileset: CDE-TT
5 XCOMM  configure
6 XCOMM  @(#) $XConsortium: configTT.src /main/3 1996/04/23 20:38:20 drk $
7 XCOMM #######
8 XCOMM
9 XCOMM (c) Copyright Hewlett-Packard Company, 1993
10 XCOMM
11 XCOMM #######
12 #define HASH #
13
14 PRODUCT=CDE
15 FILESET=CDE-TT
16 DO_CONFIGURATION=""
17 retval=0
18
19 FixInetdDotConf()
20 {
21 FILE=/etc/inetd.conf
22 TMPFILE=/tmp/inetd.conf
23 TTDBSERVERD=CDE_INSTALLATION_TOP/bin/rpc.ttdbserver
24 OLDTTDBSERVERD=CDE_INSTALLATION_TOP/bin/rpc.ttdbserverd
25
26 XCOMM
27 XCOMM Desired entry:
28 XCOMM ttdbserver stream rpc/tcp wait root /usr/dt/bin/rpc.ttdbserver rpc.ttdbserver
29 XCOMM
30
31 XCOMM
32 XCOMM see if it already exists
33 XCOMM
34
35     nawk -v ttdb=$TTDBSERVERD -v oldttdb=$OLDTTDBSERVERD \
36         '{if (($1 == "ttdbserver" && $6 != ttdb) ||
37               ($1 == "ttdbserverd" && $6 == oldttdb))
38                 print "#cde " $0;
39           else
40                 print $0
41          }' $FILE >$TMPFILE
42
43     cp $TMPFILE $FILE
44     rm $TMPFILE
45
46     awk '{if ($1 == "ttdbserver")
47                 print $0 > "/tmp/tt-already-there"
48          }' $FILE >/dev/null
49
50     if [ ! -f /tmp/tt-already-there ]
51     then
52         echo "ttdbserver stream rpc/tcp wait root $TTDBSERVERD rpc.ttdbserver" >>$FILE
53     else
54         rm /tmp/tt-already-there
55     fi
56 }
57
58 UnfixInetdDotConf()
59 {
60 FILE=/etc/inetd.conf
61 TMPFILE=/tmp/inetd.conf
62 TTDBSERVERD=CDE_INSTALLATION_TOP/bin/rpc.ttdbserver
63 OLDTTDBSERVERD=CDE_INSTALLATION_TOP/bin/rpc.ttdbserverd
64
65     nawk -v ttdb=$TTDBSERVERD \
66         '{if ($1 == "ttdbserver" && $6 == ttdb)
67                 ;
68           else
69                 print $0
70          }' $FILE >$TMPFILE
71
72     cp $TMPFILE $FILE
73     rm $TMPFILE
74
75     awk '{if ($1 == "#cde" &&
76              ($2 == "ttdbserver" || $2 == "ttdbserverd")) {
77                 $1 = $2;
78                 $2 = ""
79              }
80              print $0
81          }' $FILE >$TMPFILE
82
83     cp $TMPFILE $FILE
84     rm $TMPFILE
85 }
86
87 FixEtcRpc()
88 {
89 FILE=/etc/rpc
90 TMPFILE=/tmp/etc-rpc
91
92     if [ ! -f $FILE ]
93     then
94         echo "ttdbserver     100083  tooltalk" >$FILE
95     else
96         awk '{if ($1 == "ttdbserver" && $2 == "100083")
97                 print $0 > "/tmp/etc-rpc-already-there"
98              }' $FILE >/dev/null
99
100         if [ ! -f /tmp/etc-rpc-already-there ]
101         then
102             awk '{if ($1 == "ttdbserver" || $2 == "100083")
103                         print $0 > "/tmp/etc-rpc-already-there"
104                  }' $FILE >/dev/null
105
106             if [ ! -f /tmp/etc-rpc-already-there ]
107             then
108                 echo "ttdbserver     100083  tooltalk" >>$FILE
109             else
110                 awk '{if ($1 == "ttdbserver" || $2 == "100083")
111                         print "#cde " $0; else print $0
112                      }' $FILE >$TMPFILE
113
114                 echo "ttdbserver     100083  tooltalk" >>$TMPFILE
115
116                 mv $TMPFILE $FILE
117                 rm /tmp/etc-rpc-already-there
118             fi
119         else
120             rm /tmp/etc-rpc-already-there
121         fi
122     fi
123 }
124
125 UnfixEtcRpc()
126 {
127 FILE="/etc/rpc"
128 TMPFILE="/tmp/etc-rpc"
129
130     awk '{if ($1 == "ttdbserver" && $2 == "100083")
131                 ;
132           else
133                 print $0
134          }' $FILE >$TMPFILE
135
136     mv $TMPFILE $FILE
137
138     awk '{if ($1 == "#cde") {
139                 $1 = $2;
140                 $2 = ""
141              }
142           print $0
143          }' $FILE >$TMPFILE
144
145     mv $TMPFILE $FILE
146 }
147
148 RemoveTTFiles()
149 {
150     while read SRC
151     do
152       if [ "$SRC" != "" ]
153       then
154         rm -f $SRC
155         dirname=${SRC%/STAR}
156         if [ -d $dirname ]
157         then
158           cd $dirname
159           while [ "$dirname" != "$CDE_TOP" ]
160           do
161             cd ..
162             rmdir ${dirname##STAR/} >/dev/null 2>/dev/null
163             dirname=${dirname%/STAR}
164           done
165         fi
166       fi
167     done <<-EOF
168 #include "CDE-TT.list"
169         EOF
170 }
171
172 VerifyInstalledFiles()
173 {
174     echo "Status   mode    owner   group   filename"
175     echo "-----------------------------------------"
176 XCOMM     exists  correct correct correct  /usr/dt/foo1
177 XCOMM     MISSING  WRONG   WRONG   WRONG   /usr/dt/foo2
178 XCOMM        exists    the link is correct    /usr/dt/link
179
180     while read SRC
181     do
182 #include "../verify.func"
183     done <<-EOF
184 #include "CDE-TT.lst"
185         EOF
186 }
187
188 #include "../option.func"
189
190 XCOMM ######################################################################
191 XCOMM
192 XCOMM                           Main Body
193 XCOMM
194 XCOMM ######################################################################
195
196   HandleOption $*
197
198   if [ "$OPERATION" = "configure" ]
199   then
200
201     FixInetdDotConf
202
203     FixEtcRpc
204
205   elif [ "$OPERATION" = "deconfigure" ]
206   then
207
208     UnfixEtcRpc
209
210     UnfixInetdDotConf
211
212     RemoveTTFiles
213
214     VerifyInstalledFiles
215
216   elif [ "$OPERATION" = "verify" ]
217   then
218
219     VerifyInstalledFiles
220
221   fi
222
223   if [ "$OPERATION" != "verify" ]
224   then
225
226     HASH issue a SIGHUP to the inetd process
227
228     ps -ef | grep inetd | grep -v grep >/tmp/tmppsout
229     if [ -s /tmp/tmppsout ]
230     then
231         awk '{print "kill -1 " $2}' /tmp/tmppsout | /bin/csh
232     else
233         /usr/sbin/inetd -s
234     fi
235
236     rm /tmp/tmppsout
237   fi
238
239   return $retval