hmc.init.in 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/sh
  2. ##
  3. #
  4. #/*
  5. # * Licensed to the Apache Software Foundation (ASF) under one
  6. # * or more contributor license agreements. See the NOTICE file
  7. # * distributed with this work for additional information
  8. # * regarding copyright ownership. The ASF licenses this file
  9. # * to you under the Apache License, Version 2.0 (the
  10. # * "License"); you may not use this file except in compliance
  11. # * with the License. You may obtain a copy of the License at
  12. # *
  13. # * http://www.apache.org/licenses/LICENSE-2.0
  14. # *
  15. # * Unless required by applicable law or agreed to in writing, software
  16. # * distributed under the License is distributed on an "AS IS" BASIS,
  17. # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. # * See the License for the specific language governing permissions and
  19. # * limitations under the License.
  20. # */
  21. #
  22. # RPM Init file for HMC
  23. #
  24. PATH=/usr/bin:/sbin:/bin:/usr/sbin
  25. export PATH
  26. [ -f /etc/sysconfig/puppet ] && . /etc/sysconfig/puppet
  27. lockfile=${LOCKFILE-/var/lock/subsys/puppet}
  28. pidfile=${PIDFILE-/var/run/puppet/agent.pid}
  29. puppetd=${PUPPETD-/usr/bin/puppet}
  30. RETVAL=0
  31. # Source function library.
  32. . /etc/rc.d/init.d/functions
  33. # Determine if we can use the -p option to daemon, killproc, and status.
  34. # RHEL < 5 can't.
  35. if status | grep -q -- '-p' 2>/dev/null; then
  36. daemonopts="--pidfile $pidfile"
  37. pidopts="-p $pidfile"
  38. fi
  39. # copy the configs in the right config dir for puppet
  40. cp /etc/puppet/auth.conf /etc/puppet/master/
  41. cp /etc/puppet/puppet.conf /etc/puppet/master/
  42. checkHDPRepo() {
  43. if [[ ! -f /etc/yum.repos.d/hdp.repo ]]; then
  44. echo "Please install hdp repo before starting hmc"
  45. exit 1
  46. fi
  47. }
  48. bootPuppet() {
  49. if [[ ! -f /var/run/hmc/puppetmaster.boot ]]; then
  50. daemon $daemonopts $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS}
  51. killproc puppet
  52. touch /var/run/hmc/puppetmaster.boot
  53. fi
  54. }
  55. checkJDK() {
  56. jdk64="jdk-6u26-linux-x64.bin"
  57. jdk32="jdk-6u26-linux-i586.bin"
  58. if [[ ! -f /var/run/hmc/downloads/$jdk64 || ! -f /var/run/hmc/downloads/$jdk32 ]]; then
  59. echo "Please download $jdk64 and $jdk32 from Oracle to /var/run/hmc/downloads/"
  60. exit 1
  61. fi
  62. mkdir -p /var/www/html/downloads
  63. cp /var/run/hmc/downloads/* /var/www/html/downloads/
  64. }
  65. PUPPET_OPTS="master --confdir=/etc/puppet/master --verbose --config_version=/usr/share/hmc/bin/get_revision --reports hmcreport --debug --logdest=/var/log/puppet_master.log --autoflush"
  66. case "$1" in
  67. start)
  68. checkHDPRepo
  69. checkJDK
  70. bootPuppet
  71. echo "Starting HMC Installer "
  72. /etc/init.d/httpd start
  73. RETVAL=$?
  74. if [ $RETVAL = 0 ]; then
  75. echo -n "Starting HMC"
  76. else
  77. echo -n "Failed to start HMC"
  78. fi
  79. echo
  80. ;;
  81. stop)
  82. echo "Shutting down HMC "
  83. /etc/init.d/httpd stop
  84. RETVAL=$?
  85. if [ $RETVAL = 0 ]; then
  86. echo -n "Stopped HMC"
  87. else
  88. echo -n "Failed to stop HMC"
  89. fi
  90. echo
  91. ;;
  92. try-restart|condrestart)
  93. if test "$1" = "condrestart"; then
  94. echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
  95. fi
  96. $0 status
  97. if test $? = 0; then
  98. $0 restart
  99. else
  100. : # Not running is not a failure.
  101. fi
  102. ;;
  103. restart)
  104. $0 stop
  105. $0 start
  106. ;;
  107. force-reload)
  108. echo -n "Reload service HMC "
  109. $0 try-restart
  110. ;;
  111. reload)
  112. $0 restart
  113. ;;
  114. status)
  115. status httpd
  116. RETVAL=$?
  117. ;;
  118. probe)
  119. echo "Not Implemented"
  120. ;;
  121. *)
  122. echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
  123. exit 1
  124. ;;
  125. esac
  126. exit $RETVAL