aboutsummaryrefslogtreecommitdiff
path: root/bin/provision-docker
blob: d24ea56293c191306695ef38a86c8732ea889a8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
#
# Provisioner for Docker
#

# Check for sudo
if [ "`whoami`" != "root" ]; then
  SUDO="sudo"
fi

# Parameters
# See https://wiki.debian.org/Backports#Finding_backports
COMPOSE_BACKPORT="`apt show docker-compose -a 2> /dev/null | grep backports | awk '{ print $3 }' | cut -d '/' -f 1`"

# Ensure an up-to-date system
$SUDO apt-get update
$SUDO apt-get upgrade -y

# Check for backport availability for Debian bookworm
if [ "$COMPOSE_BACKPORT" == "bookworm-backports" ]; then
  COMPOSE_BACKPORTS="-t $COMPOSE_BACKPORT"
fi

# Docker and docker-compose from distribution
$SUDO apt-get install $COMPOSE_BACKPORTS -y docker.io docker-compose

# Put the regular user into docker group
$SUDO usermod -a -G docker $(whoami)