[SCM] live-boot branch, debian-next, updated. debian/3.0_a28-1-4-g8cadb3d
Daniel Baumann
daniel at debian.org
Tue Jun 5 12:46:20 UTC 2012
The following commit has been merged in the debian-next branch:
commit 8cadb3d81e1f40958872715e4d7ca82b9a96d59b
Author: Daniel Baumann <daniel at debian.org>
Date: Tue Jun 5 14:46:19 2012 +0200
Splitting out a first bunch of functions out from /lib/live/boot.sh to /live/live/boot/.
diff --git a/Makefile b/Makefile
index e2f6cde..fc048e7 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ SHELL := sh -e
LANGUAGES = $(shell cd manpages/po && ls)
-SCRIPTS = bin/* initramfs-tools/hooks/* initramfs-tools/scripts/live initramfs-tools/scripts/live-functions initramfs-tools/scripts/live-helpers initramfs-tools/scripts/*/* scripts/*
+SCRIPTS = bin/* initramfs-tools/hooks/* initramfs-tools/scripts/live initramfs-tools/scripts/live-functions initramfs-tools/scripts/live-helpers initramfs-tools/scripts/*/* scripts/* scripts/*/*
all: build
@@ -43,7 +43,7 @@ build:
install:
# Installing scripts
mkdir -p $(DESTDIR)/lib/live
- cp -r scripts/boot.sh $(DESTDIR)/lib/live
+ cp -r scripts/boot.sh boot $(DESTDIR)/lib/live
# Installing executables
mkdir -p $(DESTDIR)/sbin
diff --git a/scripts/boot.sh b/scripts/boot.sh
index 83114a2..eed8fa9 100755
--- a/scripts/boot.sh
+++ b/scripts/boot.sh
@@ -2,6 +2,14 @@
# set -e
+for _SCRIPT in /lib/live/boot/*
+do
+ if [ -e "${_SCRIPT}" ]
+ then
+ . ${_SCRIPT}
+ fi
+done
+
export PATH="/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
echo "/root/lib" >> /etc/ld.so.conf
@@ -453,189 +461,6 @@ do_netmount()
return ${rc}
}
-do_iscsi()
-{
- do_netsetup
- #modprobe ib_iser
- modprobe iscsi_tcp
- local debugopt=""
- [ "${DEBUG}" = "Yes" ] && debugopt="-d 8"
- #FIXME this name is supposed to be unique - some date + ifconfig hash?
- ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)"
- export ISCSI_INITIATORNAME
- if [ -n "${ISCSI_SERVER}" ] ; then
- iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_SERVER}" -p "${ISCSI_PORT}"
- else
- iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_PORTAL}" -p 3260
- fi
- if [ $? != 0 ]
- then
- panic "Failed to log into iscsi target"
- fi
- local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
- /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
- if [ -n "${host}" ]
- then
- local devices=""
- local i=0
- while [ -z "${devices}" -a $i -lt 60 ]
- do
- sleep 1
- devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* \
- /sys/class/scsi_device/${host}*/device/block/* | sed -e 's!.*[:/]!!')"
- i=$(expr $i + 1)
- echo -ne $i\\r
- done
- for dev in $devices
- do
- if check_dev "null" "/dev/$dev"
- then
- NETBOOT="iscsi"
- export NETBOOT
- return 0;
- fi
- done
- panic "Failed to locate a live device on iSCSI devices (tried: $devices)."
- else
- panic "Failed to locate iSCSI host in /sys"
- fi
-}
-
-do_httpmount ()
-{
- rc=1
-
- for webfile in HTTPFS FTPFS FETCH
- do
- local url="$(eval echo \"\$\{${webfile}\}\")"
- local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
-
- if [ -n "$url" ]
- then
- case "${extension}" in
- iso|squashfs|tgz|tar)
- if [ "${extension}" = "iso" ]
- then
- mkdir -p "${alt_mountpoint}"
- dest="${alt_mountpoint}"
- else
- local dest="${mountpoint}/${LIVE_MEDIA_PATH}"
- mount -t ramfs ram "${mountpoint}"
- mkdir -p "${dest}"
- fi
- if [ "${webfile}" = "FETCH" ]
- then
- case "$url" in
- tftp*)
- ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
- rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
- lfile="$(basename $url)"
- log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
- tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
- ;;
-
- *)
- log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
- wget "${url}" -O "${dest}/$(basename ${url})"
- ;;
- esac
- else
- log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
- if [ "${webfile}" = "FTPFS" ]
- then
- FUSE_MOUNT="curlftpfs"
- url="$(dirname ${url})"
- else
- FUSE_MOUNT="httpfs"
- fi
- modprobe fuse
- $FUSE_MOUNT "${url}" "${dest}"
- ROOT_PID="$(minips h -C "$FUSE_MOUNT" | { read x y ; echo "$x" ; } )"
- fi
- [ ${?} -eq 0 ] && rc=0
- [ "${extension}" = "tgz" ] && live_dest="ram"
- if [ "${extension}" = "iso" ]
- then
- isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
- mount -t iso9660 "${isoloop}" "${mountpoint}"
- rc=${?}
- fi
- break
- ;;
-
- *)
- log_begin_msg "Unrecognized archive extension for ${url}"
- ;;
- esac
- fi
- done
-
- if [ ${rc} != 0 ]
- then
- if [ -d "${alt_mountpoint}" ]
- then
- umount "${alt_mountpoint}"
- rmdir "${alt_mountpoint}"
- fi
- umount "${mountpoint}"
- elif [ "${webfile}" != "FETCH" ] ; then
- NETBOOT="${webfile}"
- export NETBOOT
- fi
-
- return ${rc}
-}
-
-do_nfsmount ()
-{
- rc=1
-
- modprobe -q nfs
-
- if [ -n "${NFSOPTS}" ]
- then
- NFSOPTS="-o ${NFSOPTS}"
- fi
-
- log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
-
- # FIXME: This while loop is an ugly HACK round an nfs bug
- i=0
- while [ "$i" -lt 60 ]
- do
- nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
- sleep 1
- i="$(($i + 1))"
- done
-
- return ${rc}
-}
-
-do_cifsmount ()
-{
- rc=1
-
- if [ -x "/sbin/mount.cifs" ]
- then
- if [ -z "${NFSOPTS}" ]
- then
- CIFSOPTS="-ouser=root,password="
- else
- CIFSOPTS="-o ${NFSOPTS}"
- fi
-
- log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
- modprobe -q cifs
-
- if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
- then
- rc=0
- fi
- fi
-
- return ${rc}
-}
-
do_snap_copy ()
{
fromdev="${1}"
diff --git a/scripts/boot/mount-cifs.sh b/scripts/boot/mount-cifs.sh
new file mode 100755
index 0000000..3481fd0
--- /dev/null
+++ b/scripts/boot/mount-cifs.sh
@@ -0,0 +1,24 @@
+do_cifsmount ()
+{
+ rc=1
+
+ if [ -x "/sbin/mount.cifs" ]
+ then
+ if [ -z "${NFSOPTS}" ]
+ then
+ CIFSOPTS="-ouser=root,password="
+ else
+ CIFSOPTS="-o ${NFSOPTS}"
+ fi
+
+ log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
+ modprobe -q cifs
+
+ if mount.cifs "${NFSROOT}" "${mountpoint}" "${CIFSOPTS}"
+ then
+ rc=0
+ fi
+ fi
+
+ return ${rc}
+}
diff --git a/scripts/boot/mount-http.sh b/scripts/boot/mount-http.sh
new file mode 100755
index 0000000..581df5d
--- /dev/null
+++ b/scripts/boot/mount-http.sh
@@ -0,0 +1,84 @@
+do_httpmount ()
+{
+ rc=1
+
+ for webfile in HTTPFS FTPFS FETCH
+ do
+ local url="$(eval echo \"\$\{${webfile}\}\")"
+ local extension="$(echo "${url}" | sed 's/\(.*\)\.\(.*\)/\2/')"
+
+ if [ -n "$url" ]
+ then
+ case "${extension}" in
+ iso|squashfs|tgz|tar)
+ if [ "${extension}" = "iso" ]
+ then
+ mkdir -p "${alt_mountpoint}"
+ dest="${alt_mountpoint}"
+ else
+ local dest="${mountpoint}/${LIVE_MEDIA_PATH}"
+ mount -t ramfs ram "${mountpoint}"
+ mkdir -p "${dest}"
+ fi
+ if [ "${webfile}" = "FETCH" ]
+ then
+ case "$url" in
+ tftp*)
+ ip="$(dirname $url | sed -e 's|tftp://||g' -e 's|/.*$||g')"
+ rfile="$(echo $url | sed -e "s|tftp://$ip||g")"
+ lfile="$(basename $url)"
+ log_begin_msg "Trying tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip"
+ tftp -g -b 10240 -r $rfile -l ${dest}/$lfile $ip
+ ;;
+
+ *)
+ log_begin_msg "Trying wget ${url} -O ${dest}/$(basename ${url})"
+ wget "${url}" -O "${dest}/$(basename ${url})"
+ ;;
+ esac
+ else
+ log_begin_msg "Trying to mount ${url} on ${dest}/$(basename ${url})"
+ if [ "${webfile}" = "FTPFS" ]
+ then
+ FUSE_MOUNT="curlftpfs"
+ url="$(dirname ${url})"
+ else
+ FUSE_MOUNT="httpfs"
+ fi
+ modprobe fuse
+ $FUSE_MOUNT "${url}" "${dest}"
+ ROOT_PID="$(minips h -C "$FUSE_MOUNT" | { read x y ; echo "$x" ; } )"
+ fi
+ [ ${?} -eq 0 ] && rc=0
+ [ "${extension}" = "tgz" ] && live_dest="ram"
+ if [ "${extension}" = "iso" ]
+ then
+ isoloop=$(setup_loop "${dest}/$(basename "${url}")" "loop" "/sys/block/loop*" "" '')
+ mount -t iso9660 "${isoloop}" "${mountpoint}"
+ rc=${?}
+ fi
+ break
+ ;;
+
+ *)
+ log_begin_msg "Unrecognized archive extension for ${url}"
+ ;;
+ esac
+ fi
+ done
+
+ if [ ${rc} != 0 ]
+ then
+ if [ -d "${alt_mountpoint}" ]
+ then
+ umount "${alt_mountpoint}"
+ rmdir "${alt_mountpoint}"
+ fi
+ umount "${mountpoint}"
+ elif [ "${webfile}" != "FETCH" ] ; then
+ NETBOOT="${webfile}"
+ export NETBOOT
+ fi
+
+ return ${rc}
+}
diff --git a/scripts/boot/mount-iscsi.sh b/scripts/boot/mount-iscsi.sh
new file mode 100755
index 0000000..f8cc439
--- /dev/null
+++ b/scripts/boot/mount-iscsi.sh
@@ -0,0 +1,47 @@
+do_iscsi()
+{
+ do_netsetup
+ #modprobe ib_iser
+ modprobe iscsi_tcp
+ local debugopt=""
+ [ "${DEBUG}" = "Yes" ] && debugopt="-d 8"
+ #FIXME this name is supposed to be unique - some date + ifconfig hash?
+ ISCSI_INITIATORNAME="iqn.1993-08.org.debian.live:01:$(echo "${HWADDR}" | sed -e s/://g)"
+ export ISCSI_INITIATORNAME
+ if [ -n "${ISCSI_SERVER}" ] ; then
+ iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_SERVER}" -p "${ISCSI_PORT}"
+ else
+ iscsistart $debugopt -i "${ISCSI_INITIATORNAME}" -t "${ISCSI_TARGET}" -g 1 -a "${ISCSI_PORTAL}" -p 3260
+ fi
+ if [ $? != 0 ]
+ then
+ panic "Failed to log into iscsi target"
+ fi
+ local host="$(ls -d /sys/class/scsi_host/host*/device/iscsi_host:host* \
+ /sys/class/scsi_host/host*/device/iscsi_host/host* | sed -e 's:/device.*::' -e 's:.*host::')"
+ if [ -n "${host}" ]
+ then
+ local devices=""
+ local i=0
+ while [ -z "${devices}" -a $i -lt 60 ]
+ do
+ sleep 1
+ devices="$(ls -d /sys/class/scsi_device/${host}*/device/block:* \
+ /sys/class/scsi_device/${host}*/device/block/* | sed -e 's!.*[:/]!!')"
+ i=$(expr $i + 1)
+ echo -ne $i\\r
+ done
+ for dev in $devices
+ do
+ if check_dev "null" "/dev/$dev"
+ then
+ NETBOOT="iscsi"
+ export NETBOOT
+ return 0;
+ fi
+ done
+ panic "Failed to locate a live device on iSCSI devices (tried: $devices)."
+ else
+ panic "Failed to locate iSCSI host in /sys"
+ fi
+}
diff --git a/scripts/boot/mount-nfs.sh b/scripts/boot/mount-nfs.sh
new file mode 100755
index 0000000..7baf634
--- /dev/null
+++ b/scripts/boot/mount-nfs.sh
@@ -0,0 +1,24 @@
+do_nfsmount ()
+{
+ rc=1
+
+ modprobe -q nfs
+
+ if [ -n "${NFSOPTS}" ]
+ then
+ NFSOPTS="-o ${NFSOPTS}"
+ fi
+
+ log_begin_msg "Trying nfsmount -o nolock -o ro ${NFSOPTS} ${NFSROOT} ${mountpoint}"
+
+ # FIXME: This while loop is an ugly HACK round an nfs bug
+ i=0
+ while [ "$i" -lt 60 ]
+ do
+ nfsmount -o nolock -o ro ${NFSOPTS} "${NFSROOT}" "${mountpoint}" && rc=0 && break
+ sleep 1
+ i="$(($i + 1))"
+ done
+
+ return ${rc}
+}
--
live-boot
More information about the debian-live-changes
mailing list