From 39a5cc646d961285d90ab6e4c0ae466df211d13c Mon Sep 17 00:00:00 2001 From: Ruslan Savchuk Date: Thu, 3 Apr 2025 23:13:20 +0200 Subject: [PATCH] add basic init script --- src/init.sh | 358 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 358 insertions(+) create mode 100644 src/init.sh diff --git a/src/init.sh b/src/init.sh new file mode 100644 index 0000000..8f7000a --- /dev/null +++ b/src/init.sh @@ -0,0 +1,358 @@ +#!/bin/bash + +stage="" + +# Parse command line arguments +while [[ "$#" -gt 0 ]]; do + case $1 in + --stage) + stage="$2" + shift # Remove --last-stage + shift # Remove the value + ;; + *) + echo "Unknown parameter: $1" + exit 1 + ;; + esac +done + +# init container runtime +if [ "$stage" = "configure-runtime" ]; then +echo '====================== download runc =========================' +wget -q --show-progress --https-only --timestamping \ + https://github.com/opencontainers/runc/releases/download/v1.2.6/runc.amd64 + +echo '====================== make runc executable =========================' +mv runc.amd64 runc \ + && chmod +x runc \ + && mv runc /usr/local/bin/ + +echo '====================== download containerd =========================' +wget https://github.com/containerd/containerd/releases/download/v2.0.4/containerd-2.0.4-linux-amd64.tar.gz + +echo '====================== make containerd executable =========================' +mkdir containerd \ + && tar -xvf containerd-2.0.4-linux-amd64.tar.gz -C containerd \ + && mv containerd/bin/* /bin/ + +echo '====================== int containerd service =========================' +mkdir -p /etc/containerd/ +cat << EOF | tee /etc/containerd/config.toml +[debug] + level = "debug" + +[plugins] + [plugins.'io.containerd.cri.v1.images'] + snapshotter = "native" + [plugins."io.containerd.cri.v1.runtime"] + [plugins."io.containerd.cri.v1.runtime".containerd] + default_runtime_name = "runc" + [plugins."io.containerd.cri.v1.runtime".containerd.runtimes] + [plugins."io.containerd.cri.v1.runtime".containerd.runtimes.runc] + runtime_type = "io.containerd.runc.v2" + snapshotter = "native" + + [plugins."io.containerd.cri.v1.runtime".containerd.runtimes.runc.options] + BinaryName = "/usr/local/bin/runc" +EOF + +cat <