dtinfo other files
[oweals/cde.git] / cde / admin / IntegTools / post_install / ibm / configMin.src
1 XCOMM! /bin/ksh
2 XCOMM   (c) Copyright 1993, 1994 International Business Machines Corp.
3 XCOMM  @(#) $XConsortium: configMin.src /main/7 1996/04/23 10:35:44 drk $
4
5 XCOMM AIX cpp does not honor the usual requirement that preprocessor
6 XCOMM directives must begin in column one, so we must do more quoting.
7 #define HASH #
8
9 SERVICES=/etc/services
10 INETD=/etc/inetd.conf
11
12 AdddtspcToInetserv()
13 {
14 DTSPCD=CDE_INSTALLATION_TOP/bin/dtspcd
15
16
17 XCOMM
18 XCOMM check for existence of /etc/services
19 XCOMM
20
21     if [ ! -f $SERVICES ]       # highly unlikely
22     then
23         echo "" >$SERVICES
24     fi
25
26 XCOMM
27 XCOMM check for existence of /etc/inetd.conf
28 XCOMM
29
30     if [ ! -f $INETD ]          # highly unlikely
31     then
32         echo "" >$INETD
33     fi
34
35 #ifdef _POWER
36
37      /usr/sbin/chservices -a -v dtspc -p tcp -n 6112      1>/dev/null 2>/dev/null
38      if [ $? -ne 0 ]
39      then
40          exit 1
41      fi
42
43      /usr/sbin/chsubserver -a -v dtspc -t stream -p tcp -w nowait -u root \
44                 -g $DTSPCD -r inetd $DTSPCD         1>/dev/null 2>/dev/null
45      if [ $? -ne 0 ]
46      then
47          exit 1
48      fi
49
50 #else
51
52 XCOMM
53 XCOMM Check if the server exists in the /etc/services file.
54 XCOMM
55
56     rc=`inetserv -s -S -v dtspc -p tcp 1>/dev/null 2>/dev/null;echo $?`
57     
58     if [ "$rc" -ne "0" ]
59     then
60 XCOMM
61 XCOMM Add entry into /etc/services file
62 XCOMM
63          inetserv -a -S -v dtspc -p tcp -n 6112
64     fi
65
66
67 XCOMM
68 XCOMM Check if the server exists in the /etc/inetd.conf file.
69 XCOMM
70     rc=`inetserv -s -I -v dtspc -p tcp 1>/dev/null 2>/dev/null;echo $?`
71
72     if [ "$rc" -ne "0" ]
73     then
74          inetserv -a -I -v dtspc -p tcp -t stream -w nowait -U root \
75              -r $DTSPCD -R $DTSPCD 1>/dev/null 2>/dev/null
76     fi
77
78
79 XCOMM
80 XCOMM remove legacy entries like "dtspcd" if exist
81 XCOMM
82
83     rc=`inetserv -s -S -v dtspcd -p tcp 1>/dev/null 2>/dev/null;echo $?`
84
85     if [ "$rc" = "0" ]
86     then
87          inetserv -D -S -v dtspcd -p tcp
88     fi
89 #endif
90 }
91
92 CheckFordtspcService()
93 {
94
95 #ifdef _POWER
96     rc=`grep "dtspc" $SERVICES | cut -c1 | grep -xv "#" \
97            1>/dev/null 2>/dev/null;echo $?`
98 #else
99     rc=`inetserv -s -S -v dtspc -p tcp 1>/dev/null 2>/dev/null;echo $?`
100 #endif
101     return $rc
102 }
103
104 RemovedtspcFromInetserv()
105 {
106 DTSPCD=CDE_INSTALLATION_TOP/bin/dtspcd
107
108 #ifdef _POWER
109
110      /usr/sbin/chservices -d -v dtspc -p tcp -n 6112          1>/dev/null   2>/dev/null
111      if [ $? -ne 0 ]
112      then
113          exit 1
114      fi
115
116      /usr/sbin/chsubserver -d -v dtspc -t stream -p tcp -w nowait -u root \
117                 -g $DTSPCD -r inetd $DTSPCD         1>/dev/null   2>/dev/null
118      if [ $? -ne 0 ]
119      then
120          exit 1
121      fi
122
123 #else
124 XCOMM
125 XCOMM Check if the server exists in the /etc/services file.
126 XCOMM
127
128     rc=`inetserv -s -S -v dtspc -p tcp 1>/dev/null 2>/dev/null;echo $?`
129
130     if [ "$rc" = "0" ]
131     then
132          inetserv -D -S -v dtspc -p tcp 2>/dev/null 1>/dev/null
133     fi
134
135 XCOMM
136 XCOMM remove legacy entries like "dtspcd" if exist
137 XCOMM
138
139     rc=`inetserv -s -S -v dtspcd -p tcp 1>/dev/null 2>/dev/null;echo $?`
140
141     if [ "$rc" = "0" ]
142     then
143          inetserv -D -S -v dtspcd -p tcp
144     fi
145 #endif
146
147 }
148
149 StopDaemon()
150 {
151     ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
152     if [ -s /tmp/tmppsout ]
153     then
154         awk '{print "kill " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
155         sleep 2
156         ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
157         if [ -s /tmp/tmppsout ]
158         then
159             awk '{print "kill -TERM " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
160             sleep 2
161             ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
162             if [ -s /tmp/tmppsout ]
163             then
164                 awk '{print "kill -9 " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
165                 sleep 2
166             fi
167         fi
168     fi
169     rm -f /tmp/tmppsout
170 }
171
172
173
174 HandleOption()
175 {
176   while [ $# -ne 0 ]; do
177     case $1 in
178         -e) DO_CONFIGURATION="yes"
179             shift;
180             ;;
181         -d) DO_CONFIGURATION="no"
182             shift;
183             ;;
184     esac
185   done
186 }
187
188 XCOMM #################################################################
189 XCOMM
190 XCOMM Main body
191 XCOMM
192 XCOMM #################################################################
193
194 PRODUCT=CDE
195 FILESET=CDE-MIN
196 DO_CONFIGURATION=""
197 retval=0
198
199 #ifndef _POWER
200 XCOMM
201 XCOMM refresh the inetserv object class with the latest 
202 XCOMM entries from /etc/inetd.conf and /etc/services files
203 XCOMM
204
205   inetexp
206
207   StopDaemon "dtspcd"
208 #endif
209
210   HandleOption $*
211
212   if [ "$DO_CONFIGURATION" = "yes" ]
213   then
214
215 #ifndef _POWER
216 XCOMM
217 XCOMM  create the /var/dt/tmp directory for the dtspcd
218 XCOMM
219
220     if [ ! -d CDE_LOGFILES_TOP/tmp ]
221     then
222         mkdir -p CDE_LOGFILES_TOP/tmp
223     fi
224 #endif
225
226     CheckFordtspcService
227     rc=$?
228     if [ "$rc" -eq "0" ]
229     then
230         echo "\n dtspc is already enabled...\n"
231         exit 0
232     fi
233     AdddtspcToInetserv
234
235 #ifndef _POWER
236 XCOMM
237 XCOMM  update inetd
238 XCOMM
239
240     inetimp
241     refresh -s inetd
242 #endif
243
244   elif [ "$DO_CONFIGURATION" = "no" ]
245   then
246
247     CheckFordtspcService
248     rc=$?
249     if [ "$rc" = "0" ]
250     then
251         RemovedtspcFromInetserv
252     else
253         echo "\n dtspc is already disabled...\n"
254         exit 0
255     fi
256
257 #ifndef _POWER
258 XCOMM
259 XCOMM  update inetd
260 XCOMM
261     inetimp
262     refresh -s inetd
263 #endif
264
265   fi