aboutsummaryrefslogtreecommitdiff
path: root/tools/load_bringelle.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/load_bringelle.sh')
-rwxr-xr-xtools/load_bringelle.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/load_bringelle.sh b/tools/load_bringelle.sh
new file mode 100755
index 0000000..ad360cc
--- /dev/null
+++ b/tools/load_bringelle.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+# Ensure to abort on error
+set -e
+
+wai=$(dirname $(readlink -f "$0")) # Current script directory
+outdir="${wai}/../"
+floppy="${outdir}/floppy.img"
+mountp="$(mktemp -d)" # Mount point (where the floppy will be mounted temporally
+kernel="${outdir}/src/bringelle"
+
+check_for () {
+ command -v "$1" &>/dev/null || { echo "Command $1 not found!"; exit 1; }
+}
+
+check_for losetup
+[ ! -e "$floppy" ] && { echo "Floppy drive \"$floppy\" not found!"; exit 1; }
+[ ! -e "$kernel" ] && { echo "Kernel \"$kernel\" not found!"; exit 1; }
+
+# Initiate loop devices
+loop=$(sudo losetup -f)
+part="${loop}p1" # Disk partition
+sudo losetup -Pf $floppy
+
+# Prepare disk partition
+sudo mount $part "$mountp"
+cp $kernel $mountp/boot/bringelle.bs
+
+# Umount floppy
+sync
+sudo umount "$mountp"
+rmdir "$mountp"
+
+# Cleanup
+sudo losetup -D
+