Added rootfs-size sanity check

* Module will now check the total size of the active root filesystem
* - This is done to catch and prevent instances of double-extroot migration
pull/46/head
jrwimmer 2021-12-20 20:32:06 -08:00
parent 1a78065764
commit 0ed9bc94fb
No known key found for this signature in database
GPG Key ID: A62B2B67E6233F10
1 changed files with 28 additions and 4 deletions

View File

@ -32,12 +32,37 @@ function configure {
$DIALOG_OK) $DIALOG_OK)
perform_migration;; perform_migration;;
$DIALOG_CANCEL) $DIALOG_CANCEL)
dialog --title "Extroot" --msgbox "Operation cancelled" 14 72;; dialog --title "Extroot" --msgbox "Operation cancelled" 14 72
exit 0;;
$DIALOG_ESC) $DIALOG_ESC)
dialog --title "Extroot" --msgbox "Operation cancelled" 14 72;; dialog --title "Extroot" --msgbox "Operation cancelled" 14 72
exit 0;;
esac esac
} }
function check_space {
# Get block size for the root partition
rootfs_blocksize=$(df -P / | awk '{print $2}' | tail -n+2)
rootfs_humansize=$(df -h / | awk '{print $2}' | tail -n+2)
# Check if the root partition is larger than 256 MB
if (( $rootfs_blocksize > 256000 )); then
dialog --title "Extroot: WARNING" --defaultno --yesno "::: WARNING :::\n\n\nThe root partition appears to be larger than 256MB in size (Seen: $rootfs_humansize)\n\nThis may indicate that the overlay configuration process has already been performed on this installation.\n\nAre you sure you wish to continue?" 14 72
return=$?
case $return in
$DIALOG_OK)
return 0;;
$DIALOG_CANCEL)
dialog --title "Extroot" --msgbox "Operation cancelled" 14 72
exit 0;;
$DIALOG_ESC)
dialog --title "Extroot" --msgbox "Operation cancelled" 14 72
exit 0;;
esac
fi
}
function check_network { function check_network {
# Check for Internet connection by attempting to contact an opkg repository server # Check for Internet connection by attempting to contact an opkg repository server
@ -68,8 +93,6 @@ function install_dependencies {
} }
function remount_rootfsdata { function remount_rootfsdata {
#TODO: Add sanity check for the overlay having already been migrated
# Identify flash memory device containing current overlay # Identify flash memory device containing current overlay
rootfsdata_dev="$(sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab)" rootfsdata_dev="$(sed -n -e "/\s\/overlay\s.*$/s///p" /etc/mtab)"
@ -183,6 +206,7 @@ function perform_step {
} }
function perform_migration { function perform_migration {
check_space
perform_step "check_network" "Checking network connectivity" perform_step "check_network" "Checking network connectivity"