This repository has been archived by the owner on May 3, 2019. It is now read-only.
forked from osuosl/ganeti-instance-image
-
Notifications
You must be signed in to change notification settings - Fork 2
/
import
executable file
·61 lines (57 loc) · 2.05 KB
/
import
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
55
56
57
58
59
60
61
#!/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 $IMPORT_INDEX
mkdir_dumpdir_temp
( cd "$DUMPDIR" && tar -xf - ) # import dumps from tar on stdin
if test 'yes' = "$NOMOUNT"; then
cleanup push "rm -f \"${DUMPDIR}/disk.img\""
if test 'nomount' = "`printf '%s' "$IMAGE_NAME" | cut -d- -f1`" && ! test -b "$BLOCKDEV"; then
qcow_extractfile "${DUMPDIR}/disk.img" 'raw'
else
losetup_blockdev
qcow_extractfile "${DUMPDIR}/disk.img"
fi
else
cleanup push "rm -f \"${DUMPDIR}/root.dump\""
cleanup push "rm -f \"${DUMPDIR}/boot.dump\" 2>/dev/null || :"
use_unique_tmpdir
losetup_blockdev
get_disk0_size_mbytes
check_swap_size
format_disk0
map_all
mkfs_disk0
get_uuids
mount_disk0
dump_extractfile "${DUMPDIR}/root.dump"
setup_fstab
! test 'True' = "$INSTANCE_HV_serial_console" || setup_console
filesystem_relabel
rm -f "${TARGET}/etc/udev/rules.d/z"*"_persistent-net.rules"
if test -x "${CUSTOMIZE_DIR}/grub"; then
ROOT_DEV="$root_dev"; BOOT_DEV="$boot_dev"; IMPORT_SCRIPT=1
export TARGET SUITE BLOCKDEV ROOT_DEV BOOT_DEV IMG_SSH_KEY_URL IMPORT_SCRIPT
# Install grub as we're not deploying via a disk image
"${CUSTOMIZE_DIR}/grub"
fi
fi