generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathdisable-admin-container
More file actions
26 lines (22 loc) · 872 Bytes
/
disable-admin-container
File metadata and controls
26 lines (22 loc) · 872 Bytes
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
#!/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 disabled; 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 false; then
echo "The admin container is already disabled - it should stop soon, if it hasn't already."
else
echo "Disabling admin container"
if ! apiclient set host-containers.admin.enabled=false; then
error "failed to disable admin container"
fi
echo "The admin container is now disabled - it should stop soon."
fi