summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-09-01 16:29:41 +0200
committerThomas Haller <thaller@redhat.com>2022-09-01 16:33:39 +0200
commit8ae132cc49e9f4a11a22ca9eba78731f9c1c7153 (patch)
tree04cdd30313a9a9f94170937844bb595a84668abe
parent222bd85fdc277e586ff688e085f9a86e4ac9f768 (diff)
downloadNetworkManager-8ae132cc49e9f4a11a22ca9eba78731f9c1c7153.tar.gz
contrib: add "reset" command to "nm-in-container.sh"
It's between "stop" and "clean". It removes the container, but keeps the container images. This is to fast restart without rebuilding the container (image).
-rwxr-xr-xcontrib/scripts/nm-in-container.sh23
1 files changed, 14 insertions, 9 deletions
diff --git a/contrib/scripts/nm-in-container.sh b/contrib/scripts/nm-in-container.sh
index 28fa58b425..efa06fd6d6 100755
--- a/contrib/scripts/nm-in-container.sh
+++ b/contrib/scripts/nm-in-container.sh
@@ -6,12 +6,13 @@ set -e
# Script to create a podman container for testing NetworkManager.
#
# Commands:
-# - build: build a new image, named "$CONTAINER_NAME_REPOSITORY:$CONTAINER_NAME_TAG" ("nm:nm")
-# - run: start the container and tag it "$CONTAINER_NAME_NAME" ("nm")
-# - exec: run bash inside the container
-# - journal|j: print the journal from inside the container
-# - stop: stop the container
-# - clean: delete the container and the image.
+# - build: build a new image, named "$CONTAINER_NAME_REPOSITORY:$CONTAINER_NAME_TAG" ("nm:nm").
+# - run: start the container and tag it "$CONTAINER_NAME_NAME" ("nm").
+# - exec: run bash inside the container (this is the default).
+# - journal|j: print the journal from inside the container.
+# - stop: stop the container.
+# - reset: stop and delete the container.
+# - clean: stop and delete the container and the image.
#
# Options:
# --no-cleanup: don't delete the CONTAINERFILE and other artifacts
@@ -41,7 +42,7 @@ EXEC_ENV=()
usage() {
cat <<EOF
-$0: build|run|exec|stop|clean|journal [--no-cleanup] [--stop] [-- EXTRA_ARGS]
+$0: build|run|exec|stop|reset|clean|journal [--no-cleanup] [--stop] [-- EXTRA_ARGS]
EOF
echo
awk '/^####*$/{ if(on) exit; on=1} { if (on) { if (on==2) print(substr($0,3)); on=2; } }' "$BASH_SOURCE"
@@ -418,9 +419,13 @@ container_is_running() {
###############################################################################
-do_clean() {
+do_reset() {
podman stop "$CONTAINER_NAME_NAME" || :
podman rm "$CONTAINER_NAME_NAME" || :
+}
+
+do_clean() {
+ do_reset
podman rmi "$CONTAINER_NAME_REPOSITORY:$CONTAINER_NAME_TAG" || :
}
@@ -509,7 +514,7 @@ for (( i=1 ; i<="$#" ; )) ; do
j)
CMD=journal
;;
- build|run|exec|stop|clean|journal)
+ build|run|exec|stop|reset|clean|journal)
CMD=$c
;;
--)