You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.3 KiB

9 years ago
9 years ago
9 years ago
9 years ago
  1. #!/bin/bash
  2. #
  3. # /etc/rc.d/init.d/kubelet
  4. #
  5. # chkconfig: 2345 95 95
  6. # description: Daemon for kubelet (kubernetes.io)
  7. ### BEGIN INIT INFO
  8. # Provides: kubelet
  9. # Required-Start: $local_fs $network $syslog cgconfig
  10. # Required-Stop:
  11. # Should-Start:
  12. # Should-Stop:
  13. # Default-Start: 2 3 4 5
  14. # Default-Stop: 0 1 6
  15. # Short-Description: start and stop kubelet
  16. # Description:
  17. # The Kubernetes container manager maintains docker state against a state file.
  18. ### END INIT INFO
  19. # Source function library.
  20. . /etc/rc.d/init.d/functions
  21. prog="kubelet"
  22. exec="{{ bin_dir }}/$prog"
  23. pidfile="/var/run/$prog.pid"
  24. lockfile="/var/lock/subsys/$prog"
  25. logfile="/var/log/$prog"
  26. [ -e /etc/kubernetes/$prog.env ] && . /etc/kubernetes/$prog.env
  27. start() {
  28. if [ ! -x $exec ]; then
  29. if [ ! -e $exec ]; then
  30. echo "Docker executable $exec not found"
  31. else
  32. echo "You do not have permission to execute the Docker executable $exec"
  33. fi
  34. exit 5
  35. fi
  36. check_for_cleanup
  37. if ! [ -f $pidfile ]; then
  38. printf "Starting $prog:\t"
  39. echo "\n$(date)\n" >> $logfile
  40. $exec $DAEMON_ARGS &>> $logfile &
  41. pid=$!
  42. echo $pid >> $pidfile
  43. touch $lockfile
  44. success
  45. echo
  46. else
  47. failure
  48. echo
  49. printf "$pidfile still exists...\n"
  50. exit 7
  51. fi
  52. }
  53. stop() {
  54. echo -n $"Stopping $prog: "
  55. killproc -p $pidfile -d 300 $prog
  56. retval=$?
  57. echo
  58. [ $retval -eq 0 ] && rm -f $lockfile
  59. return $retval
  60. }
  61. restart() {
  62. stop
  63. start
  64. }
  65. reload() {
  66. restart
  67. }
  68. force_reload() {
  69. restart
  70. }
  71. rh_status() {
  72. status -p $pidfile $prog
  73. }
  74. rh_status_q() {
  75. rh_status >/dev/null 2>&1
  76. }
  77. check_for_cleanup() {
  78. if [ -f ${pidfile} ]; then
  79. /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
  80. fi
  81. }
  82. case "$1" in
  83. start)
  84. rh_status_q && exit 0
  85. $1
  86. ;;
  87. stop)
  88. rh_status_q || exit 0
  89. $1
  90. ;;
  91. restart)
  92. $1
  93. ;;
  94. reload)
  95. rh_status_q || exit 7
  96. $1
  97. ;;
  98. force-reload)
  99. force_reload
  100. ;;
  101. status)
  102. rh_status
  103. ;;
  104. condrestart|try-restart)
  105. rh_status_q || exit 0
  106. restart
  107. ;;
  108. *)
  109. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
  110. exit 2
  111. esac
  112. exit $?