Revision bad5ca1f snf-image-host/common.sh.in

b/snf-image-host/common.sh.in
40 40

  
41 41
CLEANUP=( )
42 42

  
43
add_cleanup() {
44
    local cmd=""
45
    for arg; do cmd+=$(printf "%q " "$arg"); done
46
    CLEANUP+=("$cmd")
47
}
48

  
43 49
log_error() {
44 50
    echo "$@" >&2
45 51
}
......
139 145
        log_error "Cannot interpret kpartx output and get partition mapping"
140 146
        exit 1
141 147
    fi
142
    $KPARTX -a -p- $blockdev > /dev/null
148
    $KPARTX -a -p- "$blockdev" > /dev/null
143 149
    filesystem_dev="/dev/mapper/${filesystem_dev_base/%-1/}"
144 150
    if [ ! -b "/dev/mapper/$filesystem_dev_base" ]; then
145 151
        log_error "Can't find kpartx mapped partition:" \
......
150 156
}
151 157

  
152 158
unmap_disk0() {
153
    $KPARTX -d -p- $1
159
    $KPARTX -d -p- "$1"
154 160
}
155 161

  
156 162
format_disk0() {
......
171 177
create_floppy() {
172 178
    local img=$1
173 179

  
174
    local target=$(mktemp -d) || exit 1
175
    CLEANUP+=("rmdir $target")
180
    local target=$(mktemp -d)
181
    add_cleanup rmdir "$target"
176 182

  
177
    dd bs=512 count=2880 if=/dev/zero of=$img
178
    mkfs.ext2 -F $img > /dev/null
179
    mount $img $target -o loop
183
    dd bs=512 count=2880 if=/dev/zero of="$img"
184
    mkfs.ext2 -F "$img" > /dev/null
185
    mount "$img" "$target" -o loop
180 186
    set | egrep ^snf_export_\\w+=|sed -e 's/^snf_export_/SNF_IMAGE_/' | \
181 187
    while read line; do
182
        echo "export $line" >> $target/rules
188
        echo "export $line" >> "$target/rules"
183 189
    done
184
    umount $target
190
    umount "$target"
185 191
}
186 192

  
187 193
# this one is only to be called by create
......
275 281
: ${HELPER_KERNEL:="@HELPER_KERNEL@"}
276 282
: ${HELPER_INITRD:="@HELPER_INITRD@"}
277 283
: ${HELPER_PKG:="@HELPER_DIR@/snf-image-helper.deb"}
278
: ${HELPER_SOFT_TIMEOUT=15}
279
: ${HELPER_HARD_TIMEOUT=5}
280
: ${HELPER_USER="nobody"}
284
: ${HELPER_SOFT_TIMEOUT:=15}
285
: ${HELPER_HARD_TIMEOUT:=5}
286
: ${HELPER_USER:="nobody"}
287
: ${HELPER_CACHE_FILE:="@HELPER_DIR@/cache.tar"}
288
: ${HELPER_EXTRA_PKGS:="linux-image-amd64,e2fsprogs,ntfs-3g,ntfsprogs,xmlstarlet,python"}
289

  
281 290

  
282 291
SCRIPT_NAME=$(basename $0)
283 292

  

Also available in: Unified diff