configTT.src 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. XCOMM! /bin/ksh
  2. XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
  3. XCOMM @(#) $XConsortium: configTT.src /main/5 1996/04/23 10:36:05 drk $
  4. XCOMM AIX cpp does not honor the usual requirement that preprocessor
  5. XCOMM directives must begin in column one, so we must do more quoting.
  6. #define HASH #
  7. INETD=/etc/inetd.conf
  8. CheckForttinInetd()
  9. {
  10. #ifdef _POWER
  11. grep "ttdbserverd" $INETD > /dev/null 2>&1 && sed "/ttdbserverd/d" $INETD > /tmp/configTT.$$ && mv /tmp/configTT.$$ $INETD
  12. rc=`grep "ttdbserver" $INETD | cut -c1 | grep -xv "#" \
  13. 1>/dev/null 2>/dev/null;echo $?`
  14. #else
  15. rc=`inetserv -s -I -v ttdbserver -p tcp 1>/dev/null 2>/dev/null;echo $?`
  16. #endif
  17. return $rc
  18. }
  19. XCOMM
  20. XCOMM Checks if portmap daemon is already running; if not
  21. XCOMM starts the portmap daemon.
  22. XCOMM
  23. CheckPortmap()
  24. {
  25. ps -ef | fgrep portmap | grep -v grep 2>/dev/null 1>/dev/null
  26. if [ $? -ne 0 ]
  27. then
  28. startsrc -s portmap
  29. fi
  30. }
  31. StopDaemon()
  32. {
  33. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  34. if [ -s /tmp/tmppsout ]
  35. then
  36. awk '{print "kill " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
  37. sleep 2
  38. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  39. if [ -s /tmp/tmppsout ]
  40. then
  41. awk '{print "kill -TERM " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
  42. sleep 2
  43. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  44. if [ -s /tmp/tmppsout ]
  45. then
  46. awk '{print "kill -9 " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
  47. sleep 2
  48. fi
  49. fi
  50. fi
  51. rm -f /tmp/tmppsout
  52. }
  53. FixEtcRpc()
  54. {
  55. XCOMM
  56. XCOMM now check to see if the proper entry is in /etc/rpc
  57. XCOMM
  58. RPCFILE=/etc/rpc
  59. TMPFILE=/tmp/etc-rpc
  60. if [ ! -f $RPCFILE ]
  61. then
  62. HASH if the file doesn't exist (highly unlikely), make one
  63. HASH with the proper entry
  64. HASH
  65. echo "ttdbserver 100083 tooltalk" >$RPCFILE
  66. else
  67. HASH
  68. HASH check to see if the entry is already there
  69. HASH
  70. grep "ttdbserverd" $RPCFILE > /dev/null 2>&1 && sed "/ttdbserverd/d" $RPCFILE > /tmp/configTTrpc.$$ && mv /tmp/configTTrpc.$$ $RPCFILE
  71. awk '{if ($1 == "ttdbserver" && $2 == "100083")
  72. print $0 > "/tmp/etc-rpc-already-there"
  73. }' $RPCFILE >/dev/null
  74. if [ ! -f /tmp/etc-rpc-already-there ]
  75. then
  76. HASH
  77. HASH if it isn't, check to see if either term already
  78. HASH exists. If either one does they need to be commented
  79. HASH out.
  80. awk '{if (($1 == "ttdbserver" && $2 != "100083") ||
  81. ($2 == "100083" && $1 != "ttdbserver"))
  82. print "#cde " $0;
  83. else
  84. print $0
  85. }' $RPCFILE >$TMPFILE
  86. echo "ttdbserver 100083 tooltalk" >>$TMPFILE
  87. mv $TMPFILE $RPCFILE
  88. else
  89. rm /tmp/etc-rpc-already-there
  90. fi
  91. fi
  92. }
  93. UnfixEtcRpc()
  94. {
  95. FILE="/etc/rpc"
  96. TMPFILE="/tmp/etc-rpc"
  97. awk '{if ($1 == "ttdbserver" && $2 == "100083")
  98. ;
  99. else if ($1 == "ttdbserverd" && $2 == "100083")
  100. ;
  101. else
  102. print $0
  103. }' $FILE >$TMPFILE
  104. mv $TMPFILE $FILE
  105. awk '{if ($1 == "#cde") {
  106. $1 = $2
  107. $2 = ""
  108. }
  109. print $0
  110. }' $FILE >$TMPFILE
  111. mv $TMPFILE $FILE
  112. }
  113. RemovettFromInetserv()
  114. {
  115. TTDB=CDE_INSTALLATION_TOP/bin/rpc.ttdbserver
  116. #ifdef _POWER
  117. /usr/sbin/chsubserver -d -v ttdbserver -t sunrpc_tcp -p tcp -w wait -u root \
  118. -g $TTDB -r inetd rpc.ttdbserver 100083 1 \
  119. 1>/dev/null 2>/dev/null
  120. grep -v "#ttdbserver" $INETD >/tmp/configTT.$$ && cp /tmp/configTT.$$ $INETD
  121. #else
  122. inetserv -D -I -v ttdbserver -p tcp 2>/dev/null 1>/dev/null
  123. #endif
  124. if [ "$?" -ne "0" ]
  125. then
  126. exit 1
  127. fi
  128. }
  129. AddttToInetserv()
  130. {
  131. INETD=/etc/inetd.conf
  132. TTDB=CDE_INSTALLATION_TOP/bin/rpc.ttdbserver
  133. XCOMM
  134. XCOMM check for existence of /etc/inetd.conf
  135. XCOMM
  136. if [ ! -f $INETD ] # highly unlikely
  137. then
  138. echo "" >$INETD
  139. fi
  140. #ifdef _POWER
  141. /usr/sbin/chsubserver -a -v ttdbserver -t sunrpc_tcp -p tcp -w wait -u root \
  142. -g $TTDB -r inetd rpc.ttdbserver 100083 1 \
  143. 1>/dev/null 2>/dev/null
  144. if [ "$?" -ne "0" ]
  145. then
  146. exit 1
  147. fi
  148. #else
  149. XCOMM
  150. XCOMM Check if the server exists in the /etc/inetd.conf file.
  151. XCOMM
  152. rc=`inetserv -s -I -v ttdbserver -p tcp 1>/dev/null 2>/dev/null;echo $?`
  153. if [ "$rc" -ne "0" ]
  154. then
  155. inetserv -a -S -v ttdbserver -p tcp -n 111
  156. rc=$?
  157. if [ "$rc" -eq "0" ]
  158. then
  159. inetserv -a -I -v ttdbserver -p tcp -t sunrpc_tcp -w wait -U root \
  160. -r $TTDB -R "rpc.ttdbserver 100083 1"
  161. if [ "$?" = "1" ]
  162. then
  163. exit 1
  164. fi
  165. else
  166. echo "Cannot add entries to inetd.conf..."
  167. exit 1
  168. fi
  169. fi
  170. #endif
  171. }
  172. HandleOption()
  173. {
  174. while [ $# -ne 0 ]; do
  175. case $1 in
  176. -e) DO_CONFIGURATION="yes"
  177. shift;
  178. ;;
  179. -d) DO_CONFIGURATION="no"
  180. shift;
  181. ;;
  182. esac
  183. done
  184. }
  185. XCOMM ##################################################################
  186. XCOMM
  187. XCOMM Main Body
  188. XCOMM
  189. XCOMM ##################################################################
  190. DO_CONFIGURATION=""
  191. PRODUCT=CDE
  192. FILESET=CDE-TT
  193. retval=0
  194. #ifndef _POWER
  195. StopDaemon "rpc.ttdbserver"
  196. #endif
  197. HandleOption $*
  198. if [ "$DO_CONFIGURATION" = "yes" ]
  199. then
  200. FixEtcRpc
  201. #ifndef _POWER
  202. CheckPortmap
  203. #endif
  204. CheckForttinInetd
  205. rc=$?
  206. if [ "$rc" = "0" ]
  207. then
  208. RemovettFromInetserv
  209. fi
  210. AddttToInetserv
  211. elif [ "$DO_CONFIGURATION" = "no" ]
  212. then
  213. UnfixEtcRpc
  214. #ifndef _POWER
  215. CheckPortmap
  216. #endif
  217. CheckForttinInetd
  218. rc=$?
  219. if [ "$rc" = "0" ]
  220. then
  221. RemovettFromInetserv
  222. else
  223. echo "\nToolTalk is already disabled..\n"
  224. exit 0
  225. fi
  226. fi
  227. #ifndef _POWER
  228. if [ "$DO_CONFIGURATION" != "" ]
  229. then
  230. XCOMM After adding ToolTalk to the inetd service list the inet
  231. XCOMM daemon needs to reread its configuration.
  232. inetimp
  233. refresh -s inetd
  234. fi
  235. #endif