forked from grnet/ganeti-instance-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export
executable file
·54 lines (50 loc) · 1.74 KB
/
export
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
# Copyright (C) 2010, 2011, 2012 Oregon State University
# Copyright (C) 2013, 2014, 2015 GRNET S.A.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
set -e
. ./common.sh
debug set -x
# TODO:
# * use $EXPORT_INDEX
mkdir_dumpdir_temp
losetup_blockdev
case "$SHELL" in
*zsh|*bash)
:
;;
*) # dash, ash, etc apparently can't handle FDs >=10
test -z "$EXP_SIZE_FD" || test "$EXP_SIZE_FD" -lt 10 || EXP_SIZE_FD=''
;;
esac
test -z "$EXP_SIZE_FD" || expr `disk_size 'get'` \* 512 >&$EXP_SIZE_FD
if test 'yes' = "$NOMOUNT"; then
if test 'nomount' = "`printf '%s' "$IMAGE_NAME" | cut -d- -f1`" && test -n "$OLD_BLOCKDEV"; then
unlosetup_blockdev
cleanup pop
qcow_create "${DUMPDIR}/disk.img" 'raw'
else
qcow_create "${DUMPDIR}/disk.img"
fi
cleanup push "rm -f \"${DUMPDIR}/disk.img\""
else
map_all
dump_create "${DUMPDIR}/root.dump"
cleanup push "rm -f \"${DUMPDIR}/root.dump\""
cleanup push "rm -f \"${DUMPDIR}/boot.dump\" 2>/dev/null || :"
fi
( cd "$DUMPDIR" && tar -cf - . ) # export dumps to tar on stdout