Skip to content

Commit

Permalink
Merge pull request markdumay#27 from markdumay/develop
Browse files Browse the repository at this point in the history
Validate CPU architecture
  • Loading branch information
markdumay authored Nov 5, 2020
2 parents b08e2db + e02c72c commit f96c904
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 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.1
# Version : 1.1.2
# 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 @@ -22,7 +22,8 @@ readonly BOLD='\e[1m' # Bold font
readonly DSM_SUPPORTED_VERSION=6
readonly DEFAULT_DOCKER_VERSION='19.03.13'
readonly DEFAULT_COMPOSE_VERSION='1.27.4'
readonly DOWNLOAD_DOCKER=https://download.docker.com/linux/static/stable/x86_64
readonly CPU_ARCH='x86_64'
readonly DOWNLOAD_DOCKER="https://download.docker.com/linux/static/stable/${CPU_ARCH}"
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
Expand Down Expand Up @@ -155,7 +156,7 @@ detect_current_versions() {
}

#======================================================================================================================
# Verifies the host runs DSM and that Docker (including Compose) is already installed.
# Verifies the host has the right CPU, runs DSM and that Docker (including Compose) is already installed.
#======================================================================================================================
# Globals:
# - dsm_version
Expand All @@ -165,6 +166,12 @@ detect_current_versions() {
# Terminates with non-zero exit code if host is incompatible.
#======================================================================================================================
validate_current_version() {
# Test host has supported CPU, exit otherwise
current_arch=$(uname -m)
if [ "${current_arch}" != "${CPU_ARCH}" ]; then
terminate "This script supports ${CPU_ARCH} CPUs only, use --force to override"
fi

# Test if host is DSM 6, exit otherwise
if [ "${dsm_major_version}" != "${DSM_SUPPORTED_VERSION}" ] ; then
terminate "This script supports DSM 6.x only, use --force to override"
Expand Down Expand Up @@ -650,7 +657,6 @@ execute_extract_backup() {
fi
}

# TODO: fix x86_64
#======================================================================================================================
# Downloads the targeted Docker Compose binary, unless instructed to skip the download.
#======================================================================================================================
Expand All @@ -663,7 +669,7 @@ execute_extract_backup() {
#======================================================================================================================
execute_download_compose() {
if [ "${skip_compose_update}" = 'false' ] ; then
compose_bin="${DOWNLOAD_GITHUB}/releases/download/${target_compose_version}/docker-compose-Linux-x86_64"
compose_bin="${DOWNLOAD_GITHUB}/releases/download/${target_compose_version}/docker-compose-Linux-${CPU_ARCH}"
print_status "Downloading target Docker Compose binary (${compose_bin})"
response=$(curl -L "${compose_bin}" --write-out '%{http_code}' -o "${download_dir}/docker-compose")
if [ "${response}" != 200 ] ; then
Expand Down

0 comments on commit f96c904

Please sign in to comment.