forked from bottlerocket-os/bottlerocket-control-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enable-admin-container
28 lines (24 loc) · 1.15 KB
/
enable-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
#!/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
error() {
echo -e "Error: ${*}\n" >&2
exit 1
}
if ! command -v apiclient >/dev/null 2>&1; then
error "can't find 'apiclient'"
fi
# Check if the admin container is already enabled; if it is, we don't want to
# change settings, or it may be restarted.
if apiclient raw -u "/settings?keys=settings.host-containers.admin.enabled" | grep -q true; then
echo "The admin container is already enabled - it should start soon, if it hasn't already, and then you can SSH in or use 'apiclient exec admin bash'."
echo "You can also use 'enter-admin-container' to enable, wait, and connect in one step."
else
echo "Enabling admin container"
if ! apiclient set host-containers.admin.enabled=true; then
error "failed to enable admin container"
fi
echo "The admin container is now enabled - it should pull and start soon, and then you can SSH in or use 'apiclient exec admin bash'."
echo "You can also use 'enter-admin-container' to enable, wait, and connect in one step."
fi