github.com/oyvindsk/docker@v1.5.0/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 unshare=/usr/bin/unshare 27 exec="/usr/bin/$prog" 28 pidfile="/var/run/$prog.pid" 29 lockfile="/var/lock/subsys/$prog" 30 logfile="/var/log/$prog" 31 32 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog 33 34 prestart() { 35 service cgconfig status > /dev/null 36 37 if [[ $? != 0 ]]; then 38 service cgconfig start 39 fi 40 41 } 42 43 start() { 44 [ -x $exec ] || exit 5 45 46 if ! [ -f $pidfile ]; then 47 prestart 48 printf "Starting $prog:\t" 49 echo "\n$(date)\n" >> $logfile 50 "$unshare" -m -- $exec -d $other_args &>> $logfile & 51 pid=$! 52 touch $lockfile 53 # wait up to 10 seconds for the pidfile to exist. see 54 # https://github.com/docker/docker/issues/5359 55 tries=0 56 while [ ! -f $pidfile -a $tries -lt 10 ]; do 57 sleep 1 58 tries=$((tries + 1)) 59 done 60 success 61 echo 62 else 63 failure 64 echo 65 printf "$pidfile still exists...\n" 66 exit 7 67 fi 68 } 69 70 stop() { 71 echo -n $"Stopping $prog: " 72 killproc -p $pidfile -d 300 $prog 73 retval=$? 74 echo 75 [ $retval -eq 0 ] && rm -f $lockfile 76 return $retval 77 } 78 79 restart() { 80 stop 81 start 82 } 83 84 reload() { 85 restart 86 } 87 88 force_reload() { 89 restart 90 } 91 92 rh_status() { 93 status -p $pidfile $prog 94 } 95 96 rh_status_q() { 97 rh_status >/dev/null 2>&1 98 } 99 100 case "$1" in 101 start) 102 rh_status_q && exit 0 103 $1 104 ;; 105 stop) 106 rh_status_q || exit 0 107 $1 108 ;; 109 restart) 110 $1 111 ;; 112 reload) 113 rh_status_q || exit 7 114 $1 115 ;; 116 force-reload) 117 force_reload 118 ;; 119 status) 120 rh_status 121 ;; 122 condrestart|try-restart) 123 rh_status_q || exit 0 124 restart 125 ;; 126 *) 127 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" 128 exit 2 129 esac 130 131 exit $?