github.com/deemoprobe/k8s-first-commit@v0.0.0-20230430165612-a541f1982be3/src/saltbase/salt/controller-manager/initd (about) 1 #!/bin/bash 2 # 3 ### BEGIN INIT INFO 4 # Provides: controller-manager 5 # Required-Start: $local_fs $network $syslog 6 # Required-Stop: 7 # Default-Start: 2 3 4 5 8 # Default-Stop: 0 1 6 9 # Short-Description: The Kubernetes controller manager 10 # Description: 11 # The Kubernetes controller manager is responsible for monitoring replication 12 # controllers, and creating corresponding tasks to achieve the desired state. 13 ### END INIT INFO 14 15 16 # PATH should only include /usr/* if it runs after the mountnfs.sh script 17 PATH=/sbin:/usr/sbin:/bin:/usr/bin 18 DESC="The Kubernetes container manager" 19 NAME=controller-manager 20 DAEMON=/usr/local/bin/controller-manager 21 DAEMON_ARGS=" --master=127.0.0.1:8080" 22 DAEMON_LOG_FILE=/var/log/$NAME.log 23 PIDFILE=/var/run/$NAME.pid 24 SCRIPTNAME=/etc/init.d/$NAME 25 DAEMON_USER=controller-manager 26 27 # Exit if the package is not installed 28 [ -x "$DAEMON" ] || exit 0 29 30 # Read configuration variable file if it is present 31 [ -r /etc/default/$NAME ] && . /etc/default/$NAME 32 33 # Define LSB log_* functions. 34 # Depend on lsb-base (>= 3.2-14) to ensure that this file is present 35 # and status_of_proc is working. 36 . /lib/lsb/init-functions 37 38 # 39 # Function that starts the daemon/service 40 # 41 do_start() 42 { 43 # Return 44 # 0 if daemon has been started 45 # 1 if daemon was already running 46 # 2 if daemon could not be started 47 start-stop-daemon --start --quiet --background --no-close \ 48 --make-pidfile --pidfile $PIDFILE \ 49 --exec $DAEMON -c $DAEMON_USER --test > /dev/null \ 50 || return 1 51 start-stop-daemon --start --quiet --background --no-close \ 52 --make-pidfile --pidfile $PIDFILE \ 53 --exec $DAEMON -c $DAEMON_USER -- \ 54 $DAEMON_ARGS >> $DAEMON_LOG_FILE 2>&1 \ 55 || return 2 56 } 57 58 # 59 # Function that stops the daemon/service 60 # 61 do_stop() 62 { 63 # Return 64 # 0 if daemon has been stopped 65 # 1 if daemon was already stopped 66 # 2 if daemon could not be stopped 67 # other if a failure occurred 68 start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON 69 RETVAL="$?" 70 [ "$RETVAL" = 2 ] && return 2 71 # Many daemons don't delete their pidfiles when they exit. 72 rm -f $PIDFILE 73 return "$RETVAL" 74 } 75 76 77 case "$1" in 78 start) 79 log_daemon_msg "Starting $DESC" "$NAME" 80 do_start 81 case "$?" in 82 0|1) log_end_msg 0 || exit 0 ;; 83 2) verblog_end_msg 1 || exit 1 ;; 84 esac 85 ;; 86 stop) 87 log_daemon_msg "Stopping $DESC" "$NAME" 88 do_stop 89 case "$?" in 90 0|1) log_end_msg 0 ;; 91 2) exit 1 ;; 92 esac 93 ;; 94 status) 95 status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $? 96 ;; 97 98 restart|force-reload) 99 log_daemon_msg "Restarting $DESC" "$NAME" 100 do_stop 101 case "$?" in 102 0|1) 103 do_start 104 case "$?" in 105 0) log_end_msg 0 ;; 106 1) log_end_msg 1 ;; # Old process is still running 107 *) log_end_msg 1 ;; # Failed to start 108 esac 109 ;; 110 *) 111 # Failed to stop 112 log_end_msg 1 113 ;; 114 esac 115 ;; 116 *) 117 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 118 exit 3 119 ;; 120 esac