From 05bb9668f4c67012711b4a966c22636d88c08906 Mon Sep 17 00:00:00 2001 From: Roger Luethi Date: Wed, 18 Jun 2014 09:53:54 +0200 Subject: [PATCH] Scripts to clean disk and shut down This changeset adds two simple scripts: one fills the unused space of the root disk with zeroes to allow for better compression of the resulting disk image, the other shuts the computer down. Partial-Bug: 1312764 Implements: blueprint openstack-training-labs Change-Id: I2e80518733b0e1e17a59192c6e2522f423709551 --- labs/scripts/shutdown.sh | 13 +++++++++++++ labs/scripts/zero_empty.sh | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 labs/scripts/shutdown.sh create mode 100644 labs/scripts/zero_empty.sh diff --git a/labs/scripts/shutdown.sh b/labs/scripts/shutdown.sh new file mode 100644 index 00000000..fd51ab82 --- /dev/null +++ b/labs/scripts/shutdown.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +TOP_DIR=$(cd $(dirname "$0")/.. && pwd) +source "$TOP_DIR/config/paths" +source "$LIB_DIR/functions.guest" + +indicate_current_auto + +exec_logfile + +echo "Shutting down" + +# Shutdown some time after returning so our caller has time to finish +sudo -b sh -c 'sleep 2; /sbin/shutdown -P now' diff --git a/labs/scripts/zero_empty.sh b/labs/scripts/zero_empty.sh new file mode 100644 index 00000000..bfff5fd5 --- /dev/null +++ b/labs/scripts/zero_empty.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +TOP_DIR=$(cd $(dirname "$0")/.. && pwd) +source "$TOP_DIR/config/paths" +source "$LIB_DIR/functions.guest" + +indicate_current_auto + +exec_logfile + +# Fill unused disk space with zeroes (the disk image is easier to compress when +# it doesn't contain leftovers from deleted files) +zero_empty_space