Advertisement
Guest User

rc.yp

a guest
Dec 9th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. #!/bin/sh
  2. # /etc/rc.d/rc.yp
  3. #
  4. # Start NIS (Network Information Service). NIS provides network-wide
  5. # distribution of hostname, username, and other information databases.
  6. # After configuring NIS, you will need to uncomment the parts of this
  7. # script that you want to run.
  8. #
  9. # NOTE: for detailed information about setting up NIS, see the
  10. # documentation in /usr/doc/yp-tools, /usr/doc/ypbind,
  11. # /usr/doc/ypserv, and /usr/doc/Linux-HOWTOs/NIS-HOWTO.
  12.  
  13. # Set non-zero to enable yp client functions
  14. YP_CLIENT_ENABLE=1
  15.  
  16. # Set non-zero to enable yp server functions
  17. YP_SERVER_ENABLE=0
  18.  
  19. # If YP_SERVER_ENABLE is set, a non-zero YP_XFRD_ENABLE setting will
  20. # enable ypxfrd.
  21. YP_XFRD_ENABLE=0
  22.  
  23. PID_PATH=/var/run
  24.  
  25. yp_start() {
  26.  
  27. if [ $YP_SERVER_ENABLE -ne 0 ]; then
  28. # NIS SERVER CONFIGURATION:
  29. # If you are the master server for the NIS domain, you must run ypserv to
  30. # service clients on the domain.
  31. if [ -x /usr/sbin/ypserv ]; then
  32. echo "Starting NIS server: /usr/sbin/ypserv"
  33. /usr/sbin/ypserv
  34. fi
  35.  
  36. # If you are the master server for the NIS domain, you must also run
  37. # rpc.yppasswdd, which is the RPC server that lets users change their
  38. # passwords. You might also want users to be able to change their shell
  39. # and GECOS information, in which case you should comment out the first
  40. # yppasswdd line and uncomment out the second one.
  41.  
  42. if [ -x /usr/sbin/rpc.yppasswdd ]; then
  43. echo "Starting NIS master password server: /usr/sbin/rpc.yppasswdd"
  44. /usr/sbin/rpc.yppasswdd
  45. # echo "Starting NIS master password server: /usr/sbin/rpc.yppasswdd -e chsh -e chfn"
  46. # /usr/sbin/rpc.yppasswdd -e chsh -e chfn
  47. fi
  48.  
  49. # If you have NIS slave servers, you might also want to start up
  50. # rpc.ypxfrd, which transfers changes in the NIS domain to slave servers.
  51. # Alternatively, rpc.ypxfrd can be run out of inetd.
  52. if [ $YP_XFRD_ENABLE -ne 0 ]; then
  53. if [ -x /usr/sbin/rpc.ypxfrd ]; then
  54. echo "Starting NIS transfer server: /usr/sbin/rpc.ypxfrd"
  55. /usr/sbin/rpc.ypxfrd
  56. fi
  57. fi
  58. fi
  59.  
  60. if [ $YP_CLIENT_ENABLE -ne 0 ]; then
  61. # NIS CLIENT CONFIGURATION:
  62. # If you are a NIS client, all you need to do is run ypbind, which will
  63. # broadcast across the network to find a server. Your NIS server might
  64. # also be a client.
  65. if [ -d /var/yp ]; then
  66. echo "Starting NIS services: /usr/sbin/ypbind -broadcast"
  67. /usr/sbin/ypbind -broadcast
  68. fi
  69. fi
  70. }
  71.  
  72. yp_stop() {
  73. if [ -r ${PID_PATH}/ypbind.pid ]; then
  74. echo "Stopping NIS services."
  75. kill $(cat ${PID_PATH}/ypbind.pid)
  76. fi
  77.  
  78. if [ -r ${PID_PATH}/ypxfrd.pid ]; then
  79. echo "Stopping NIS transfer server."
  80. kill $(cat ${PID_PATH}/ypxfrd.pid)
  81. fi
  82.  
  83. if [ -r ${PID_PATH}/yppasswdd.pid ]; then
  84. echo "Stopping NIS master password server."
  85. kill $(cat ${PID_PATH}/yppasswdd.pid)
  86. fi
  87.  
  88. if [ -r ${PID_PATH}/ypserv.pid ]; then
  89. echo "Stopping NIS server."
  90. kill $(cat ${PID_PATH}/ypserv.pid)
  91. fi
  92. }
  93.  
  94. # First, we must setup the NIS domainname. NOTE: this is not necessarily
  95. # the same as your DNS domainname, set in /etc/resolv.conf. The NIS
  96. # domainname is the name of a domain served by your NIS server.
  97. #
  98. # If /etc/defaultdomain has not been configured we'll bail out.
  99. if [ -r /etc/defaultdomain -a -x /bin/nisdomainname ]; then
  100. if [ "$(nisdomainname)" == "(none)" ]; then
  101. nisdomainname `cat /etc/defaultdomain`
  102. fi
  103. else
  104. echo "/etc/rc.d/rc.yp: NIS not configured. Hint: set up /etc/defaultdomain."
  105. exit 0
  106. fi
  107.  
  108. case "$1" in
  109. 'start')
  110. yp_start
  111. ;;
  112. 'stop')
  113. yp_stop
  114. ;;
  115. 'restart')
  116. yp_stop
  117. yp_start
  118. ;;
  119. *)
  120. echo "usage $0 start|stop|restart"
  121. esac
  122.  
  123. # # Done setting up NIS.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement