Commit c6889332 authored by Michael Shigorin's avatar Michael Shigorin Committed by Anton Midyukov

e2k: add partition check to write.sh

...otherwise a whole-disk block device would be accepted by the script but not by the firmware's bootloader. Optical media isn't to be checked for those of course.
parent a8f9b600
......@@ -10,9 +10,17 @@ usage() { error "Usage: $0 /path/to/alt-e2k.iso /dev/sdX1_or_/dev/sr0"; }
[ -s "$1" ] || usage
[ -b "$2" ] || usage
checkuid() { [ "$(id -u)" = 0 ] || error "$0: need to run as root"; }
format() { mkfs.ext2 -E packed_meta_blocks=1,num_backup_sb=1 -L altinst "$1"; }
# use a partition block device, not the whole disk one
checkpart() {
dev="${1#/dev/}"
[ -n "$dev" ] || usage
[ -f "/sys/class/block/$dev/partition" ] || usage
}
case "$2" in
/dev/sr[0-9]*|dvd*|cd*)
grep -qw "^$2" /proc/mounts && checkuid && umount -v "$2"
......@@ -21,6 +29,7 @@ case "$2" in
;;
/dev/sd*)
grep -q "^$1" /proc/mounts && error "$1 mounted already"
checkpart "$2"
checkuid
[ "$(blkid -o value -s LABEL "$2")" = "altinst" ] || format "$2"
src="$(mktemp -d)"
......@@ -37,6 +46,7 @@ case "$2" in
sed -i 's,default=.*$,&_flash,' "$dst/boot.conf"
echo "done"
}
echo -n "unmounting media... "
umount "$src" "$dst"
echo "done."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment