Skip to content
This repository was archived by the owner on Mar 25, 2022. It is now read-only.

Commit 9c49398

Browse files
author
Lars Gierth
committed
docker: upgrade docker, and fix non-interactive upgrades thereof
License: MIT Signed-off-by: Lars Gierth <[email protected]>
1 parent cbd7c81 commit 9c49398

File tree

2 files changed

+46
-16
lines changed

2 files changed

+46
-16
lines changed

base/install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
# TODO add nodesource repo
66
pkgs=(mosh tmux screen gdb vim tree htop iftop sysstat bridge-utils unzip jq mtr traceroute dnsutils psmisc)
77
pkgs+=(git mercurial nodejs build-essential autoconf libtool bison flex devscripts)
8-
apt-get install -qq -y "${pkgs[@]}"
8+
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::=--force-confold install -qq -y "${pkgs[@]}"
99

1010
if [ ! -e "/usr/bin/node" ]; then
1111
echo "linking nodejs => node (thanks ubuntu)"

docker/getdocker.sh

+45-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ set -e
1616
#
1717
# Git commit from https://github.com/docker/docker-install when
1818
# the script was uploaded (Should only be modified by upload job):
19-
SCRIPT_COMMIT_SHA=6a2b5fd
19+
SCRIPT_COMMIT_SHA=490beaa
2020

2121

2222
# This value will automatically get changed for:
@@ -46,6 +46,8 @@ x86_64-ubuntu-zesty
4646
s390x-ubuntu-xenial
4747
s390x-ubuntu-yakkety
4848
s390x-ubuntu-zesty
49+
ppc64le-ubuntu-xenial
50+
ppc64le-ubuntu-zesty
4951
aarch64-ubuntu-xenial
5052
armv6l-raspbian-jessie
5153
armv7l-raspbian-jessie
@@ -60,13 +62,17 @@ armv7l-ubuntu-zesty
6062
"
6163

6264
mirror=''
65+
DRY_RUN=${DRY_RUN:-}
6366
while [ $# -gt 0 ]; do
6467
case "$1" in
6568
--mirror)
6669
mirror="$2"
6770
shift
6871
;;
69-
*)
72+
--dry-run)
73+
DRY_RUN=1
74+
;;
75+
--*)
7076
echo "Illegal option $1"
7177
;;
7278
esac
@@ -152,6 +158,14 @@ command_exists() {
152158
command -v "$@" > /dev/null 2>&1
153159
}
154160

161+
is_dry_run() {
162+
if [ -z "$DRY_RUN" ]; then
163+
return 1
164+
else
165+
return 0
166+
fi
167+
}
168+
155169
get_distribution() {
156170
lsb_dist=""
157171
# Every system that we officially support has /etc/os-release
@@ -164,6 +178,9 @@ get_distribution() {
164178
}
165179

166180
echo_docker_as_nonroot() {
181+
if is_dry_run; then
182+
return
183+
fi
167184
if command_exists docker && [ -e /var/run/docker.sock ]; then
168185
(
169186
set -x
@@ -253,7 +270,7 @@ ee_notice() {
253270
}
254271

255272
do_install() {
256-
echo "Executing docker install script, commit: $SCRIPT_COMMIT_SHA"
273+
echo "# Executing docker install script, commit: $SCRIPT_COMMIT_SHA"
257274

258275
if command_exists docker; then
259276
version="$(docker -v | cut -d ' ' -f3 | cut -d ',' -f1)"
@@ -319,6 +336,10 @@ do_install() {
319336
fi
320337
fi
321338

339+
if is_dry_run; then
340+
sh_c="echo"
341+
fi
342+
322343
# perform some very rudimentary platform detection
323344
lsb_dist=$( get_distribution )
324345
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
@@ -349,10 +370,7 @@ do_install() {
349370
esac
350371
;;
351372

352-
*)
353-
if command_exists lsb_release; then
354-
dist_version="$(lsb_release --codename | cut -f2)"
355-
fi
373+
centos)
356374
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
357375
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
358376
fi
@@ -363,6 +381,15 @@ do_install() {
363381
exit 1
364382
;;
365383

384+
*)
385+
if command_exists lsb_release; then
386+
dist_version="$(lsb_release --codename | cut -f2)"
387+
fi
388+
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
389+
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
390+
fi
391+
;;
392+
366393
esac
367394

368395
# Check if this is a forked Linux distro
@@ -400,16 +427,18 @@ do_install() {
400427
fi
401428
apt_repo="deb [arch=$(dpkg --print-architecture)] $DOWNLOAD_URL/linux/$lsb_dist $dist_version $CHANNEL"
402429
(
403-
set -x
404-
$sh_c 'apt-get update'
405-
$sh_c "apt-get install -y -q $pre_reqs"
406-
curl "$DOWNLOAD_URL/linux/$lsb_dist/gpg" | $sh_c 'apt-key add -'
430+
if ! is_dry_run; then
431+
set -x
432+
fi
433+
$sh_c 'apt-get update -qq >/dev/null'
434+
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq -o Dpkg::Options::=--force-confold $pre_reqs >/dev/null"
435+
$sh_c "curl -fsSL \"$DOWNLOAD_URL/linux/$lsb_dist/gpg\" | apt-key add -qq - >/dev/null"
407436
$sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list"
408437
if [ "$lsb_dist" = "debian" ] && [ "$dist_version" = "wheezy" ]; then
409438
$sh_c 'sed -i "/deb-src.*download\.docker/d" /etc/apt/sources.list.d/docker.list'
410439
fi
411-
$sh_c 'apt-get update'
412-
$sh_c 'apt-get install -o Dpkg::Options::="--force-confold" -y -q docker-ce'
440+
$sh_c 'apt-get update -qq >/dev/null'
441+
$sh_c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq -o Dpkg::Options::=--force-confold docker-ce >/dev/null'
413442
)
414443
echo_docker_as_nonroot
415444
exit 0
@@ -439,11 +468,12 @@ do_install() {
439468
pre_reqs="yum-utils"
440469
fi
441470
(
442-
set -x
471+
if ! is_dry_run; then
472+
set -x
473+
fi
443474
$sh_c "$pkg_manager install -y -q $pre_reqs"
444475
$sh_c "$config_manager --add-repo $yum_repo"
445476
if [ "$CHANNEL" != "stable" ]; then
446-
echo "Info: Enabling channel '$CHANNEL' for docker-ce repo"
447477
$sh_c "$config_manager $enable_channel_flag docker-ce-$CHANNEL"
448478
fi
449479
$sh_c "$pkg_manager makecache"

0 commit comments

Comments
 (0)