github.com/pritambaral/docker@v1.4.2-0.20150120174542-b2fe1b3dd952/contrib/init/sysvinit-redhat/docker (about) 1 #!/bin/sh 2 # 3 # /etc/rc.d/init.d/docker 4 # 5 # Daemon for docker.com 6 # 7 # chkconfig: 2345 95 95 8 # description: Daemon for docker.com 9 10 ### BEGIN INIT INFO 11 # Provides: docker 12 # Required-Start: $network cgconfig 13 # Required-Stop: 14 # Should-Start: 15 # Should-Stop: 16 # Default-Start: 2 3 4 5 17 # Default-Stop: 0 1 6 18 # Short-Description: start and stop docker 19 # Description: Daemon for docker.com 20 ### END INIT INFO 21 22 # Source function library. 23 . /etc/rc.d/init.d/functions 24 25 prog="docker" 26 exec="/usr/bin/$prog" 27 pidfile="/var/run/$prog.pid" 28 lockfile="/var/lock/subsys/$prog" 29 logfile="/var/log/$prog" 30 31 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog 32 33 prestart() { 34 service cgconfig status > /dev/null 35 36 if [[ $? != 0 ]]; then 37 service cgconfig start 38 fi 39 40 } 41 42 start() { 43 [ -x $exec ] || exit 5 44 45 if ! [ -f $pidfile ]; then 46 prestart 47 printf "Starting $prog:\t" 48 echo "\n$(date)\n" >> $logfile 49 $exec -d $other_args &>> $logfile & 50 pid=$! 51 touch $lockfile 52 # wait up to 10 seconds for the pidfile to exist. see 53 # https://github.com/docker/docker/issues/5359 54 tries=0 55 while [ ! -f $pidfile -a $tries -lt 10 ]; do 56 sleep 1 57 tries=$((tries + 1)) 58 done 59 success 60 echo 61 else 62 failure 63 echo 64 printf "$pidfile still exists...\n" 65 exit 7 66 fi 67 } 68 69 stop() { 70 echo -n $"Stopping $prog: " 71 killproc -p $pidfile -d 300 $prog 72 retval=$? 73 echo 74 [ $retval -eq 0 ] && rm -f $lockfile 75 return $retval 76 } 77 78 restart() { 79 stop 80 start 81 } 82 83 reload() { 84 restart 85 } 86 87 force_reload() { 88 restart 89 } 90 91 rh_status() { 92 status -p $pidfile $prog 93 } 94 95 rh_status_q() { 96 rh_status >/dev/null 2>&1 97 } 98 99 case "$1" in 100 start) 101 rh_status_q && exit 0 102 $1 103 ;; 104 stop) 105 rh_status_q || exit 0 106 $1 107 ;; 108 restart) 109 $1 110 ;; 111 reload) 112 rh_status_q || exit 7 113 $1 114 ;; 115 force-reload) 116 force_reload 117 ;; 118 status) 119 rh_status 120 ;; 121 condrestart|try-restart) 122 rh_status_q || exit 0 123 restart 124 ;; 125 *) 126 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" 127 exit 2 128 esac 129 130 exit $?