-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup_runner.sh
executable file
·58 lines (52 loc) · 1.82 KB
/
setup_runner.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -e
basic_packages=("buildah" "uidmap" "libcap2" "libcap2-bin" "podman")
multiarch_packages=("qemu" "binfmt-support" "qemu-user-static")
archs="${INPUT_ARCHS}"
platforms="${INPUT_PLATFORMS}"
missing_packages=()
# Validate input
if [ -n "$archs" ] && [ -n "$platforms" ]; then
echo "::error::Both 'archs' and 'platforms' are set. Please specify only one."
exit 1
fi
# Determine all required packages based on inputs
required_packages=("${basic_packages[@]}")
if [ -n "$archs" ] || [ -n "$platforms" ]; then
required_packages+=("${multiarch_packages[@]}")
fi
# Check for missing packages
echo "::group::Checking Package Installation"
for pkg in "${required_packages[@]}"; do
if ! dpkg -s "$pkg" &> /dev/null; then
echo "Package $pkg is not installed."
missing_packages+=("$pkg")
else
echo "Package $pkg is already installed."
fi
done
echo "::endgroup::"
# If there are missing packages, update and install
if [ ${#missing_packages[@]} -ne 0 ]; then
echo "::group::Updating package lists and installing missing packages"
sudo apt-get update
sudo apt-get -y install "${missing_packages[@]}"
echo "::endgroup::"
else
echo "All required packages are already installed."
fi
# Apply additional configurations
echo "::group::Applying Additional Configurations"
sudo setcap cap_setuid+eip /usr/bin/newuidmap
sudo setcap cap_setgid+eip /usr/bin/newgidmap
sudo chmod u-s /usr/bin/newuidmap
sudo chmod u-s /usr/bin/newgidmap
if [ ! -f ~/.local/share/containers/.clean ]; then
sudo rm -rf ~/.local/share/containers/*
mkdir -p ~/.local/share/containers/
sudo touch ~/.local/share/containers/.clean
fi
echo -e "[storage]\ndriver = \"vfs\"" | sudo tee /etc/containers/storage.conf > /dev/null
mkdir -p "$HOME/.docker"
echo "::endgroup::"
echo "Configuration completed successfully."