forked from bottlerocket-os/bottlerocket-control-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enter-admin-container
45 lines (37 loc) · 1.09 KB
/
enter-admin-container
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
#!/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
THISDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
error() {
echo -e "Error: ${*}\n" >&2
exit 1
}
if ! command -v apiclient >/dev/null 2>&1; then
error "can't find 'apiclient'"
fi
# Use our existing script to enable the admin container if it's not already.
# We don't want its stdout, which is about how to connect to the admin
# container; that's what this script is for!
echo "Confirming admin container is enabled..."
if ! "${THISDIR}/enable-admin-container" >/dev/null; then
error "failed to enable admin container."
fi
echo -n "Waiting for admin container to start..."
max=60
i=0
while :; do
(( i++ ))
if [[ $i -gt $max ]]; then
echo
error "could not connect to admin container within $max seconds."
fi
if apiclient exec admin true &>/dev/null; then
break
fi
echo -n "."
sleep 1
done
echo
echo "Entering admin container"
apiclient exec admin bash