]> code.delx.au - monosys/commitdiff
sync-boot-mirror for non-mdadm redundant booting
authorJames Bunton <jamesbunton@delx.net.au>
Fri, 1 May 2015 23:51:57 +0000 (09:51 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Fri, 1 May 2015 23:51:57 +0000 (09:51 +1000)
scripts/sync-boot-mirror [new file with mode: 0755]

diff --git a/scripts/sync-boot-mirror b/scripts/sync-boot-mirror
new file mode 100755 (executable)
index 0000000..3ab7d56
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+rsync -a --exclude=lost+found --delete /boot/ /boot-mirror/
+
+function get_uuid {
+    eval $(grep "$1 " /etc/fstab | cut -d ' ' -f1)
+    echo "$UUID"
+}
+
+# Replace UUIDs so it can actually boot!
+sed -i "s/$(get_uuid /boot)/$(get_uuid /boot-mirror)/g" \
+    $(find /boot-mirror/grub/ -name '*.cfg')
+