ia64/xen-unstable

view tools/domain_builder/mynewdom @ 386:49c0cdb50376

bitkeeper revision 1.184.1.1 (3ea6af80NfieJpdXAH_E9VdoYOKtXQ)

fixed broken symlink creation
author jws@cairnwell.research
date Wed Apr 23 15:21:36 2003 +0000 (2003-04-23)
parents 6cb457415689
children c6258eb58cde
line source
1 #!/bin/sh
3 # mynewdom <size> <extra args>
5 SIZE=${1:?"size missing"}
7 SITE_NFS=128.232.32.20
8 SITE_GW=128.232.32.1
9 SITE_MASK=255.255.240.0
11 shift;
13 ARGS="$*"
15 IMAGE=../../../xenolinux-2.4.21-pre4/arch/xeno/boot/image
18 LASTDOM=`/bin/ls /proc/xeno/ | grep -v cmd | cut -c4- | sort -rn | head -1`
19 DOM=$[LASTDOM+1]
21 echo Domain ${DOM} looks free
23 ADDR=`/sbin/ifconfig eth0 | grep inet.addr | sed -e 's/.*inet addr:\([0-9.]*\) .*/\1/'`
24 LO=`echo $ADDR | sed -e 's/[0-9]\+\.[0-9]\+\.[0-9]\+\.\([0-9]\+\)/\1/'`
25 HI=`echo $ADDR | sed -e 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/'`
26 NEWADDR=$HI.$[LO+DOM]
28 NEWNAME=$NEWADDR
29 LOOKUP=`host $NEWADDR`
30 echo $LOOKUP | grep 'domain name pointer' && NEWNAME=`echo $LOOKUP | sed -e 's!.*domain name pointer \([^ ]\+\).$!\1!'`
31 echo New IP address : ${NEWADDR} name : ${NEWNAME}
33 #SITE_GW=`netstat -rn|while read a b c;do case "$a" in 0.0.0.0)echo "$b";;esac;done`
34 NEWNAME=''
35 #${NEWADDR}
36 IP_CONFIG="ip=${NEWADDR}:${SITE_NFS}:${SITE_GW}:${SITE_MASK}:${NEWNAME}:eth0:off"
37 echo IP_CONFIG : ${IP_CONFIG}
39 CMDLINE=`cat /proc/cmdline`
40 case $CMDLINE in
41 *root=/dev/nfs*)
42 ROOT_DIR=`echo $CMDLINE | sed -e 's,.*nfsroot=\([^ ]*\).*,\1,'`
43 ROOT_PATH=`echo $ROOT_DIR | sed -e 's!^\(.*\)[0-9]\+$!\1!'`
44 ROOT_NUM=`echo $ROOT_DIR | sed -e 's!^.*\([0-9]\+\)$!\1!'`
45 NEWROOT_DEV="root=/dev/nfs nfsroot=${ROOT_PATH}$[ROOT_NUM+DOM]"
46 ;;
47 *root=/dev/[hs]d[abcd][0-9]*|*root=/dev/x[hs]d[abcd][0-9]*)
48 ROOT_DEV=`echo $CMDLINE | sed -e 's!^.*root=\(/dev/[x]*[hs]da[0-9]\+\).*$!\1!'`
49 ROOT_DISK=`echo $ROOT_DEV | sed -e 's!\(/dev/[x]\?[hs]d[a-z]\)[0-9]\+!\1!'`
50 ROOT_PART=`echo $ROOT_DEV | sed -e 's!/dev/[x]\?[hs]d[a-z]\([0-9]\+\)!\1!'`
51 NEWROOT_DEV="root=${ROOT_DISK}$[ROOT_PART+DOM] ro"
52 ;;
53 *)
54 echo Could not determine root from /proc/cmdline
55 exit
56 ;;
57 esac
59 echo New root arguments : ${NEWROOT_DEV}
61 echo ./newdom ${SIZE} ${IMAGE} ${NEWADDR} ${IP_CONFIG} ${NEWROOT_DEV} ${EXTRA_ARGS}
63 ./newdom ${SIZE} ${IMAGE} ${NEWADDR} ${IP_CONFIG} ${NEWROOT_DEV} ${EXTRA_ARGS}