Moved network info under xen
[invirt/packages/invirt-autoinstaller.git] / common / usr / sbin / invirt-create-image
1 #!/bin/bash
2 # Usage: no command-line args.
3 # "arguments" come in environment:
4 #  TARGET a device filename
5 #  FSSIZE the desired filesystem size in mebibytes (rest will be swap)
6 #  ARCH, DIST, MIRROR
7 #  HOSTNAME, IP
8 #
9 # Optional: GATEWAY, NETMASK.  These default to values in invirt-getconf, if installed
10
11 set -e
12
13 if [ "$GATEWAY" = "" ]; then
14     GATEWAY=$(invirt-getconf xen.network.gateway)
15 fi
16
17 if [ "$NETMASK" = "" ]; then
18     NETMASK=$(invirt-getconf xen.network.netmask)
19 fi
20
21 echo ,"${FSSIZE}"$',L,*\n,,S\n;\n;' | sfdisk -uM -H 255 -S 63 "$TARGET"
22
23 dmsetup info "$TARGET" 2>/dev/null && kpartx -a "$TARGET"
24
25 xen-create-image --image-dev "${TARGET}1" --swap-dev "${TARGET}2" --fs ext3 --ide \
26  --hostname "$HOSTNAME" --ip="$IP" --netmask="$NETMASK" --gateway="$GATEWAY" \
27  --arch "$ARCH" --dist "$DIST" --mirror "$MIRROR" --cache=yes --verbose
28
29 dmsetup info "$TARGET" 2>/dev/null && kpartx -d "$TARGET"
30
31 exit 0