Revision f6e23601

b/snf-image-helper/common.sh
29 29

  
30 30
RESULT=/dev/ttyS1
31 31
FLOPPY_DEV=/dev/fd0
32
PROGNAME=$(basename $0)
32 33

  
33 34
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
34 35

  
......
50 51
    exit 1
51 52
}
52 53

  
54
warn() {
55
    echo "Warning: $@" >&2
56
}
57

  
53 58
get_base_distro() {
54 59
    local root_dir=$1
55 60

  
......
154 159
  fi
155 160
}
156 161

  
162

  
163

  
157 164
trap cleanup EXIT
158 165

  
159 166
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :
b/snf-image-helper/tasks/10FixPartitionTable.in
20 20
retval=$(get_last_partition "$SNF_IMAGE_DEV")
21 21

  
22 22
id=$(echo $retval | cut -d: -f1)
23
pstart=$(echo $retval | cut -d: -f2)
24
pend=$(echo $retval | cut -d: -f3)
25
ptype=$(echo $retval | cut -d: -f5)
23 26

  
24 27
if [ $id -gt 4 ]; then
25 28
    log_error "We don't support logical volumes"
26 29
fi
27 30

  
28
pstart=$(echo $retval | cut -d: -f2)
29
pend=$(echo $retval | cut -d: -f3)
30
ptype=$(echo $retval | cut -d: -f5)
31

  
32 31
if [ x"$ptype" = "x" ]; then
33 32
    # Don't know how to handle this
34
    echo "Warning: Last partition with id: \`$id' is empty" \
35
        "or has unknown filesystem"
36

  
33
    warn "Last partition with id: \`$id' is empty or has unknown filesystem"
34
    warn "I won't resize the partition"
37 35
    exit 0
38 36
fi
39 37

  
......
41 39

  
42 40
#Extend the partition
43 41

  
44
$PARTED -s -m "$SNF_IMAGE_DEV" rm $id
42
$PARTED -s -m "$SNF_IMAGE_DEV" rm "$id"
45 43
$PARTED -s -m "$SNF_IMAGE_DEV" mkpart primary "$ptype" "$pstart" "$new_pend"
46 44

  
47 45
#inform the kernel about the changes
b/snf-image-helper/tasks/20FilesystemResizeUnmounted.in
14 14
    log_error "Device file:\`${SNF_IMAGE_DEV}' is not a block device"
15 15
fi
16 16

  
17
if [ -z "$SNF_IMAGE_TYPE" ]; then
18
    log_error "Image type does not exist"
19
fi
20

  
21 17
last_partition=$(get_last_partition "$SNF_IMAGE_DEV")
22 18
id=$(echo "$last_partition" | cut -d: -f1)
23 19
ptype=$(echo "$last_partition" | cut -d: -f5)
24 20

  
25
if [[ "$ptype" =~ ext[234] ]]; then
26
    device="$SNF_IMAGE_DEV""$id"
21
if [[ "$ptype" == ext[234] ]]; then
22
    device="${SNF_IMAGE_DEV}${id}"
27 23
    "$RESIZE2FS" "$device"
28 24
fi
29 25

  
b/snf-image-helper/tasks/40AddDeleteUnattendScript.in
14 14
	log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"	
15 15
fi
16 16

  
17
if [ "$SNF_IMAGE_TYPE" = "ntfsdump" ]; then
17
if [ "$SNF_IMAGE_OS" = "windows" ]; then
18 18
    # Make sure Unattend.xml is removed after setup has finished
19 19
    mkdir -p "$SNF_IMAGE_TARGET/Windows/Setup/Scripts"
20 20
    echo "del /Q /F C:\Unattend.xml" > "$SNF_IMAGE_TARGET/Windows/Setup/Scripts/SetupComplete.cmd"
b/snf-image-helper/tasks/40DeleteSSHKeys.in
16 16

  
17 17
target="$SNF_IMAGE_TARGET"
18 18

  
19
if [ "$SNF_IMAGE_TYPE" != "extdump" ]; then
19
if [ "$SNF_IMAGE_OS" != "linux" ]; then
20 20
    cleanup
21 21
    trap - EXIT
22 22
    exit 0
b/snf-image-helper/tasks/40InstallUnattend.in
11 11
. "@commondir@/common.sh"
12 12

  
13 13
if [ -z "$SNF_IMAGE_TARGET" ]; then
14
    log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"	
14
    log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"
15 15
fi
16 16

  
17
if [ "$SNF_IMAGE_TYPE" != "ntfsdump" ]; then
17
if [ "$SNF_IMAGE_OS" != "windows" ]; then
18 18
    exit 0
19 19
fi
20 20

  
b/snf-image-helper/tasks/40SELinuxAutorelabel.in
14 14
	log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"	
15 15
fi
16 16

  
17
if [ "$SNF_IMAGE_TYPE" = "extdump" ]; then
17
if [ "$SNF_IMAGE_OS" = "linux" ]; then
18 18
    distro=$(get_base_distro $SNF_IMAGE_TARGET)
19 19

  
20 20
    if [ "$distro" = "redhat" ]; then
b/snf-image-helper/tasks/50AssignHostname.in
62 62
    log_error "Hostname is missing"
63 63
fi
64 64

  
65
if [ "$SNF_IMAGE_TYPE" = "ntfsdump" ]; then
65
if [ "$SNF_IMAGE_OS" = "windows" ]; then
66 66
    windows_hostname "$SNF_IMAGE_TARGET" "$SNF_IMAGE_HOSTNAME"
67
elif [ "$SNF_IMAGE_TYPE" = "extdump" ]; then
67
elif [ "$SNF_IMAGE_OS" = "linux" ]; then
68 68
    linux_hostname "$SNF_IMAGE_TARGET" "$SNF_IMAGE_HOSTNAME"
69 69
fi
70 70

  
b/snf-image-helper/tasks/50ChangePassword.in
66 66
    log_error "Password is missing"
67 67
fi
68 68

  
69
if [ "$SNF_IMAGE_TYPE" = "ntfsdump" ]; then
69
if [ "$SNF_IMAGE_OS" = "windows" ]; then
70 70
    windows_password "$SNF_IMAGE_TARGET" "$SNF_IMAGE_PASSWORD"
71
elif [ "$SNF_IMAGE_TYPE" = "extdump" ]; then
71
elif [ "$SNF_IMAGE_OS" = "linux" ]; then
72 72
    linux_password "$SNF_IMAGE_TARGET" "$SNF_IMAGE_PASSWORD"
73 73
fi
74 74

  

Also available in: Unified diff