echo "coping the needed files..."
+cp init mpoint/
+chmod 777 mpoint/init
+
cp run-init mpoint/bin/
chmod 777 mpoint/bin/run-init
echo "copying iscsi related files..."
-mkdir mpoint/etc/iscsi
+mkdir -p mpoint/etc/iscsi
cp iscsi/iscsid.conf mpoint/etc/iscsi/
cp iscsi/initiatorname.iscsi mpoint/etc/iscsi/
cp iscsi/tools/* mpoint/sbin/
-mkdir mpoint/modules
+mkdir -p mpoint/modules
cp modules/* mpoint/modules/
--- /dev/null
+#!/bin/sh
+
+echo "Loading, please wait..."
+
+[ -d /dev ] || mkdir -m 0755 /dev
+[ -d /root ] || mkdir -m 0700 /root
+[ -d /sys ] || mkdir /sys
+[ -d /proc ] || mkdir /proc
+[ -d /tmp ] || mkdir /tmp
+mkdir -p /var/lock
+mount -t sysfs -o nodev,noexec,nosuid none /sys
+mount -t proc -o nodev,noexec,nosuid none /proc
+
+# Note that this only becomes /dev on the real filesystem if udev's scripts
+# are used; which they will be, but it's worth pointing out
+tmpfs_size="10M"
+if [ -e /etc/udev/udev.conf ]; then
+ . /etc/udev/udev.conf
+fi
+mount -t tmpfs -o size=$tmpfs_size,mode=0755 udev /dev
+[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
+[ -e /dev/null ] || mknod /dev/null c 1 3
+> /dev/.initramfs-tools
+mkdir /dev/.initramfs
+
+# Export the dpkg architecture
+export DPKG_ARCH=
+. /conf/arch.conf
+
+# Set modprobe env
+export MODPROBE_OPTIONS="-qb"
+
+# Export relevant variables
+export ROOT=
+export ROOTDELAY=
+export ROOTFLAGS=
+export ROOTFSTYPE=
+export break=
+export init=/sbin/init
+export quiet=n
+export readonly=y
+export rootmnt=/root
+export debug=
+export panic=
+export blacklist=
+export resume_offset=
+
+# Bring in the main config
+. /conf/initramfs.conf
+for conf in conf/conf.d/*; do
+ [ -f ${conf} ] && . ${conf}
+done
+. /scripts/functions
+
+# Parse command line options
+for x in $(cat /proc/cmdline); do
+ case $x in
+ init=*)
+ init=${x#init=}
+ ;;
+ root=*)
+ ROOT=${x#root=}
+ case $ROOT in
+ LABEL=*)
+ ROOT="/dev/disk/by-label/${ROOT#LABEL=}"
+ ;;
+ UUID=*)
+ ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
+ ;;
+ /dev/nfs)
+ [ -z "${BOOT}" ] && BOOT=nfs
+ ;;
+ esac
+ ;;
+ rootflags=*)
+ ROOTFLAGS="-o ${x#rootflags=}"
+ ;;
+ rootfstype=*)
+ ROOTFSTYPE="${x#rootfstype=}"
+ ;;
+ rootdelay=*)
+ ROOTDELAY="${x#rootdelay=}"
+ case ${ROOTDELAY} in
+ *[![:digit:].]*)
+ ROOTDELAY=
+ ;;
+ esac
+ ;;
+ nfsroot=*)
+ NFSROOT="${x#nfsroot=}"
+ ;;
+ ip=*)
+ IPOPTS="${x#ip=}"
+ ;;
+ boot=*)
+ BOOT=${x#boot=}
+ ;;
+ resume=*)
+ RESUME="${x#resume=}"
+ ;;
+ resume_offset=*)
+ resume_offset="${x#resume_offset=}"
+ ;;
+ noresume)
+ noresume=y
+ ;;
+ panic=*)
+ panic="${x#panic=}"
+ case ${panic} in
+ *[![:digit:].]*)
+ panic=
+ ;;
+ esac
+ ;;
+ quiet)
+ quiet=y
+ ;;
+ ro)
+ readonly=y
+ ;;
+ rw)
+ readonly=n
+ ;;
+ debug)
+ debug=y
+ quiet=n
+ exec >/dev/.initramfs/initramfs.debug 2>&1
+ set -x
+ ;;
+ debug=*)
+ debug=y
+ quiet=n
+ set -x
+ ;;
+ break=*)
+ break=${x#break=}
+ ;;
+ break)
+ break=premount
+ ;;
+ blacklist=*)
+ blacklist=${x#blacklist=}
+ ;;
+ esac
+done
+
+if [ -z "${noresume}" ]; then
+ export resume=${RESUME}
+else
+ export noresume
+fi
+
+depmod -a
+maybe_break top
+
+# Don't do log messages here to avoid confusing usplash
+run_scripts /scripts/init-top
+
+maybe_break modules
+log_begin_msg "Loading essential drivers"
+load_modules
+log_end_msg
+
+maybe_break premount
+[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
+run_scripts /scripts/init-premount
+[ "$quiet" != "y" ] && log_end_msg
+
+maybe_break mount
+log_begin_msg "Mounting root file system"
+. /scripts/${BOOT}
+parse_numeric ${ROOT}
+maybe_break mountroot
+mountroot
+log_end_msg
+
+maybe_break bottom
+[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
+run_scripts /scripts/init-bottom
+[ "$quiet" != "y" ] && log_end_msg
+
+# Move virtual filesystems over to the real filesystem
+mount -n -o move /sys ${rootmnt}/sys
+mount -n -o move /proc ${rootmnt}/proc
+
+# Check init bootarg
+if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then
+ echo "Target filesystem doesn't have ${init}."
+ init=
+fi
+
+# Search for valid init
+if [ -z "${init}" ] ; then
+ for init in /sbin/init /etc/init /bin/init /bin/sh; do
+ if [ ! -x "${rootmnt}${init}" ]; then
+ continue
+ fi
+ break
+ done
+fi
+
+# No init on rootmount
+if [ ! -x "${rootmnt}${init}" ]; then
+ panic "No init found. Try passing init= bootarg."
+fi
+
+# don't leak too much of env - some init(8) don't clear it
+# (keep init, rootmnt)
+unset debug
+unset MODPROBE_OPTIONS
+unset DPKG_ARCH
+unset ROOTFLAGS
+unset ROOTFSTYPE
+unset ROOTDELAY
+unset ROOT
+unset blacklist
+unset break
+unset noresume
+unset panic
+unset quiet
+unset readonly
+unset resume
+unset resume_offset
+
+# temporary hack.. copying the /etc/resolv.conf file -- pravin
+cp /etc/resolv.conf ${rootmnt}/etc/resolv.conf
+
+# Chain to real filesystem
+maybe_break init
+exec run-init ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console
+panic "Could not execute run-init."
export TARGET
;;
+ iscsilabel=*)
+ ISCSILABEL="${ARGUMENT#iscsilabel=}"
+ export ISCSILABEL
+ ;;
+
+
dnsip=*)
DNSIP="${ARGUMENT#dnsip=}"
export DNSIP
{
ifconfig lo 127.0.0.1 up
ifconfig "${DEVICE}" up
- local myip=`echo ${BOOTIP} | cut -d: -f1`
- local mynm=`echo ${BOOTIP} | cut -d: -f4`
- local mygw=`echo ${BOOTIP} | cut -d: -f3`
+ local myip=`echo ${STATICIP} | cut -d: -f1`
+ local mynm=`echo ${STATICIP} | cut -d: -f4`
+ local mygw=`echo ${STATICIP} | cut -d: -f3`
echo "myip=${myip} mynm=${mynm} mygw=${mygw}"
ifconfig "${DEVICE}" "${myip}" netmask "${mynm}"
ifconfig "${DEVICE}"
add_ip_to_resolv_conf "4.2.2.2"
add_ip_to_resolv_conf "128.255.1.3"
else
- add_ip_to_resolv_conf ${DNSIP}
+ for x in $( echo "${DNS}" | sed 's/,/ /g')
+ do
+ add_ip_to_resolv_conf ${x}
+ done
fi
return 0
}
{
rc=1
-
modprobe -q af_packet # For DHCP
if [ -x /sbin/udevadm ]
udevsettle
fi
- if [ -z ${BOOTIP} ]
+ if [ -z ${STATICIP} ]
then
ipconfig ${DEVICE} | tee /netboot.config
# Adding DNS Entry
rc=1
if [ ! -z ${ISCSINAME} ]
then
- echo ${ISCSINAME} > /etc/iscsi/initiatorname.iscsi
+ echo "InitiatorName=${ISCSINAME}" > /etc/iscsi/initiatorname.iscsi
fi
dest="${mountpoint}/${LIVE_MEDIA_PATH}"
iscsiadm -m discovery -t st -p "${ISCSIFS}"
sleep 4
targetname=`iscsiadm -m node | grep "${TARGET}" | cut -d' ' -f2`
- iscsiadm -m node --targetname "${targetname}" --portal "${ISCSIFS}" --login
- export iscsidevice=/dev/disk/by-label/Debian\\x20lenny\\x2020090614-09\:11
- wait_for_device ${iscsidevice} 160
- mount -t iso9660 "${iscsidevice}" "${mountpoint}"
+ iscsiadm -m node --targetname "${targetname}" --login
+ #/bin/sh
+ if [[ -z "${ISCSILABEL}" ]]
+ then
+ export iscsidevice=/dev/disk/by-label/Debian\\x20lenny\\x2020090614-09\:11
+ else
+ export iscsidevice="/dev/disk/by-label/${ISCSILABEL}"
+ fi
+ sleep 20
+ #wait_for_device ${iscsidevice} 160
+ #mount -t iso9660 "${iscsidevice}" "${mountpoint}"
+ mount -t iso9660 /dev/disk/by-label/Debian* "${mountpoint}"
rc=${?}
sync
sleep 2
+
# rc=0
return $rc
}
rescue_break_shell ()
{
- if [ "${RESCUEBREAK}" = "Yes" ];
- then
echo "#################################################################"
echo "#### giving rescue shell, you can execute any commands here #####"
echo "#### When done, type exit, boot process will resume :-) #####"
echo "#################################################################"
- /bin/sh
+ /bin/sh -i
echo "#################################################################"
echo "#### Resuming Boot Process #####"
echo "#################################################################"
- fi
}
mountroot ()
done
fi
fi
- rescue_break_shell
+
+
+ if [ "${RESCUEBREAK}" = "Yes" ]; then
+ rescue_break_shell
+ fi
+
if [ -z "${livefs_root}" ]
then
panic "Unable to find a medium containing a live file system"
kill ${tailpid}
[ -w "${rootmnt}/var/log/" ] && cp live.log "${rootmnt}/var/log/" 2>/dev/null
}
+
return 0
}
+add_ip_to_resolv_conf ()
+{
+ if [ ! -z ${1} ]
+ then
+ echo "nameserver $1" >> /etc/resolv.conf
+ fi
+}
+
+setup_static_ip ()
+{
+ ifconfig lo 127.0.0.1 up
+ ifconfig "${DEVICE}" up
+ local myip=`echo ${STATICIP} | cut -d: -f1`
+ local mynm=`echo ${STATICIP} | cut -d: -f4`
+ local mygw=`echo ${STATICIP} | cut -d: -f3`
+ echo "myip=${myip} mynm=${mynm} mygw=${mygw}"
+ ifconfig "${DEVICE}" "${myip}" netmask "${mynm}"
+ ifconfig "${DEVICE}"
+ route add default gw "${mygw}"
+ return 0
+}
+
+setup_static_dns ()
+{
+ if [ -z ${DNSIP} ]
+ then
+ add_ip_to_resolv_conf "4.2.2.2"
+ add_ip_to_resolv_conf "128.255.1.3"
+ else
+ for x in $( echo "${DNS}" | sed 's/,/ /g')
+ do
+ add_ip_to_resolv_conf ${x}
+ done
+ fi
+ return 0
+}
+
do_netmount() {
rc=1
- echo "nameserver 4.2.2.2
- nameserver 128.255.1.3" > /etc/resolv.conf
modprobe "${MP_QUIET}" af_packet # For DHCP
/sbin/udevadm trigger
/sbin/udevadm settle
- ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config
+
+ if [ -z ${BOOTIP} ]
+ then
+ ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf | tee /netboot.config
+
+ # Adding DNS Entry
+ local ipconf_dnsip=`cat /netboot.config | grep dns0 | cut -d':' -f3 | cut -d' ' -f2`
+ if [ -z ${ipconf_dnsip}] || [ ${ipconf_dnsip} == '0.0.0.0']
+ then
+ setup_static_dns
+ else
+ add_ip_to_resolv_conf ${ipconf_dnsip}
+ fi
+ # source relevant ipconfig output
+ OLDHOSTNAME=${HOSTNAME}
+ . /tmp/net-${DEVICE}.conf
+ [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
+ export HOSTNAME
+
+ else
+ setup_static_ip
+ setup_static_dns
+ fi
+
if [ "${NFSROOT}" = "auto" ]; then
NFSROOT=${ROOTSERVER}:${ROOTPATH}
[ "$quiet" != "y" ] && log_end_msg
- echo "Giving rescue shell.... type exit when finished"
- /bin/bash
return ${rc}
}
{
rc=1
- echo "inside iscsimount"
+ echo "inside iscsimount" >> /mylogs
insmod /modules/libcrc32c.ko
insmod /modules/crc32c.ko
sleep 4
targetname=`iscsiadm -m node | grep "${TARGET}" | cut -d' ' -f2`
iscsiadm -m node --targetname "${targetname}" --portal "${ISCSIFS}" --login
-# dmesg > /messages
+ dmesg >> /mylogs
sync
i=0
# iscsiadm -m session -P 3 | grep "attached scsi disk"
# Mount the ISO.
rc=1
-# ifconfig lo 127.0.0.1 up
-# ifconfig eth0 up
-# echo "The ip configuration is $ip"
-# myip=`echo $ip | cut -d: -f1`
-# echo "Using ip address $myip"
-# mynm=`echo $ip | cut -d: -f4`
-# echo "Using Netmask $mynm"
-# mygw=`echo $ip | cut -d: -f3`
-# echo "Using gateway ip $mygw"
-# ifconfig eth0 $myip netmask $mynm 2> /output
-# echo "verify the ip address"
-# ifconfig eth0
-
-# echo "setting route"
-# route add default gw $mygw 2> /outputroute
-
-
-
-
echo "passed on path is ${HTTPFS}" >> status
ISO_PATH="${HTTPFS}"
echo "The location of ubuntu iso is $ISO_PATH" >> /output
losetup -r /dev/loop0 $FILEPATH
mount -t iso9660 $FILEPATH "${mountpoint}" -o loop -o ro
fi
-# /bin/bash
-
# test if knoppix is there
if test -d /cdrom/casper
fi
}
+rescue_break_shell ()
+{
+ if [ "${RESCUEBREAK}" = "Yes" ];
+ then
+ echo "#################################################################"
+ echo "#### giving rescue shell, you can execute any commands here #####"
+ echo "#### When done, type exit, boot process will resume :-) #####"
+ echo "#################################################################"
+ /bin/sh -i
+ echo "#################################################################"
+ echo "#### Resuming Boot Process #####"
+ echo "#################################################################"
+ fi
+}
+
mountroot() {
exec 6>&1
exec 7>&2
fi
if [ "${RESCUEBREAK}" = "Yes" ]; then
- echo "#################################################################"
- echo "#### giving rescue shell, you can execute any commands here #####"
- echo "#### When done, type exit, boot process will resume :-) #####"
- echo "#################################################################"
- /bin/sh
+ rescue_break_shell
fi
+
if [ -z "${livefs_root}" ]; then
panic "Unable to find a medium containing a live file system"
fi
gunzip initrd.gz
echo "extracting filesystem filesystem"
-mkdir mpoint
+mkdir -p mpoint
cd mpoint
cpio -ivu --no-absolute-filename < ../initrd 2> /dev/null
cd ..
chmod 0777 mpoint/scripts/casper
echo "copying iscsi related files..."
-mkdir mpoint/etc/iscsi
+mkdir -p mpoint/etc/iscsi
cp iscsi/iscsid.conf mpoint/etc/iscsi/
cp iscsi/initiatorname.iscsi mpoint/etc/iscsi/
cp iscsi/tools/* mpoint/sbin/
cp fdisk mpoint/sbin/
-mkdir mpoint/modules
+mkdir -p mpoint/modules
cp modules/* mpoint/modules/
sudo chown -R root.root mpoint
unset debug
fi
-#rm /root/etc/rc3.d/S50NetworkManager
-#rm /root/etc/rc5.d/S50NetworkManager
-#rm /root/etc/rc5.d/S50NetworkManager
-#mv /root/etc/init.d/networking /root/etc/init.d/dnetworking
-#mv /root/etc/init.d/gdm /root/etc/init.d/dgdm
-rm /root/etc/init.d/NetworkManager
-rm /root/etc/init.d/networking
+# moving Network mangager related scripts so that they will not get executed
+# these scripts do have sucidal tendency of tearing down the network
+# thats why disabling them -- pravin
+mv /root/etc/init.d/NetworkManager /root/etc/init.d/d_NetworkManager
+mv /root/etc/init.d/networking /root/etc/init.d/d_networking
+
+# Modifying rc.local so that network manager scripts can be restored back.
+echo "#!/bin/sh -e
+# rc.local
+mv /etc/init.d/d_NetworkManager /etc/init.d/NetworkManager
+mv /etc/init.d/d_networking /etc/init.d/networking
+exit 0
+" > /root/etc/rc.local
+
+# because of some reasons, I dont understand, resolv.conf is not being set
+# that is why I am copying this manually into actual filesystem. -- pravin
+cp /etc/resolv.conf /root/etc/resolv.conf
+
#/bin/sh
# Chain to real filesystem
It uses iscsi for booting
ENDTEXT
kernel live/ubuntu/U9/vmlinuz
- append initrd=live/ubuntu/U9/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper netboot=http iscsifs=P_ISCSI_LOCATION_LOCAL target=ubuntu
+ append initrd=live/ubuntu/U9/initrd.gz file=/cdrom/preseed/ubuntu.seed boot=casper netboot=iscsi iscsifs=P_ISCSI_LOCATION_LOCAL target=ubuntu
IPAPPEND 3