-
Notifications
You must be signed in to change notification settings - Fork 15
/
restore.sh
executable file
·47 lines (36 loc) · 1.47 KB
/
restore.sh
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 -x
MY_DIR=$(dirname "$(readlink -f "$0")")
if [ $# -lt 1 ]; then
echo "Usage: "
echo " ${0} [Different tgz Docker Image file]"
echo "e.g.: "
echo " ${0} "
fi
###################################################
#### ---- Change this only to use your own ----
###################################################
ORGANIZATION=openkbs
###################################################
#### **** Container package information ****
###################################################
DOCKER_IMAGE_REPO=`echo $(basename $PWD)|tr '[:upper:]' '[:lower:]'|tr "/: " "_" `
imageTag="${ORGANIZATION}/${DOCKER_IMAGE_REPO}"
###################################################
#### ---- Mostly, you don't need change below ----
###################################################
## -- transform '-' and space to '_'
#instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/\-: " "_"`
instanceName=`echo $(basename ${imageTag})|tr '[:upper:]' '[:lower:]'|tr "/: " "_"`
TGZ_DOCKER_IMAGE=${1:-${instanceName}.tgz}
function restore() {
if [ ! -s ${TGZ_DOCKER_IMAGE} ]; then
echo "*** ERROR ***: Can't find image (*.tgz or tar.gz) file: Can't continue! Abort!"
exit 1
fi
gunzip -c ${TGZ_DOCKER_IMAGE} | docker load
sudo docker images | grep ${TGZ_DOCKER_IMAGE%.tgz}
}
echo "---------------------------------------------"
echo "---- SAVE a Container for ${imageTag}"
echo "---------------------------------------------"
restore