|
Harald Hoyer |
9e9f8f |
From 52c4c9484d0cdccad7d9a3cc684677e784edab53 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
9e9f8f |
From: Will Woods <wwoods@redhat.com>
|
|
Harald Hoyer |
9e9f8f |
Date: Thu, 8 Mar 2012 18:03:48 -0500
|
|
Harald Hoyer |
9e9f8f |
Subject: [PATCH] Add 'live.updates' to livenet module
|
|
Harald Hoyer |
9e9f8f |
|
|
Harald Hoyer |
9e9f8f |
live.updates allows you to specify the URL for an "updates image" that
|
|
Harald Hoyer |
9e9f8f |
should be applied to the live runtime before switch_root.
|
|
Harald Hoyer |
9e9f8f |
|
|
Harald Hoyer |
9e9f8f |
The URL can be anything supported by url-lib (http, https, ftp, possibly
|
|
Harald Hoyer |
9e9f8f |
nfs) and the image can be anything supported by img-lib (xz/gzip
|
|
Harald Hoyer |
9e9f8f |
compressed cpio/tar, uncompressed cpio/tar, filesystem image, etc.)
|
|
Harald Hoyer |
9e9f8f |
---
|
|
Harald Hoyer |
9e9f8f |
modules.d/90livenet/fetch-liveupdate.sh | 32 +++++++++++++++++++++++++++++++
|
|
Harald Hoyer |
9e9f8f |
modules.d/90livenet/module-setup.sh | 1 +
|
|
Harald Hoyer |
9e9f8f |
modules.d/90livenet/parse-livenet.sh | 12 +++++++++++-
|
|
Harald Hoyer |
9e9f8f |
3 files changed, 44 insertions(+), 1 deletion(-)
|
|
Harald Hoyer |
9e9f8f |
create mode 100755 modules.d/90livenet/fetch-liveupdate.sh
|
|
Harald Hoyer |
9e9f8f |
|
|
Harald Hoyer |
9e9f8f |
diff --git a/modules.d/90livenet/fetch-liveupdate.sh b/modules.d/90livenet/fetch-liveupdate.sh
|
|
Harald Hoyer |
9e9f8f |
new file mode 100755
|
|
Harald Hoyer |
9e9f8f |
index 0000000..8a5fdec
|
|
Harald Hoyer |
9e9f8f |
--- /dev/null
|
|
Harald Hoyer |
9e9f8f |
+++ b/modules.d/90livenet/fetch-liveupdate.sh
|
|
Harald Hoyer |
9e9f8f |
@@ -0,0 +1,32 @@
|
|
Harald Hoyer |
9e9f8f |
+#!/bin/sh
|
|
Harald Hoyer |
9e9f8f |
+# fetch-liveupdate - fetch an update image for dmsquash-live media.
|
|
Harald Hoyer |
9e9f8f |
+# this gets called by the "initqueue/online" hook for each network interface
|
|
Harald Hoyer |
9e9f8f |
+# that comes online.
|
|
Harald Hoyer |
9e9f8f |
+
|
|
Harald Hoyer |
9e9f8f |
+# no updates requested? we're not needed.
|
|
Harald Hoyer |
9e9f8f |
+[ -e /tmp/liveupdates.info ] || return 0
|
|
Harald Hoyer |
9e9f8f |
+
|
|
Harald Hoyer |
9e9f8f |
+command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
|
Harald Hoyer |
9e9f8f |
+command -v fetch_url >/dev/null || . /lib/url-lib.sh
|
|
Harald Hoyer |
9e9f8f |
+command -v unpack_img >/dev/null || . /lib/img-lib.sh
|
|
Harald Hoyer |
9e9f8f |
+
|
|
Harald Hoyer |
9e9f8f |
+read url < /tmp/liveupdates.info
|
|
Harald Hoyer |
9e9f8f |
+
|
|
Harald Hoyer |
9e9f8f |
+info "fetching live updates from $url"
|
|
Harald Hoyer |
9e9f8f |
+
|
|
Harald Hoyer |
9e9f8f |
+fetch_url "$url" /tmp/updates.img
|
|
Harald Hoyer |
9e9f8f |
+if [ $? != 0 ]; then
|
|
Harald Hoyer |
9e9f8f |
+ warn "failed to fetch update image!"
|
|
Harald Hoyer |
9e9f8f |
+ warn "url: $url"
|
|
Harald Hoyer |
9e9f8f |
+ return 1
|
|
Harald Hoyer |
9e9f8f |
+fi
|
|
Harald Hoyer |
9e9f8f |
+
|
|
Harald Hoyer |
9e9f8f |
+unpack_img /tmp/updates.img /updates.tmp.$$
|
|
Harald Hoyer |
9e9f8f |
+if [ $? != 0 ]; then
|
|
Harald Hoyer |
9e9f8f |
+ warn "failed to unpack update image!"
|
|
Harald Hoyer |
9e9f8f |
+ warn "url: $url"
|
|
Harald Hoyer |
9e9f8f |
+ return 1
|
|
Harald Hoyer |
9e9f8f |
+fi
|
|
Harald Hoyer |
9e9f8f |
+rm -rf /updates
|
|
Harald Hoyer |
9e9f8f |
+mv -f /updates.tmp.$$ /updates
|
|
Harald Hoyer |
9e9f8f |
+mv /tmp/liveupdates.info /tmp/liveupdates.done
|
|
Harald Hoyer |
9e9f8f |
diff --git a/modules.d/90livenet/module-setup.sh b/modules.d/90livenet/module-setup.sh
|
|
Harald Hoyer |
9e9f8f |
index c650ef3..2071553 100755
|
|
Harald Hoyer |
9e9f8f |
--- a/modules.d/90livenet/module-setup.sh
|
|
Harald Hoyer |
9e9f8f |
+++ b/modules.d/90livenet/module-setup.sh
|
|
Harald Hoyer |
9e9f8f |
@@ -12,6 +12,7 @@ depends() {
|
|
Harald Hoyer |
9e9f8f |
|
|
Harald Hoyer |
9e9f8f |
install() {
|
|
Harald Hoyer |
9e9f8f |
inst_hook cmdline 29 "$moddir/parse-livenet.sh"
|
|
Harald Hoyer |
9e9f8f |
+ inst_hook initqueue/online 95 "$moddir/fetch-liveupdate.sh"
|
|
Harald Hoyer |
9e9f8f |
inst "$moddir/livenetroot.sh" "/sbin/livenetroot"
|
|
Harald Hoyer |
9e9f8f |
}
|
|
Harald Hoyer |
9e9f8f |
|
|
Harald Hoyer |
9e9f8f |
diff --git a/modules.d/90livenet/parse-livenet.sh b/modules.d/90livenet/parse-livenet.sh
|
|
Harald Hoyer |
9e9f8f |
index 926dba2..3553cef 100755
|
|
Harald Hoyer |
9e9f8f |
--- a/modules.d/90livenet/parse-livenet.sh
|
|
Harald Hoyer |
9e9f8f |
+++ b/modules.d/90livenet/parse-livenet.sh
|
|
Harald Hoyer |
9e9f8f |
@@ -1,10 +1,20 @@
|
|
Harald Hoyer |
9e9f8f |
-#!/bin/bash
|
|
Harald Hoyer |
9e9f8f |
+#!/bin/sh
|
|
Harald Hoyer |
9e9f8f |
# live net images - just like live images, but specified like:
|
|
Harald Hoyer |
9e9f8f |
# root=live:[url-to-backing-file]
|
|
Harald Hoyer |
9e9f8f |
|
|
Harald Hoyer |
9e9f8f |
[ -z "$root" ] && root=$(getarg root=)
|
|
Harald Hoyer |
9e9f8f |
. /lib/url-lib.sh
|
|
Harald Hoyer |
9e9f8f |
|
|
Harald Hoyer |
9e9f8f |
+# live updates
|
|
Harald Hoyer |
9e9f8f |
+updates=$(getarg live.updates=)
|
|
Harald Hoyer |
9e9f8f |
+if [ -n "$updates" ]; then
|
|
Harald Hoyer |
9e9f8f |
+ # make sure network comes up even if we're doing a local live device
|
|
Harald Hoyer |
9e9f8f |
+ [ -z "$netroot" ] && echo "rd.neednet=1" > /etc/cmdline.d/90livenet.conf
|
|
Harald Hoyer |
9e9f8f |
+ echo "$updates" > /tmp/liveupdates.info
|
|
Harald Hoyer |
9e9f8f |
+ echo '[ -e /tmp/liveupdates.done ]' > \
|
|
Harald Hoyer |
9e9f8f |
+ $hookdir/initqueue/finished/liveupdates.sh
|
|
Harald Hoyer |
9e9f8f |
+fi
|
|
Harald Hoyer |
9e9f8f |
+
|
|
Harald Hoyer |
9e9f8f |
str_starts "$root" "live:" && liveurl="$root"
|
|
Harald Hoyer |
9e9f8f |
str_starts "$liveurl" "live:" || return
|
|
Harald Hoyer |
9e9f8f |
liveurl="${liveurl#live:}"
|