Commit f6e23601 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Add diskdump support in the helper (part 2)

parent 42f09a19
......@@ -29,6 +29,7 @@
RESULT=/dev/ttyS1
FLOPPY_DEV=/dev/fd0
PROGNAME=$(basename $0)
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
......@@ -50,6 +51,10 @@ log_error() {
exit 1
}
warn() {
echo "Warning: $@" >&2
}
get_base_distro() {
local root_dir=$1
......@@ -154,6 +159,8 @@ cleanup() {
fi
}
trap cleanup EXIT
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
......@@ -20,20 +20,18 @@ fi
retval=$(get_last_partition "$SNF_IMAGE_DEV")
id=$(echo $retval | cut -d: -f1)
pstart=$(echo $retval | cut -d: -f2)
pend=$(echo $retval | cut -d: -f3)
ptype=$(echo $retval | cut -d: -f5)
if [ $id -gt 4 ]; then
log_error "We don't support logical volumes"
fi
pstart=$(echo $retval | cut -d: -f2)
pend=$(echo $retval | cut -d: -f3)
ptype=$(echo $retval | cut -d: -f5)
if [ x"$ptype" = "x" ]; then
# Don't know how to handle this
echo "Warning: Last partition with id: \`$id' is empty" \
"or has unknown filesystem"
warn "Last partition with id: \`$id' is empty or has unknown filesystem"
warn "I won't resize the partition"
exit 0
fi
......@@ -41,7 +39,7 @@ new_pend=$(get_last_free_sector "$SNF_IMAGE_DEV")
#Extend the partition
$PARTED -s -m "$SNF_IMAGE_DEV" rm $id
$PARTED -s -m "$SNF_IMAGE_DEV" rm "$id"
$PARTED -s -m "$SNF_IMAGE_DEV" mkpart primary "$ptype" "$pstart" "$new_pend"
#inform the kernel about the changes
......
......@@ -14,16 +14,12 @@ if [ ! -b "$SNF_IMAGE_DEV" ]; then
log_error "Device file:\`${SNF_IMAGE_DEV}' is not a block device"
fi
if [ -z "$SNF_IMAGE_TYPE" ]; then
log_error "Image type does not exist"
fi
last_partition=$(get_last_partition "$SNF_IMAGE_DEV")
id=$(echo "$last_partition" | cut -d: -f1)
ptype=$(echo "$last_partition" | cut -d: -f5)
if [[ "$ptype" =~ ext[234] ]]; then
device="$SNF_IMAGE_DEV""$id"
if [[ "$ptype" == ext[234] ]]; then
device="${SNF_IMAGE_DEV}${id}"
"$RESIZE2FS" "$device"
fi
......
......@@ -14,7 +14,7 @@ if [ ! -d "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"
fi
if [ "$SNF_IMAGE_TYPE" = "ntfsdump" ]; then
if [ "$SNF_IMAGE_OS" = "windows" ]; then
# Make sure Unattend.xml is removed after setup has finished
mkdir -p "$SNF_IMAGE_TARGET/Windows/Setup/Scripts"
echo "del /Q /F C:\Unattend.xml" > "$SNF_IMAGE_TARGET/Windows/Setup/Scripts/SetupComplete.cmd"
......
......@@ -16,7 +16,7 @@ fi
target="$SNF_IMAGE_TARGET"
if [ "$SNF_IMAGE_TYPE" != "extdump" ]; then
if [ "$SNF_IMAGE_OS" != "linux" ]; then
cleanup
trap - EXIT
exit 0
......
......@@ -11,10 +11,10 @@ set -e
. "@commondir@/common.sh"
if [ -z "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"
log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"
fi
if [ "$SNF_IMAGE_TYPE" != "ntfsdump" ]; then
if [ "$SNF_IMAGE_OS" != "windows" ]; then
exit 0
fi
......
......@@ -14,7 +14,7 @@ if [ ! -d "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"
fi
if [ "$SNF_IMAGE_TYPE" = "extdump" ]; then
if [ "$SNF_IMAGE_OS" = "linux" ]; then
distro=$(get_base_distro $SNF_IMAGE_TARGET)
if [ "$distro" = "redhat" ]; then
......
......@@ -62,9 +62,9 @@ if [ -z "$SNF_IMAGE_HOSTNAME" ]; then
log_error "Hostname is missing"
fi
if [ "$SNF_IMAGE_TYPE" = "ntfsdump" ]; then
if [ "$SNF_IMAGE_OS" = "windows" ]; then
windows_hostname "$SNF_IMAGE_TARGET" "$SNF_IMAGE_HOSTNAME"
elif [ "$SNF_IMAGE_TYPE" = "extdump" ]; then
elif [ "$SNF_IMAGE_OS" = "linux" ]; then
linux_hostname "$SNF_IMAGE_TARGET" "$SNF_IMAGE_HOSTNAME"
fi
......
......@@ -66,9 +66,9 @@ if [ -z "$SNF_IMAGE_PASSWORD" ]; then
log_error "Password is missing"
fi
if [ "$SNF_IMAGE_TYPE" = "ntfsdump" ]; then
if [ "$SNF_IMAGE_OS" = "windows" ]; then
windows_password "$SNF_IMAGE_TARGET" "$SNF_IMAGE_PASSWORD"
elif [ "$SNF_IMAGE_TYPE" = "extdump" ]; then
elif [ "$SNF_IMAGE_OS" = "linux" ]; then
linux_password "$SNF_IMAGE_TARGET" "$SNF_IMAGE_PASSWORD"
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment