configRun.src 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. XCOMM! /bin/ksh
  2. XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
  3. XCOMM @(#) $XConsortium: configRun.src /main/7 1996/10/18 16:25:57 drk $
  4. #define HASH #
  5. #define STAR *
  6. INETD=/etc/inetd.conf
  7. XCOMM
  8. XCOMM The "sm" object definitions for 410 are in /usr/lib/objrepos so
  9. XCOMM ODMDIR need to get set to the correct path name .
  10. XCOMM
  11. #ifdef _POWER
  12. ODMDIR=/usr/lib/objrepos
  13. #endif
  14. CreateAppConfigDirectory()
  15. {
  16. XCOMM
  17. XCOMM Create the APPCONFIG directory inside DT_CONFIG_TOP and create
  18. XCOMM all of its subdirectories
  19. XCOMM
  20. cd $DT_CONFIG_TOP
  21. if [ ! -d $APPCONFIG ]
  22. then
  23. mkdir $APPCONFIG
  24. fi
  25. cd $APPCONFIG
  26. for i in $APPCONFIG_DIRS
  27. do
  28. if [ ! -d $i ]
  29. then
  30. mkdir $i
  31. fi
  32. cd $i
  33. HASH
  34. HASH for each locale
  35. HASH
  36. for j in $DT_TOP/$APPCONFIG/$i/STAR
  37. do
  38. if [ ! -d `basename $j` ]
  39. then
  40. mkdir `basename $j`
  41. fi
  42. done
  43. cd ..
  44. done
  45. }
  46. CheckFor24cmsdinInetd()
  47. {
  48. #ifdef _POWER
  49. rc=`grep "cmsd" $INETD | grep "2-4" | cut -c1 | grep -xv "#" \
  50. 1>/dev/null 2>/dev/null; echo $?`
  51. #else
  52. rc=`inetserv -s -I -v cmsd -p udp | grep "2-4" 1>/dev/null 2>/dev/null;\
  53. echo $?`
  54. #endif
  55. return $rc
  56. }
  57. CheckForcmsdinInetd()
  58. {
  59. #ifdef _POWER
  60. rc=`grep "cmsd" $INETD | cut -c1 | grep -xv "#" \
  61. 1>/dev/null 2>/dev/null;echo $?`
  62. #else
  63. rc=`inetserv -s -I -v cmsd -p udp 1>/dev/null 2>/dev/null;echo $?`
  64. #endif
  65. return $rc
  66. }
  67. #ifndef _POWER
  68. DeleteSmitStanzas()
  69. {
  70. odmdelete -o sm_cmd_opt -q"id='sysuiinterface'" 1>/dev/null 2>/dev/null
  71. odmdelete -o sm_cmd_hdr -q"id='dtconfig'" 1>/dev/null 2>/dev/null
  72. odmdelete -o sm_menu_opt -q"next_id='dtconfig'" 1>/dev/null 2>/dev/null
  73. }
  74. #endif
  75. #ifndef _POWER
  76. AddSmitStanzas()
  77. {
  78. rc=`odmget -q"next_id='dtconfig'" sm_menu_opt | grep dtconfig 1>/dev/null 2>/dev/null;echo $?`
  79. if [ "$rc" -ne "0" ]
  80. then
  81. cat << odm_stanzas | odmadd
  82. sm_menu_opt:
  83. id_seq_num = "200"
  84. id = "system"
  85. next_id = "dtconfig"
  86. text = "Change System User Interface"
  87. text_msg_file = "dtsmit.cat"
  88. text_msg_set = 30
  89. text_msg_id = 1
  90. next_type = "d"
  91. alias = ""
  92. help_msg_id = ""
  93. help_msg_loc = ""
  94. help_msg_base = ""
  95. help_msg_book = ""
  96. sm_menu_opt:
  97. id_seq_num = "050"
  98. id = "controls"
  99. next_id = "dtconfig"
  100. text = "Change System User Interface"
  101. text_msg_file = "dtsmit.cat"
  102. text_msg_set = 30
  103. text_msg_id = 1
  104. next_type = "d"
  105. alias = ""
  106. help_msg_id = ""
  107. help_msg_loc = ""
  108. help_msg_base = ""
  109. help_msg_book = ""
  110. odm_stanzas
  111. fi
  112. rc=`odmget -q"id='dtconfig'" sm_cmd_hdr | grep dtconfig 1>/dev/null 2>/dev/null;echo $?`
  113. if [ "$rc" -ne "0" ]
  114. then
  115. cat << odm_stanzas | odmadd
  116. sm_cmd_hdr:
  117. id = "dtconfig"
  118. option_id = "sysuiinterface"
  119. has_name_select = ""
  120. name = "Select System User Interface"
  121. name_msg_file = "dtsmit.cat"
  122. name_msg_set = 40
  123. name_msg_id = 1
  124. cmd_to_exec = "/usr/dt/bin/dtconfig "
  125. ask = ""
  126. exec_mode = ""
  127. ghost = ""
  128. cmd_to_discover = ""
  129. cmd_to_discover_postfix = ""
  130. name_size = 0
  131. value_size = 0
  132. help_msg_id = ""
  133. help_msg_loc = ""
  134. help_msg_base = ""
  135. help_msg_book = ""
  136. odm_stanzas
  137. fi
  138. rc=`odmget -q"id='sysuiinterface'" sm_cmd_opt | grep sysuiinterface 1>/dev/null 2>/dev/null;echo $?`
  139. if [ "$rc" -ne "0" ]
  140. then
  141. cat << odm_stanzas | odmadd
  142. sm_cmd_opt:
  143. id_seq_num = "020"
  144. id = "sysuiinterface"
  145. disc_field_name = ""
  146. name = "Select System Login User Interface"
  147. name_msg_file = "dtsmit.cat"
  148. name_msg_set = 50
  149. name_msg_id = 1
  150. op_type = "r"
  151. entry_type = ""
  152. entry_size = 0
  153. required = "y"
  154. prefix = ""
  155. cmd_to_list_mode = ""
  156. cmd_to_list = ""
  157. cmd_to_list_postfix = ""
  158. multi_select = ""
  159. value_index = 0
  160. disp_values = "CDE environment,Command line"
  161. values_msg_file = ""
  162. values_msg_set = 0
  163. values_msg_id = 0
  164. aix_values = "-e,-d"
  165. help_msg_id = ""
  166. help_msg_loc = ""
  167. help_msg_base = ""
  168. help_msg_book = ""
  169. odm_stanzas
  170. fi
  171. }
  172. #endif
  173. XCOMM
  174. XCOMM Checks if portmap daemon is already running; if not
  175. XCOMM starts the portmap daemon.
  176. XCOMM
  177. CheckPortmap()
  178. {
  179. ps -ef | fgrep portmap | grep -v grep 2>/dev/null 1>/dev/null
  180. if [ $? -ne 0 ]
  181. then
  182. startsrc -s portmap
  183. fi
  184. }
  185. StopDaemon()
  186. {
  187. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  188. if [ -s /tmp/tmppsout ]
  189. then
  190. awk '{print "kill " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
  191. sleep 2
  192. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  193. if [ -s /tmp/tmppsout ]
  194. then
  195. awk '{print "kill -TERM " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
  196. sleep 2
  197. ps -ef | fgrep $1 | grep -v grep >/tmp/tmppsout
  198. if [ -s /tmp/tmppsout ]
  199. then
  200. awk '{print "kill -9 " $2}' /tmp/tmppsout | /bin/ksh 1>/dev/null
  201. sleep 2
  202. fi
  203. fi
  204. fi
  205. rm -f /tmp/tmppsout
  206. }
  207. FixEtcRpc()
  208. {
  209. XCOMM
  210. XCOMM now check to see if the proper entry is in /etc/rpc
  211. XCOMM
  212. RPCFILE=/etc/rpc
  213. TMPFILE=/tmp/etc-rpc
  214. if [ ! -f $RPCFILE ]
  215. then
  216. HASH if the file doesn't exist (highly unlikely), make one
  217. HASH with the proper entry
  218. HASH
  219. echo "cmsd 100068 dtcalendar" >$RPCFILE
  220. else
  221. HASH
  222. HASH check to see if the entry is already there
  223. HASH
  224. awk '{if ($1 == "cmsd" && $2 == "100068")
  225. print $0 > "/tmp/etc-rpc-already-there"
  226. }' $RPCFILE >/dev/null
  227. if [ ! -f /tmp/etc-rpc-already-there ]
  228. then
  229. HASH
  230. HASH if it isn't, check to see if either term already
  231. HASH exists
  232. HASH
  233. awk '{if ($1 == "cmsd" || $2 == "100068")
  234. print $0 > "/tmp/etc-rpc-already-there"
  235. }' $RPCFILE >/dev/null
  236. HASH
  237. HASH if either one does they need to be commented out
  238. HASH
  239. if [ ! -f /tmp/etc-rpc-already-there ]
  240. then
  241. echo "cmsd 100068 dtcalendar" >>$RPCFILE
  242. else
  243. awk '{if ($1 == "cmsd" || $2 == "100068")
  244. print "#cde " $0;
  245. else
  246. print $0
  247. }' $RPCFILE >$TMPFILE
  248. echo "cmsd 100068 dtcalendar" >>/tmp/etc-rpc
  249. mv $TMPFILE $RPCFILE
  250. rm /tmp/etc-rpc-already-there
  251. fi
  252. else
  253. rm /tmp/etc-rpc-already-there
  254. fi
  255. fi
  256. }
  257. UnfixEtcRpc()
  258. {
  259. FILE=/etc/rpc
  260. TMPFILE=/tmp/etc-rpc
  261. awk '{if ($1 == "cmsd" && $2 == "100068")
  262. ;
  263. else
  264. print $0
  265. }' $FILE >$TMPFILE
  266. mv $TMPFILE $FILE
  267. awk '{if ($1 == "#cde" && ($2 == "cmsd" || $3 == "100068"))
  268. ;
  269. else
  270. print $0
  271. }' $FILE >$TMPFILE
  272. mv $TMPFILE $FILE
  273. }
  274. Remove24cmsdFromInetd()
  275. {
  276. CMSD=CDE_INSTALLATION_TOP/bin/rpc.cmsd
  277. #ifdef _POWER
  278. /usr/sbin/chsubserver -d -v cmsd -t sunrpc_udp -p udp -w wait -u root \
  279. -g $CMSD -r inetd cmsd 100068 2-4 1>/dev/null 2>/dev/null
  280. grep -v "#cmsd" $INETD >/tmp/configRun.$$ && mv /tmp/configRun.$$ $INETD
  281. #else
  282. inetserv -D -I -v cmsd -p udp 2>/dev/null 1>/dev/null
  283. #endif
  284. if [ "$?" -ne "0" ]
  285. then
  286. exit 1
  287. fi
  288. }
  289. RemovecmsdFromInetserv()
  290. {
  291. CMSD=CDE_INSTALLATION_TOP/bin/rpc.cmsd
  292. #ifdef _POWER
  293. /usr/sbin/chsubserver -d -v cmsd -t sunrpc_udp -p udp -w wait -u root \
  294. -g $CMSD -r inetd cmsd 100068 2-5 1>/dev/null 2>/dev/null
  295. grep -v "#cmsd" $INETD >/tmp/configRun.$$ && mv /tmp/configRun.$$ $INETD
  296. #else
  297. inetserv -D -I -v cmsd -p udp 2>/dev/null 1>/dev/null
  298. #endif
  299. if [ "$?" -ne "0" ]
  300. then
  301. exit 1
  302. fi
  303. }
  304. AddcmsdToInetserv()
  305. {
  306. CMSD=CDE_INSTALLATION_TOP/bin/rpc.cmsd
  307. XCOMM
  308. XCOMM check for existence of /etc/inetd.conf
  309. XCOMM
  310. if [ ! -f $INETD ] # highly unlikely
  311. then
  312. echo "" >$INETD
  313. fi
  314. #ifdef _POWER
  315. /usr/sbin/chsubserver -a -v cmsd -t sunrpc_udp -p udp -w wait -u root \
  316. -g $CMSD -r inetd cmsd 100068 2-5 1>/dev/null 2>/dev/null
  317. if [ "$?" -ne "0" ]
  318. then
  319. exit 1
  320. fi
  321. #else
  322. XCOMM
  323. XCOMM Check if the server exists in the /etc/inetd.conf file.
  324. XCOMM
  325. rc=`inetserv -s -I -v cmsd -p udp 1>/dev/null 2>/dev/null;echo $?`
  326. if [ "$rc" -ne "0" ]
  327. then
  328. inetserv -a -S -v cmsd -p udp -n 111
  329. rc=$?
  330. if [ "$rc" -eq "0" ]
  331. then
  332. inetserv -a -I -v cmsd -p udp -t sunrpc_udp -w wait -U root \
  333. -r $CMSD -R "cmsd 100068 2-5"
  334. if [ "$?" = "1" ]
  335. then
  336. exit 1
  337. fi
  338. fi
  339. fi
  340. #endif
  341. }
  342. HandleOption()
  343. {
  344. while [ $# -ne 0 ]; do
  345. case $1 in
  346. -e) DO_CONFIGURATION="yes"
  347. shift;
  348. ;;
  349. -d) DO_CONFIGURATION="no"
  350. shift;
  351. ;;
  352. esac
  353. done
  354. }
  355. LinkOtherIcons()
  356. {
  357. while read SRC
  358. do
  359. rm -f $DT_TOP/$APPCONFIG/icons/C/F$SRC
  360. ln -s $DT_TOP/$APPCONFIG/icons/C/$SRC $DT_TOP/$APPCONFIG/icons/C/F$SRC
  361. done <<-EOF
  362. fphelp.t.pm
  363. help.t.pm
  364. paint.l.pm
  365. paint.m.pm
  366. paint.t.pm
  367. penpad.t.pm
  368. term.t.pm
  369. EOF
  370. }
  371. ConfigurePrintersDir()
  372. {
  373. cd $DT_TOP/$APPCONFIG/appmanager
  374. XCOMM
  375. XCOMM for each locale
  376. XCOMM
  377. for i in *
  378. do
  379. if [ -d $i ]
  380. then
  381. cd $i
  382. HASH
  383. HASH for each directory in the locale, check for a
  384. HASH localized version of the Printers directory
  385. HASH and for the file lp_Print within that directory
  386. HASH
  387. for j in *
  388. do
  389. if [ -f $j/$DEFAULT_PRINTER ]
  390. then
  391. PRINTERS=$j
  392. HASH make the equivalent directory in the configuration
  393. HASH directory
  394. if [ ! -d $DT_CONFIG_TOP/$APPCONFIG/appmanager/$i ]
  395. then
  396. mkdir $DT_CONFIG_TOP/$APPCONFIG/appmanager/$i
  397. fi
  398. cd $DT_CONFIG_TOP/$APPCONFIG/appmanager/$i
  399. if [ ! -d $DT_CONFIG_TOP/$APPCONFIG/appmanager/$i/$PRINTERS ]
  400. then
  401. mkdir $DT_CONFIG_TOP/$APPCONFIG/appmanager/$i/$PRINTERS
  402. fi
  403. cd $DT_CONFIG_TOP/$APPCONFIG/appmanager/$i/$PRINTERS
  404. HASH now copy the file over from the installation dirctory
  405. HASH if it is not already present.
  406. if [ ! -f $DEFAULT_PRINTER ]
  407. then
  408. cp $DT_TOP/$APPCONFIG/appmanager/$i/$PRINTERS/$DEFAULT_PRINTER .
  409. fi
  410. cd $DT_TOP/$APPCONFIG/appmanager/$i
  411. fi
  412. done
  413. cd $DT_TOP/$APPCONFIG/appmanager
  414. fi
  415. done
  416. }
  417. XCOMM ##########################################################################
  418. XCOMM
  419. XCOMM Main Body
  420. XCOMM
  421. XCOMM ##########################################################################
  422. PRODUCT=CDE
  423. FILESET=CDE-RUN
  424. retval=0
  425. DT_TOP=/usr/dt
  426. DT_CONFIG_TOP=/etc/dt
  427. DT_TEMP_TOP=/var/dt
  428. DO_CONFIGURATION=""
  429. ROOT=/
  430. retval=0
  431. APPCONFIG=appconfig
  432. APPCONFIG_DIRS="appmanager help icons types"
  433. PRINTERS=""
  434. DEFAULT_PRINTER="DtPrint"
  435. #ifndef _POWER
  436. StopDaemon "rpc.cmsd"
  437. #endif
  438. HandleOption $*
  439. if [ "$DO_CONFIGURATION" = "yes" ]
  440. then
  441. XCOMM
  442. XCOMM create the /var/dt directory
  443. XCOMM
  444. if [ ! -d $DT_TEMP_TOP/$APPCONFIG/appmanager ]
  445. then
  446. mkdir -p $DT_TEMP_TOP/$APPCONFIG/appmanager
  447. fi
  448. cd $DT_TEMP_TOP
  449. mv $APPCONFIG/appmanager .hidden-appmanager
  450. chmod -R 755 * 2> /dev/null
  451. chmod 755 .hidden-appmanager 2> /dev/null
  452. chown -R bin * 2> /dev/null
  453. chgrp -R bin * 2> /dev/null
  454. mv .hidden-appmanager $APPCONFIG/appmanager
  455. chmod 755 . 2> /dev/null
  456. chown bin . 2> /dev/null
  457. chgrp bin . 2> /dev/null
  458. XCOMM
  459. XCOMM create the /etc/dt and its config directory
  460. XCOMM
  461. if [ ! -d $DT_CONFIG_TOP ]
  462. then
  463. mkdir -p $DT_CONFIG_TOP
  464. fi
  465. if [ ! -d $DT_CONFIG_TOP/config ]
  466. then
  467. mkdir -p $DT_CONFIG_TOP/config
  468. fi
  469. CreateAppConfigDirectory
  470. ConfigurePrintersDir
  471. env LANG=C /usr/dt/bin/dtprintinfo -populate
  472. XCOMM
  473. XCOMM Configure Xsession.d
  474. XCOMM
  475. cd $DT_CONFIG_TOP/config
  476. if [ ! -d Xsession.d ]
  477. then
  478. mkdir Xsession.d
  479. fi
  480. cd $DT_CONFIG_TOP
  481. chmod -R 755 *
  482. LinkOtherIcons
  483. #ifndef _POWER
  484. AddSmitStanzas
  485. #endif
  486. FixEtcRpc
  487. XCOMM After adding the Calendar Manager to the rpc service list the
  488. XCOMM portmapper needs to be restarted.
  489. #ifndef _POWER
  490. CheckPortmap
  491. #endif
  492. CheckFor24cmsdinInetd
  493. rc=$?
  494. if [ "$rc" = "0" ]
  495. then
  496. Remove24cmsdFromInetd
  497. #ifndef _POWER
  498. inetimp
  499. #endif
  500. refresh -s inetd
  501. fi
  502. CheckForcmsdinInetd
  503. rc=$?
  504. if [ "$rc" = "0" ]
  505. then
  506. RemovecmsdFromInetserv
  507. fi
  508. AddcmsdToInetserv
  509. #ifndef _POWER
  510. XCOMM After adding the Calendar Manager to the inetd service list, the inet
  511. XCOMM daemon needs to reread its configuration.
  512. inetimp
  513. refresh -s inetd
  514. #endif
  515. elif [ "$DO_CONFIGURATION" = "no" ]
  516. then
  517. #ifndef _POWER
  518. DeleteSmitStanzas
  519. #endif
  520. UnfixEtcRpc
  521. XCOMM After deleting the Calendar Manager to the rpc service list the
  522. XCOMM portmapper needs to be restarted.
  523. #ifndef _POWER
  524. CheckPortmap
  525. #endif
  526. CheckForcmsdinInetd
  527. rc=$?
  528. if [ "$rc" = "0" ]
  529. then
  530. RemovecmsdFromInetserv
  531. else
  532. echo "\ncmsd is already disabled..\n"
  533. exit 0
  534. fi
  535. #ifndef _POWER
  536. XCOMM After adding the Calendar Manager to the inetd service list, the inet
  537. XCOMM daemon needs to reread its configuration.
  538. inetimp
  539. refresh -s inetd
  540. #endif
  541. fi