configTT 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. #! /bin/ksh
  2. ########
  3. # Product: CDE
  4. # Fileset: CDE-TT
  5. # configure
  6. # @(#) $XConsortium: configTT /main/2 1996/03/06 19:09:08 barstow $
  7. ########
  8. #
  9. # (c) Copyright Hewlett-Packard Company, 1993
  10. #
  11. ########
  12. FixInetdDotConf()
  13. {
  14. FILE=/etc/inetd.conf
  15. TMPFILE=/tmp/inetd.conf
  16. TTDBSERVERD=/usr/dt/bin/rpc.ttdbserver
  17. OLDTTDBSERVERD=/usr/dt/bin/rpc.ttdbserverd
  18. awk -v ttdb=$TTDBSERVERD -v oldttdb=$OLDTTDBSERVERD '{
  19. if ($6 == ttdb || $6 == oldttdb)
  20. ;
  21. else
  22. print $0
  23. }' $FILE >$TMPFILE
  24. mv $FILE $FILE.old
  25. mv $TMPFILE $FILE
  26. echo "rpc stream tcp swait root $TTDBSERVERD 100083 1 $TTDBSERVERD -m /nfs/" >>$FILE
  27. }
  28. UnfixInetdDotConf()
  29. {
  30. FILE="/etc/inetd.conf"
  31. TMPFILE="/tmp/inetd.conf"
  32. TTDBSERVERD=/usr/dt/bin/rpc.ttdbserver
  33. awk -v ttdb=$TTDBSERVERD \
  34. '{if ($7 == "100083" && $6 == ttdb)
  35. ;
  36. else
  37. print $0
  38. }' $FILE >$TMPFILE
  39. mv $TMPFILE $FILE
  40. awk '{if ($1 == "#cde") {
  41. $1 = $2;
  42. $2 = ""
  43. }
  44. print $0
  45. }' $FILE >$TMPFILE
  46. mv $TMPFILE $FILE
  47. }
  48. FixEtcRpc()
  49. {
  50. FILE=/etc/rpc
  51. TMPFILE=/tmp/etc-rpc
  52. if [ ! -f $FILE ]
  53. then
  54. echo "ttdbserver 100083" >$FILE
  55. else
  56. awk '{if ($1 == "ttdbserver" && $2 == "100083")
  57. print $0 > "/tmp/etc-rpc-already-there"
  58. }' $FILE >/dev/null
  59. if [ ! -f /tmp/etc-rpc-already-there ]
  60. then
  61. awk '{if ($1 == "ttdbserver" || $2 == "100083")
  62. print $0 > "/tmp/etc-rpc-already-there"
  63. }' $FILE >/dev/null
  64. if [ ! -f /tmp/etc-rpc-already-there ]
  65. then
  66. echo "ttdbserver 100083" >>$FILE
  67. else
  68. awk '{if ($1 == "ttdbserver" || $2 == "100083")
  69. print "#cde " $0; else print $0
  70. }' $FILE >$TMPFILE
  71. echo "ttdbserver 100083" >>$TMPFILE
  72. mv $TMPFILE $FILE
  73. rm /tmp/etc-rpc-already-there
  74. fi
  75. else
  76. rm /tmp/etc-rpc-already-there
  77. fi
  78. fi
  79. }
  80. UnfixEtcRpc()
  81. {
  82. FILE="/etc/rpc"
  83. TMPFILE="/tmp/etc-rpc"
  84. awk '{if ($1 == "ttdbserver" && $2 == "100083")
  85. ;
  86. else
  87. print $0
  88. }' $FILE >$TMPFILE
  89. mv $TMPFILE $FILE
  90. awk '{if ($1 == "#cde") {
  91. $1 = $2;
  92. $2 = ""
  93. }
  94. print $0
  95. }' $FILE >$TMPFILE
  96. mv $TMPFILE $FILE
  97. }
  98. EstablishDtMountPoint()
  99. {
  100. FILE="/etc/src.sh"
  101. TMPFILE="/tmp/etcsrcsh.$$"
  102. #
  103. # Ensure that the DTMOUNTPOINT environment variable will be set
  104. # when anybody logs in.
  105. #
  106. if [[ -d /nfs && ! -d /net ]]
  107. then
  108. sed '/DTMOUNTPOINT=/d' $FILE >$TMPFILE
  109. echo "DTMOUNTPOINT=/nfs/ ; export DTMOUNTPOINT" >>$TMPFILE
  110. if [ ! -f ${FILE}.pre-cde ]
  111. then
  112. mv $FILE ${FILE}.pre-cde
  113. fi
  114. mv $TMPFILE $FILE
  115. fi
  116. }
  117. DeestablishDtMountPoint()
  118. {
  119. FILE="/etc/src.sh"
  120. TMPFILE="/tmp/etc-src.sh"
  121. if [ -f ${FILE}.pre-cde ]
  122. then
  123. mv ${FILE}.pre-cde $FILE
  124. else
  125. sed '/DTMOUNTPOINT=/d' $FILE >$TMPFILE
  126. mv $TMPFILE $FILE
  127. fi
  128. }
  129. KillIt()
  130. {
  131. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  132. if [ -s /tmp/tmppsout ]
  133. then
  134. awk '{print "kill " $2}' /tmp/tmppsout | /bin/ksh
  135. sleep 2
  136. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  137. if [ -s /tmp/tmppsout ]
  138. then
  139. awk '{print "kill -TERM " $2}' /tmp/tmppsout | /bin/ksh
  140. sleep 2
  141. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  142. if [ -s /tmp/tmppsout ]
  143. then
  144. awk '{print "kill -9 " $2}' /tmp/tmppsout | /bin/ksh
  145. sleep 2
  146. fi
  147. fi
  148. fi
  149. rm /tmp/tmppsout
  150. }
  151. RemoveTTFiles()
  152. {
  153. while read SRC
  154. do
  155. if [ "$SRC" != "" ]
  156. then
  157. rm -f $SRC
  158. dirname=${SRC%/*}
  159. if [ -d $dirname ]
  160. then
  161. cd $dirname
  162. while [ "$dirname" != "$CDE_TOP" ]
  163. do
  164. cd ..
  165. rmdir ${dirname##*/} >/dev/null 2>/dev/null
  166. dirname=${dirname%/*}
  167. done
  168. fi
  169. fi
  170. done <<-EOF
  171. /usr/dt/bin/rpc.ttdbserver
  172. /usr/dt/bin/rpc.ttdbserverd
  173. /usr/dt/bin/rpc.ttdbserverd
  174. /usr/dt/bin/tt_type_comp
  175. /usr/dt/bin/ttcp
  176. /usr/dt/bin/ttdbck
  177. /usr/dt/bin/ttmv
  178. /usr/dt/bin/ttrm
  179. /usr/dt/bin/ttrmdir
  180. /usr/dt/bin/ttsession
  181. /usr/dt/bin/tttrace
  182. /usr/dt/bin/tttar
  183. /usr/dt/bin/ttsnoop
  184. /usr/dt/lib/libtt.a
  185. /usr/dt/appconfig/tttypes/types.xdr
  186. EOF
  187. }
  188. VerifyInstalledFiles()
  189. {
  190. echo "Status mode owner group filename"
  191. echo "-----------------------------------------"
  192. # exists correct correct correct /usr/dt/foo1
  193. # MISSING WRONG WRONG WRONG /usr/dt/foo2
  194. # exists the link is correct /usr/dt/link
  195. while read SRC
  196. do
  197. if [ "$SRC" != "" ]
  198. then
  199. set -A tokens $SRC
  200. if [ "${tokens[3]}" = "file" ]
  201. then
  202. if [ -f ${tokens[0]} ]
  203. then
  204. echo "exists \c"
  205. else
  206. echo "MISSING or REMOVED \c"
  207. echo "${tokens[0]}"
  208. continue
  209. fi
  210. elif [ "${tokens[3]}" = "sym_link" ]
  211. then
  212. if [ -L ${tokens[0]} ]
  213. then
  214. echo "exists \c"
  215. else
  216. echo "MISSING or REMOVED \c"
  217. echo "${tokens[0]}"
  218. continue
  219. fi
  220. fi
  221. if [ "${tokens[3]}" = "file" ]
  222. then
  223. touch /tmp/config-test
  224. chmod ${tokens[1]} /tmp/config-test
  225. tmpperms=`ls -l /tmp/config-test | awk '{print $1}'`
  226. realperms=`ls -l ${tokens[0]} | awk '{print $1}'`
  227. if [ "$tmpperms" = "$realperms" ]
  228. then
  229. echo "correct \c"
  230. else
  231. echo " WRONG \c"
  232. fi
  233. owner=`ls -l ${tokens[0]} | awk '{print $3}'`
  234. if [ "$owner" = "${tokens[4]}" ]
  235. then
  236. echo "correct \c"
  237. else
  238. echo " WRONG \c"
  239. fi
  240. group=`ls -l ${tokens[0]} | awk '{print $4}'`
  241. if [ "$group" = "${tokens[5]}" ]
  242. then
  243. echo "correct \c"
  244. else
  245. echo " WRONG \c"
  246. fi
  247. elif [ "${tokens[3]}" = "sym_link" ]
  248. then
  249. linkto=`ls -l ${tokens[0]} | awk '{print $11}'`
  250. if [ "${tokens[2]}" = "$linkto" ]
  251. then
  252. echo " the link is correct \c"
  253. else
  254. echo " the link is WRONG \c"
  255. fi
  256. fi
  257. echo "${tokens[0]}"
  258. fi
  259. done <<-EOF
  260. /usr/dt/bin/rpc.ttdbserver 0555 lib/tt/bin/ttdbserverd/rpc.ttdbserver file bin bin di---- 378 cde_dt
  261. /usr/dt/bin/tt_type_comp 0555 lib/tt/bin/tt_type_comp/tt_type_comp file bin bin di---- 378 cde_dt
  262. /usr/dt/bin/ttcp 0555 lib/tt/bin/shell/ttcp file bin bin di---- 378 cde_dt
  263. /usr/dt/bin/ttdbck 0555 lib/tt/bin/dbck/ttdbck file bin bin di---- 378 cde_dt
  264. /usr/dt/bin/ttmv 0555 lib/tt/bin/shell/ttmv file bin bin di---- 378 cde_dt
  265. /usr/dt/bin/ttrm 0555 lib/tt/bin/shell/ttrm file bin bin di---- 378 cde_dt
  266. /usr/dt/bin/ttrmdir 0444 /usr/dt/bin/ttrm sym_link bin bin di---- 378 cde_dt
  267. /usr/dt/bin/ttsession 0555 lib/tt/bin/ttsession/ttsession file bin bin di---- 378 cde_dt
  268. /usr/dt/bin/tttrace 0555 lib/tt/bin/tttrace/tttrace file bin bin di---- 378 cde_dt
  269. /usr/dt/bin/tttar 0555 lib/tt/bin/tttar/tttar file bin bin di---- 378 cde_dt
  270. /usr/dt/bin/ttsnoop 0555 lib/tt/bin/ttsnoop/gui/ttsnoop file bin bin di---- 378 cde_dt
  271. /usr/dt/appconfig/tttypes/types.xdr 0444 cde1/tttypes/types.xdr file bin bin di---- 378 cde_dt
  272. EOF
  273. }
  274. ShowSize()
  275. {
  276. typeset -i total;
  277. let total=0
  278. echo "Size\t\tfilename"
  279. echo "-----------------------------------------"
  280. while read SRC
  281. do
  282. if [ "$SRC" != "" ]
  283. then
  284. set -A tokens $SRC
  285. if [ "${tokens[3]}" = "file" ]
  286. then
  287. if [ -f ${tokens[0]} ]
  288. then
  289. filesize=`ls -l ${tokens[0]} | awk '{print $5}'`
  290. echo "$filesize\t\t\c"
  291. echo "${tokens[0]}"
  292. let total=total+filesize
  293. fi
  294. fi
  295. fi
  296. done <<-EOF
  297. /usr/dt/bin/rpc.ttdbserver 0555 lib/tt/bin/ttdbserverd/rpc.ttdbserver file bin bin di---- 378 cde_dt
  298. /usr/dt/bin/tt_type_comp 0555 lib/tt/bin/tt_type_comp/tt_type_comp file bin bin di---- 378 cde_dt
  299. /usr/dt/bin/ttcp 0555 lib/tt/bin/shell/ttcp file bin bin di---- 378 cde_dt
  300. /usr/dt/bin/ttdbck 0555 lib/tt/bin/dbck/ttdbck file bin bin di---- 378 cde_dt
  301. /usr/dt/bin/ttmv 0555 lib/tt/bin/shell/ttmv file bin bin di---- 378 cde_dt
  302. /usr/dt/bin/ttrm 0555 lib/tt/bin/shell/ttrm file bin bin di---- 378 cde_dt
  303. /usr/dt/bin/ttrmdir 0444 /usr/dt/bin/ttrm sym_link bin bin di---- 378 cde_dt
  304. /usr/dt/bin/ttsession 0555 lib/tt/bin/ttsession/ttsession file bin bin di---- 378 cde_dt
  305. /usr/dt/bin/tttrace 0555 lib/tt/bin/tttrace/tttrace file bin bin di---- 378 cde_dt
  306. /usr/dt/bin/tttar 0555 lib/tt/bin/tttar/tttar file bin bin di---- 378 cde_dt
  307. /usr/dt/bin/ttsnoop 0555 lib/tt/bin/ttsnoop/gui/ttsnoop file bin bin di---- 378 cde_dt
  308. /usr/dt/appconfig/tttypes/types.xdr 0444 cde1/tttypes/types.xdr file bin bin di---- 378 cde_dt
  309. EOF
  310. echo "Total fileset size is $total"
  311. }
  312. HandleOption()
  313. {
  314. while [ $# -ne 0 ]; do
  315. case $1 in
  316. -e) OPERATION="configure"
  317. shift;
  318. ;;
  319. -d) OPERATION="deconfigure"
  320. shift;
  321. ;;
  322. -v) OPERATION="verify"
  323. shift;
  324. ;;
  325. -s) OPERATION="size"
  326. shift;
  327. ;;
  328. esac
  329. done
  330. }
  331. #################################################################
  332. #
  333. # Main Body
  334. #
  335. #################################################################
  336. PRODUCT=CDE
  337. FILESET=CDE-TT
  338. retval=0
  339. HandleOption $*
  340. if [ "$OPERATION" = "configure" ]
  341. then
  342. echo "Configuring for CDE-TT"
  343. FixInetdDotConf
  344. FixEtcRpc
  345. # After adding ToolTalk to the inetd service list the inet
  346. # daemon needs to reread its configuration.
  347. /etc/inetd -c
  348. EstablishDtMountPoint
  349. elif [ "$OPERATION" = "deconfigure" ]
  350. then
  351. echo "de-Configuring CDE-TT"
  352. /etc/inetd -k
  353. KillIt "rpc.ttdbserver"
  354. /etc/inetd
  355. UnfixInetdDotConf
  356. UnfixEtcRpc
  357. # After adding ToolTalk to the inetd service list the inet
  358. # daemon needs to reread its configuration.
  359. /etc/inetd -c
  360. DeestablishDtMountPoint
  361. RemoveTTFiles
  362. VerifyInstalledFiles
  363. elif [ "$OPERATION" = "verify" ]
  364. then
  365. VerifyInstalledFiles
  366. elif [ "$OPERATION" = "size" ]
  367. then
  368. ShowSize
  369. fi
  370. return $retval