diff options
Diffstat (limited to '')
-rwxr-xr-x | lib/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 |