Revision bad5ca1f snf-image-helper/snf-image-helper.in
b/snf-image-helper/snf-image-helper.in | ||
---|---|---|
32 | 32 |
. @commondir@/common.sh |
33 | 33 |
|
34 | 34 |
set -e |
35 |
set -o pipefail |
|
35 | 36 |
|
36 | 37 |
# terminate helper vm when the script exits |
37 |
CLEANUP+=("telinit 0")
|
|
38 |
add_cleanup telinit 0
|
|
38 | 39 |
|
39 |
if [ ! -b $FLOPPY_DEV ]; then
|
|
40 |
if [ ! -b "$FLOPPY_DEV" ]; then
|
|
40 | 41 |
log_error "Floppy device is not present!" |
41 | 42 |
fi |
42 | 43 |
|
43 |
floppy=$(mktemp -d --tmpdir floppy.XXXXXXXX)
|
|
44 |
CLEANUP+=("rmdir $floppy")
|
|
44 |
floppy=$(mktemp -d --tmpdir floppy.XXXXXX) |
|
45 |
add_cleanup rmdir "$floppy"
|
|
45 | 46 |
|
46 | 47 |
mount $FLOPPY_DEV $floppy |
47 |
CLEANUP+=("umount $floppy")
|
|
48 |
add_cleanup umount "$floppy"
|
|
48 | 49 |
|
49 |
if [ -f $floppy/rules ]; then
|
|
50 |
source $floppy/rules
|
|
50 |
if [ -f "$floppy/rules" ]; then
|
|
51 |
source "$floppy/rules"
|
|
51 | 52 |
else |
52 | 53 |
log_error "Floppy does not contain \`rules\' file" |
53 | 54 |
fi |
54 | 55 |
|
55 | 56 |
# Image mount point... |
56 |
target=$(mktemp -d --tmpdir target.XXXXXXXX)
|
|
57 |
CLEANUP+=("rmdir $target")
|
|
57 |
target=$(mktemp -d --tmpdir target.XXXXXX) |
|
58 |
add_cleanup rmdir "$target"
|
|
58 | 59 |
|
59 |
export SNF_IMAGE_TARGET=$target
|
|
60 |
export SNF_IMAGE_TARGET="$target"
|
|
60 | 61 |
|
61 | 62 |
if [ ! -d "@tasksdir@" ]; then |
62 | 63 |
log_error "snf-image/tasks directory is missing" |
... | ... | |
69 | 70 |
|
70 | 71 |
# If something goes wrong with the tasks, try to umount the target filesystem |
71 | 72 |
# in case it is left mounted... |
72 |
trap '{ umount $target; }' ERR
|
|
73 |
trap '{ umount "$target"; }' ERR
|
|
73 | 74 |
|
74 |
echo "Execute all snf-image tasks...."
|
|
75 |
echo "Execute all snf-image tasks...." |
|
75 | 76 |
$RUN_PARTS -v --exit-on-error "@tasksdir@" |
76 | 77 |
|
77 | 78 |
# Disable the trap. If code reaches here, the filesystem is unmounted. |
78 | 79 |
trap - ERR |
79 | 80 |
|
80 |
echo "SUCCESS" > $RESULT
|
|
81 |
echo "SUCCESS" > "$RESULT"
|
|
81 | 82 |
|
82 | 83 |
cleanup |
83 | 84 |
trap - EXIT |
Also available in: Unified diff