diff options
author | Daniel Baumann <daniel@debian.org> | 2012-06-05 14:46:19 +0200 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2012-06-05 16:11:16 +0200 |
commit | c48696a0ebe9ffc938b84b921db90ac620339a52 (patch) | |
tree | 6ac85d6265f3217158ab0ac71981f1fa94af1eaa /scripts/boot/mount-http.sh | |
parent | fea4312679b6d371123296d1a5d9987419888487 (diff) | |
download | live-boot-c48696a0ebe9ffc938b84b921db90ac620339a52.tar.gz live-boot-c48696a0ebe9ffc938b84b921db90ac620339a52.zip |
Splitting out a first bunch of functions out to /live/live/boot/.
Diffstat (limited to 'scripts/boot/mount-http.sh')
-rwxr-xr-x | scripts/boot/mount-http.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/scripts/boot/mount-http.sh b/scripts/boot/mount-http.sh new file mode 100755 index 0000000..99851b9 --- /dev/null +++ b/scripts/boot/mount-http.sh @@ -0,0 +1,86 @@ +#!/bin/sh + +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} +} |