Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -45,11 +45,11 @@ if [ ! -x $DOCKERD ]; then |
| 45 | 45 |
fi |
| 46 | 46 |
|
| 47 | 47 |
check_init() {
|
| 48 |
- # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly) |
|
| 49 |
- if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then |
|
| 50 |
- log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1" |
|
| 51 |
- exit 1 |
|
| 52 |
- fi |
|
| 48 |
+ # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly) |
|
| 49 |
+ if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then |
|
| 50 |
+ log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1" |
|
| 51 |
+ exit 1 |
|
| 52 |
+ fi |
|
| 53 | 53 |
} |
| 54 | 54 |
|
| 55 | 55 |
fail_unless_root() {
|
| ... | ... |
@@ -32,122 +32,122 @@ logfile="/var/log/$prog" |
| 32 | 32 |
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog |
| 33 | 33 |
|
| 34 | 34 |
prestart() {
|
| 35 |
- service cgconfig status > /dev/null |
|
| 35 |
+ service cgconfig status > /dev/null |
|
| 36 | 36 |
|
| 37 |
- if [[ $? != 0 ]]; then |
|
| 38 |
- service cgconfig start |
|
| 39 |
- fi |
|
| 37 |
+ if [[ $? != 0 ]]; then |
|
| 38 |
+ service cgconfig start |
|
| 39 |
+ fi |
|
| 40 | 40 |
|
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 | 43 |
start() {
|
| 44 |
- if [ ! -x $exec ]; then |
|
| 45 |
- if [ ! -e $exec ]; then |
|
| 46 |
- echo "Docker executable $exec not found" |
|
| 47 |
- else |
|
| 48 |
- echo "You do not have permission to execute the Docker executable $exec" |
|
| 49 |
- fi |
|
| 50 |
- exit 5 |
|
| 51 |
- fi |
|
| 52 |
- |
|
| 53 |
- check_for_cleanup |
|
| 54 |
- |
|
| 55 |
- if ! [ -f $pidfile ]; then |
|
| 56 |
- prestart |
|
| 57 |
- printf "Starting $prog:\t" |
|
| 58 |
- echo "\n$(date)\n" >> $logfile |
|
| 59 |
- "$unshare" -m -- $exec $other_args >> $logfile 2>&1 & |
|
| 60 |
- pid=$! |
|
| 61 |
- touch $lockfile |
|
| 62 |
- # wait up to 10 seconds for the pidfile to exist. see |
|
| 63 |
- # https://github.com/docker/docker/issues/5359 |
|
| 64 |
- tries=0 |
|
| 65 |
- while [ ! -f $pidfile -a $tries -lt 10 ]; do |
|
| 66 |
- sleep 1 |
|
| 67 |
- tries=$((tries + 1)) |
|
| 68 |
- echo -n '.' |
|
| 69 |
- done |
|
| 70 |
- if [ ! -f $pidfile ]; then |
|
| 71 |
- failure |
|
| 72 |
- echo |
|
| 73 |
- exit 1 |
|
| 74 |
- fi |
|
| 75 |
- success |
|
| 76 |
- echo |
|
| 77 |
- else |
|
| 78 |
- failure |
|
| 79 |
- echo |
|
| 80 |
- printf "$pidfile still exists...\n" |
|
| 81 |
- exit 7 |
|
| 82 |
- fi |
|
| 44 |
+ if [ ! -x $exec ]; then |
|
| 45 |
+ if [ ! -e $exec ]; then |
|
| 46 |
+ echo "Docker executable $exec not found" |
|
| 47 |
+ else |
|
| 48 |
+ echo "You do not have permission to execute the Docker executable $exec" |
|
| 49 |
+ fi |
|
| 50 |
+ exit 5 |
|
| 51 |
+ fi |
|
| 52 |
+ |
|
| 53 |
+ check_for_cleanup |
|
| 54 |
+ |
|
| 55 |
+ if ! [ -f $pidfile ]; then |
|
| 56 |
+ prestart |
|
| 57 |
+ printf "Starting $prog:\t" |
|
| 58 |
+ echo "\n$(date)\n" >> $logfile |
|
| 59 |
+ "$unshare" -m -- $exec $other_args >> $logfile 2>&1 & |
|
| 60 |
+ pid=$! |
|
| 61 |
+ touch $lockfile |
|
| 62 |
+ # wait up to 10 seconds for the pidfile to exist. see |
|
| 63 |
+ # https://github.com/docker/docker/issues/5359 |
|
| 64 |
+ tries=0 |
|
| 65 |
+ while [ ! -f $pidfile -a $tries -lt 10 ]; do |
|
| 66 |
+ sleep 1 |
|
| 67 |
+ tries=$((tries + 1)) |
|
| 68 |
+ echo -n '.' |
|
| 69 |
+ done |
|
| 70 |
+ if [ ! -f $pidfile ]; then |
|
| 71 |
+ failure |
|
| 72 |
+ echo |
|
| 73 |
+ exit 1 |
|
| 74 |
+ fi |
|
| 75 |
+ success |
|
| 76 |
+ echo |
|
| 77 |
+ else |
|
| 78 |
+ failure |
|
| 79 |
+ echo |
|
| 80 |
+ printf "$pidfile still exists...\n" |
|
| 81 |
+ exit 7 |
|
| 82 |
+ fi |
|
| 83 | 83 |
} |
| 84 | 84 |
|
| 85 | 85 |
stop() {
|
| 86 |
- echo -n $"Stopping $prog: " |
|
| 87 |
- killproc -p $pidfile -d 300 $prog |
|
| 88 |
- retval=$? |
|
| 89 |
- echo |
|
| 90 |
- [ $retval -eq 0 ] && rm -f $lockfile |
|
| 91 |
- return $retval |
|
| 86 |
+ echo -n $"Stopping $prog: " |
|
| 87 |
+ killproc -p $pidfile -d 300 $prog |
|
| 88 |
+ retval=$? |
|
| 89 |
+ echo |
|
| 90 |
+ [ $retval -eq 0 ] && rm -f $lockfile |
|
| 91 |
+ return $retval |
|
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 | 94 |
restart() {
|
| 95 |
- stop |
|
| 96 |
- start |
|
| 95 |
+ stop |
|
| 96 |
+ start |
|
| 97 | 97 |
} |
| 98 | 98 |
|
| 99 | 99 |
reload() {
|
| 100 |
- restart |
|
| 100 |
+ restart |
|
| 101 | 101 |
} |
| 102 | 102 |
|
| 103 | 103 |
force_reload() {
|
| 104 |
- restart |
|
| 104 |
+ restart |
|
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 | 107 |
rh_status() {
|
| 108 |
- status -p $pidfile $prog |
|
| 108 |
+ status -p $pidfile $prog |
|
| 109 | 109 |
} |
| 110 | 110 |
|
| 111 | 111 |
rh_status_q() {
|
| 112 |
- rh_status >/dev/null 2>&1 |
|
| 112 |
+ rh_status >/dev/null 2>&1 |
|
| 113 | 113 |
} |
| 114 | 114 |
|
| 115 | 115 |
|
| 116 | 116 |
check_for_cleanup() {
|
| 117 |
- if [ -f ${pidfile} ]; then
|
|
| 118 |
- /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
|
|
| 119 |
- fi |
|
| 117 |
+ if [ -f ${pidfile} ]; then
|
|
| 118 |
+ /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
|
|
| 119 |
+ fi |
|
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 | 122 |
case "$1" in |
| 123 |
- start) |
|
| 124 |
- rh_status_q && exit 0 |
|
| 125 |
- $1 |
|
| 126 |
- ;; |
|
| 127 |
- stop) |
|
| 128 |
- rh_status_q || exit 0 |
|
| 129 |
- $1 |
|
| 130 |
- ;; |
|
| 131 |
- restart) |
|
| 132 |
- $1 |
|
| 133 |
- ;; |
|
| 134 |
- reload) |
|
| 135 |
- rh_status_q || exit 7 |
|
| 136 |
- $1 |
|
| 137 |
- ;; |
|
| 138 |
- force-reload) |
|
| 139 |
- force_reload |
|
| 140 |
- ;; |
|
| 141 |
- status) |
|
| 142 |
- rh_status |
|
| 143 |
- ;; |
|
| 144 |
- condrestart|try-restart) |
|
| 145 |
- rh_status_q || exit 0 |
|
| 146 |
- restart |
|
| 147 |
- ;; |
|
| 148 |
- *) |
|
| 149 |
- echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
|
| 150 |
- exit 2 |
|
| 123 |
+ start) |
|
| 124 |
+ rh_status_q && exit 0 |
|
| 125 |
+ $1 |
|
| 126 |
+ ;; |
|
| 127 |
+ stop) |
|
| 128 |
+ rh_status_q || exit 0 |
|
| 129 |
+ $1 |
|
| 130 |
+ ;; |
|
| 131 |
+ restart) |
|
| 132 |
+ $1 |
|
| 133 |
+ ;; |
|
| 134 |
+ reload) |
|
| 135 |
+ rh_status_q || exit 7 |
|
| 136 |
+ $1 |
|
| 137 |
+ ;; |
|
| 138 |
+ force-reload) |
|
| 139 |
+ force_reload |
|
| 140 |
+ ;; |
|
| 141 |
+ status) |
|
| 142 |
+ rh_status |
|
| 143 |
+ ;; |
|
| 144 |
+ condrestart|try-restart) |
|
| 145 |
+ rh_status_q || exit 0 |
|
| 146 |
+ restart |
|
| 147 |
+ ;; |
|
| 148 |
+ *) |
|
| 149 |
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
|
| 150 |
+ exit 2 |
|
| 151 | 151 |
esac |
| 152 | 152 |
|
| 153 | 153 |
exit $? |