summaryrefslogtreecommitdiffstats
path: root/lib/container/move
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2016-12-11 12:34:23 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2016-12-11 12:34:23 +0000
commit83e6c0c55c255c069e5ee5bf9cb2d8d5f2b83f2a (patch)
treed10157feb045e099bacae644b0832c1522560f07 /lib/container/move
parentAdding upstream version 20161201. (diff)
downloadopen-infrastructure-compute-tools-83e6c0c55c255c069e5ee5bf9cb2d8d5f2b83f2a.tar.xz
open-infrastructure-compute-tools-83e6c0c55c255c069e5ee5bf9cb2d8d5f2b83f2a.zip
Adding upstream version 20161210.upstream/20161210
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rwxr-xr-xlib/container/move (renamed from lib/container/rename)25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/container/rename b/lib/container/move
index 467d687..6e855e4 100755
--- a/lib/container/rename
+++ b/lib/container/move
@@ -21,6 +21,7 @@ set -e
COMMAND="$(basename ${0})"
CONFIG="/etc/container-tools/config"
+HOOKS="/etc/container-tools/hooks"
MACHINES="/var/lib/machines"
Parameters ()
@@ -110,7 +111,7 @@ case "${FORCE}" in
*)
if container list --other | grep -qs "^${OLD}$"
then
- echo -n "'${OLD}': rename remote container to '${NEW}' [y|N]? "
+ echo -n "'${OLD}': rename container to '${NEW}' [y|N]? "
read FORCE
FORCE="$(echo ${FORCE} | tr [A-Z] [a-z])"
@@ -127,11 +128,20 @@ case "${FORCE}" in
;;
esac
+# Pre hooks
+for FILE in "${HOOKS}/pre-${COMMAND}".* "${HOOKS}/${NAME}.pre-${COMMAND}"
+do
+ if [ -x "${FILE}" ]
+ then
+ "${FILE}"
+ fi
+done
+
# Run
mv "${CONFIG}/${OLD}.conf" "${CONFIG}/${NEW}.conf"
mv "${MACHINES}/${OLD}" "${MACHINES}/${NEW}"
-# Renaming bind mounts
+# bind mounts
BIND="$(awk -F= '/^bind=/ { print $2 }' ${CONFIG}/${NAME}.conf)"
if [ -n "${BIND}" ]
@@ -158,5 +168,14 @@ then
done
fi
-# Updating configuration file
+# config
sed -i -e "s|${OLD}|${NEW}|g" "${CONFIG}/${NEW}.conf"
+
+# Post hooks
+for FILE in "${HOOKS}/post-${COMMAND}".* "${HOOKS}/${NAME}.post-${COMMAND}"
+do
+ if [ -x "${FILE}" ]
+ then
+ "${FILE}"
+ fi
+done