Skip to content

Commit

Permalink
Added timeout for starting/stopping Docker daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
markdumay committed Nov 5, 2020
1 parent 4f723f6 commit a898e78
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions syno_docker_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Description : An Unofficial Script to Update or Restore Docker Engine and Docker Compose on Synology
# Author : Mark Dumay
# Date : November 5th, 2020
# Version : 1.1.0
# Version : 1.1.1
# Usage : sudo ./syno_docker_update.sh [OPTIONS] COMMAND
# Repository : https://github.com/markdumay/synology-docker.git
# License : MIT - https://github.com/markdumay/synology-docker/blob/master/LICENSE
Expand All @@ -26,6 +26,7 @@ readonly DOWNLOAD_DOCKER=https://download.docker.com/linux/static/stable/x86_64
readonly DOWNLOAD_GITHUB=https://github.com/docker/compose
readonly GITHUB_API_COMPOSE=https://api.github.com/repos/docker/compose/releases/latest
readonly SYNO_DOCKER_SERV_NAME=pkgctl-Docker
readonly SYNO_SERVICE_TIMEOUT='5m'
readonly SYNO_DOCKER_DIR=/var/packages/Docker
readonly SYNO_DOCKER_BIN_PATH=$SYNO_DOCKER_DIR/target/usr
readonly SYNO_DOCKER_BIN=$SYNO_DOCKER_BIN_PATH/bin
Expand Down Expand Up @@ -529,15 +530,19 @@ execute_prepare() {
# Globals:
# - stage
# Outputs:
# Stopped Docker daemon.
# Stopped Docker daemon, or a non-zero exit code if the stop failed or timed out.
#======================================================================================================================
execute_stop_syno() {
print_status "Stopping Docker service"

if [ "${stage}" = 'false' ] ; then
syno_status=$(synoservicectl --status "${SYNO_DOCKER_SERV_NAME}" | grep running -o)
if [ "${syno_status}" = 'running' ] ; then
synoservicectl --stop "${SYNO_DOCKER_SERV_NAME}"
timeout "${SYNO_SERVICE_TIMEOUT}" synoservicectl --stop "${SYNO_DOCKER_SERV_NAME}"
syno_status=$(synoservicectl --status "${SYNO_DOCKER_SERV_NAME}" | grep stop -o)
if [ "${syno_status}" = 'stop' ] ; then
terminate "Could not stop Docker daemon"
fi
fi
else
echo "Skipping Docker service control in STAGE mode"
Expand Down Expand Up @@ -760,13 +765,13 @@ execute_restore_log() {
# - force
# - stage
# Outputs:
# Started Docker daemon, or a non-zero exit code if the start failed.
# Started Docker daemon, or a non-zero exit code if the start failed or timed out.
#======================================================================================================================
execute_start_syno() {
print_status "Starting Docker service"

if [ "${stage}" = 'false' ] ; then
synoservicectl --start "${SYNO_DOCKER_SERV_NAME}"
timeout "${SYNO_SERVICE_TIMEOUT}" synoservicectl --start "${SYNO_DOCKER_SERV_NAME}"

syno_status=$(synoservicectl --status "${SYNO_DOCKER_SERV_NAME}" | grep running -o)
if [ "${syno_status}" != 'running' ] ; then
Expand Down

0 comments on commit a898e78

Please sign in to comment.