-
Notifications
You must be signed in to change notification settings - Fork 38
/
sheltie
25 lines (22 loc) · 981 Bytes
/
sheltie
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
#!/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