Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds bittorrent support for live images #26

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dracut.cmdline.7.asc
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,14 @@ of your compressed filesystem image tarball.
=====================

**root=**live:__<url>__::
Boots a live image retrieved from __<url>__. Valid handlers: __http, httpd, ftp, tftp__.
Boots a live image retrieved from __<url>__. Valid handlers: __http, https, ftp, torrent, tftp__.
+
[listing]
.Example
--
root=live:http://example.com/liveboot.img
root=live:ftp://ftp.example.com/liveboot.img
root=live:torrent://example.com/liveboot.img.torrent
--

**rd.live.debug=**1::
Expand Down
1 change: 1 addition & 0 deletions modules.d/45url-lib/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ depends() {
install() {
local _dir _crt _found _lib
inst_simple "$moddir/url-lib.sh" "/lib/url-lib.sh"
inst_multiple -o ctorrent
inst_multiple curl
# also install libs for curl https
inst_libdir_file "libnsspem.so*"
Expand Down
30 changes: 30 additions & 0 deletions modules.d/45url-lib/url-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,36 @@ set_http_header() {
echo "header = \"$1: $2\"" >> $CURL_HOME/.curlrc
}

### TORRENT ##########################################################

ctorrent_args="-E 0 -e 0"

ctorrent_fetch_url() {
local url="$1" outloc="$2"
url=${url#*//}
torrent_outloc="$outloc.torrent"
echo "$url" > /proc/self/fd/0
if [ -n "$outloc" ]; then
curl $curl_args --output - -- "$url" > "$torrent_outloc" || return $?
else
local outdir="$(mkuniqdir /tmp torrent_fetch_url)"
( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
torrent_outloc="$outdir/$(ls -A $outdir)"
outloc=${torrent_outloc%.*}
fi
if ! [ -f "$torrent_outloc" ]; then
warn "Downloading '$url' failed!"
return 253
fi
ctorrent $ctorrent_args -s $outloc $torrent_outloc >&2
if ! [ -f "$outloc" ]; then
warn "Torrent download of '$url' failed!"
return 253
fi
if [ -z "$2" ]; then echo "$outloc" ; fi
}
add_url_handler ctorrent_fetch_url torrent

### NFS ##############################################################

[ -e /lib/nfs-lib.sh ] && . /lib/nfs-lib.sh
Expand Down