github.com/containerd/nerdctl@v1.7.7/Dockerfile.d/test-integration-rootless.sh (about) 1 #!/bin/bash 2 3 # Copyright The containerd Authors. 4 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 9 # http://www.apache.org/licenses/LICENSE-2.0 10 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 set -eux -o pipefail 18 if [[ "$(id -u)" = "0" ]]; then 19 if [ -e /sys/kernel/security/apparmor/profiles ]; then 20 # Load the "nerdctl-default" profile for TestRunApparmor 21 nerdctl apparmor load 22 fi 23 24 : "${WORKAROUND_ISSUE_622:=}" 25 if [[ "$WORKAROUND_ISSUE_622" = "1" ]]; then 26 touch /workaround-issue-622 27 fi 28 29 # Switch to the rootless user via SSH 30 systemctl start ssh 31 exec ssh -o StrictHostKeyChecking=no rootless@localhost "$0" "$@" 32 else 33 containerd-rootless-setuptool.sh install 34 if grep -q "options use-vc" /etc/resolv.conf; then 35 containerd-rootless-setuptool.sh nsenter -- sh -euc 'echo "options use-vc" >>/etc/resolv.conf' 36 fi 37 38 if [[ -e /workaround-issue-622 ]]; then 39 echo "WORKAROUND_ISSUE_622: Not enabling BuildKit (https://github.com/containerd/nerdctl/issues/622)" >&2 40 else 41 CONTAINERD_NAMESPACE="nerdctl-test" containerd-rootless-setuptool.sh install-buildkit-containerd 42 fi 43 containerd-rootless-setuptool.sh install-stargz 44 if [ ! -f "/home/rootless/.config/containerd/config.toml" ] ; then 45 echo "version = 2" > /home/rootless/.config/containerd/config.toml 46 fi 47 cat <<EOF >>/home/rootless/.config/containerd/config.toml 48 [proxy_plugins] 49 [proxy_plugins."stargz"] 50 type = "snapshot" 51 address = "/run/user/$(id -u)/containerd-stargz-grpc/containerd-stargz-grpc.sock" 52 EOF 53 systemctl --user restart containerd.service 54 containerd-rootless-setuptool.sh -- install-ipfs --init --offline # offline ipfs daemon for testing 55 echo "ipfs = true" >>/home/rootless/.config/containerd-stargz-grpc/config.toml 56 systemctl --user restart stargz-snapshotter.service 57 export IPFS_PATH="/home/rootless/.local/share/ipfs" 58 containerd-rootless-setuptool.sh install-bypass4netnsd 59 exec "$@" 60 fi