-
Notifications
You must be signed in to change notification settings - Fork 160
/
keycloak-importer
executable file
·70 lines (62 loc) · 2.32 KB
/
keycloak-importer
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2020, 2022 Eurotech and/or its affiliates and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eurotech - initial API and implementation
###############################################################################
ERROR=0
DOCKER_ACCOUNT=${DOCKER_ACCOUNT:=kapua}
IMAGE_VERSION=${IMAGE_VERSION:=1.6.10}
KEYCLOAK="keycloak"
TMP_DIR="/tmp/keycloak-container-$(date +%s)"
echo "Creating tmp directory: ${TMP_DIR}..."
mkdir -p "${TMP_DIR}" || die "Cannot create directory '${TMP_DIR}' where to copy files."
echo "Creating tmp directory... DONE!"
echo ""
(
echo "Exporting Keycloak image..."
echo " ${KEYCLOAK}:${IMAGE_VERSION}"
docker save -o "${TMP_DIR}"/${KEYCLOAK} ${DOCKER_ACCOUNT}/${KEYCLOAK}:${IMAGE_VERSION} &> /dev/null ||
{
echo " Cannot export image: ${KEYCLOAK}:${IMAGE_VERSION}"
echo " Perhaps it is not present in the local Docker registry?"
echo ""
exit 1
}
echo "Exporting Keycloak image... DONE!"
echo ""
eval "$(minishift docker-env)"
echo "Importing Keycloak image into Minishift..."
echo "${KEYCLOAK}:${IMAGE_VERSION}"
docker load < "${TMP_DIR}"/${KEYCLOAK} &> /dev/null ||
{
echo " Cannot import image: ${KEYCLOAK}:${IMAGE_VERSION}"
echo " Perhaps due to previous errors?"
exit 1
}
echo "Importing Keycloak images into Minishift... DONE!"
echo ""
) ||
{
ERROR=1;
echo "Exporting/Importing Keycloak image... FAILED!"
echo " Perhaps docker images are not present in the local Docker registry?"
echo " Please check running command:"
echo " docker images"
echo " If no '${DOCKER_ACCOUNT}/${KEYCLOAK}*:${IMAGE_VERSION}' image is present, please build it running command:"
echo " mvn clean install -Pkeycloak"
echo ""
}
echo "Removing tmp directory: ${TMP_DIR}..."
if [ -d "${TMP_DIR}" ]; then
rm -rf "${TMP_DIR}"
fi
echo "Removing tmp directory... DONE!"
exit ${ERROR}