summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-qcow2-rootfs/hooks/pre-mount/mount-qcow.sh
blob: d70492bf2f8692adb6b31044ccc2e292dbaa680d (plain) (blame)
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
###############################################################################
# CHECKS
#

SETUP_ROOTFS_SCRIPT="/sbin/setup-qcow2"

if [ ! -e "${SETUP_ROOTFS_SCRIPT}" ]; then
	warn "No such file of directory: ${SETUP_ROOTFS_SCRIPT}"
	emergency_shell -n "Error in $0"
	return 1
fi

if [ ! -x "${SETUP_ROOTFS_SCRIPT}" ]; then
	warn "Cannot execute: ${SETUP_ROOTFS_SCRIPT}"
	emergency_shell -n "Error in $0"
	return 1
fi

#
# END CHECKS
###############################################################################

###############################################################################
# MAIN CODE
#

# ok, let's source the setup script
if ! . ${SETUP_ROOTFS_SCRIPT} ; then
	warn "Could not source: ${SETUP_ROOTFS_SCRIPT}"
	emergency_shell -n "Error in $0"
	return 1
fi

# just go over the functions in the right order ;-)
for fun in connect_dnbd3 create_qcow export_qcow connect_qcow; do
	if ! $fun; then
		# something failed, drop a shell for debugging
		warn "'$fun' failed with: $?"
		emergency_shell -n "Error in $fun"
		return 1
	fi
done

# all good, we are done
return 0

#
# END MAIN CODE
###############################################################################