build files for making podman containers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

59 lines
1.9 KiB

#!/bin/bash
set -eEuo pipefail
trap 'echo "Error detected: aborting installation"' ERR
echo "Attempting to autodetect distro ..."
distro=$(lsb_release -is)
release=$(lsb_release -rs)
if [[ $distro == "Debian" ]]; then
echo "Detected distro: Debian"
if [[ $release =~ ^[0-9]+$ ]]; then
echo "Detected release: $release"
elif [[ $release == "testing" ]]; then
echo "Detected release: testing"
release=Testing
else
echo "Error: failed to detect release"
exit 1
fi
echo "Installing podman ..."
sudo apt install -y gnupg curl
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_${release:?}/ /" | sudo tee /etc/apt/sources.list.d/podman.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_${release:?}/Release.key | sudo apt-key add -
sudo apt update -y
sudo apt install -y fuse-overlayfs slirp4netns podman
else
echo "Error: failed to detect distro."
exit 1
fi
echo "Copying scripts to /usr/local/bin ..."
# copy bin files to /usr/local/bin
sudo cp .install/bin/* /usr/local/bin/
echo "Installing containers startup service ..."
# install systemd startup service
sudo cp .install/containers-startup.service /etc/systemd/system/
sudo systemctl enable containers-startup.service
# create startup.d if it doesn't exist
sudo mkdir -p /etc/containers/startup.d
# configure containers user
name=containers
uid=5000
subrange="1000000-1000000000"
if [[ ! $(getent group $name) ]]; then
echo "Creating group '$name' ..."
sudo groupadd -r -g $uid $name
fi
if [[ ! $(getent passwd $name) ]]; then
echo "Creating user '$name' ..."
sudo useradd -r -u $uid -p '*'-s /sbin/nologin -d /srv/vol -g $name $name
fi
echo "Configuring user '$name' ..."
sudo groupmod -g $uid $name
sudo usermod -u $uid -p '*' -s /sbin/nologin -d /srv/vol/ -G '' -v $subrange -w $subrange -g $name $name
echo "Install finished successfully."