forked from bottlerocket-os/bottlerocket-control-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enable-admin-container
33 lines (27 loc) · 1.09 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
29
30
31
32
33
#!/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
cat >&2 <<-EOF
You can manually enable the admin container like this:
apiclient -u /settings -m PATCH -d '{"host-containers": {"admin": {"enabled": true}}}'
apiclient -u /tx/commit_and_apply -m POST
EOF
exit 1
}
if ! command -v apiclient >/dev/null 2>&1; then
error "can't find 'apiclient'"
fi
# Use our own transaction so we don't interfere with other changes
TX="enable-admin-container"
echo "Setting admin container to enabled"
if ! apiclient -v -u "/settings?tx=${TX}" -m PATCH -d '{"host-containers": {"admin": {"enabled": true}}}'; then
error "failed to change enabled setting of admin container"
fi
echo "Committing and applying changes"
if ! apiclient -v -u "/tx/commit_and_apply?tx=${TX}" -m POST; then
error "failed to commit and apply settings"
fi
echo "The admin container is now enabled - it should pull and start soon, and then you can SSH in"