#!/bin/bash # This file is part of Bottlerocket. # Copyright Amazon.com, Inc., its affiliates, or other contributors. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0 OR MIT if [[ $EUID -ne 0 ]]; then echo "sheltie must be run as root, you can use 'sudo sheltie' in the admin container" exit 1 fi # Location of the container's rootfs on the host filesystem # Because we have a shared pid namespace, /proc inside the container matches # /proc outside the container. The special directory 'root' inside a given # process directory in /proc contains that process's view of the filesystem. # We use ${PPID} to indicate the pid of the parent process of this script so we # can see the container's root filesystem inside this directory. ROOT_FS_PATH="/proc/${PPID}/root" BASH_PATH="/opt/bin/bash" # Start the root shell on the Bottlerocket host if [[ ${#@} -ne 0 ]]; then exec nsenter -t 1 -a -- "$@" else exec nsenter -t 1 -a "${ROOT_FS_PATH}${BASH_PATH}" fi