Bring overlay controls into line with other nonint getters

This commit is contained in:
Simon Long 2022-01-18 18:40:59 +00:00
parent 162022b284
commit 64d6b4c11d

View File

@ -2430,23 +2430,26 @@ do_apply_os_config() {
get_overlay_now() { get_overlay_now() {
grep -q "boot=overlay" /proc/cmdline grep -q "boot=overlay" /proc/cmdline
echo $?
} }
get_overlay_conf() { get_overlay_conf() {
grep -q "boot=overlay" /boot/cmdline.txt grep -q "boot=overlay" /boot/cmdline.txt
echo $?
} }
get_bootro_now() { get_bootro_now() {
findmnt /boot | grep -q " ro," findmnt /boot | grep -q " ro,"
echo $?
} }
get_bootro_conf() { get_bootro_conf() {
grep /boot /etc/fstab | grep -q "defaults.*,ro " grep /boot /etc/fstab | grep -q "defaults.*,ro "
echo $?
} }
is_uname_current() { is_uname_current() {
test -d "/lib/modules/$(uname -r)" test -d "/lib/modules/$(uname -r)"
return $?
} }
enable_overlayfs() { enable_overlayfs() {
@ -2454,7 +2457,7 @@ enable_overlayfs() {
INITRD=initrd.img-"$KERN"-overlay INITRD=initrd.img-"$KERN"-overlay
# mount the boot partition as writable if it isn't already # mount the boot partition as writable if it isn't already
if get_bootro_now ; then if [ $(get_bootro_now) -eq 0 ] ; then
if ! mount -o remount,rw /boot 2>/dev/null ; then if ! mount -o remount,rw /boot 2>/dev/null ; then
echo "Unable to mount boot partition as writable - cannot enable" echo "Unable to mount boot partition as writable - cannot enable"
return 1 return 1
@ -2551,7 +2554,7 @@ EOF
disable_overlayfs() { disable_overlayfs() {
KERN=$(uname -r) KERN=$(uname -r)
# mount the boot partition as writable if it isn't already # mount the boot partition as writable if it isn't already
if get_bootro_now ; then if [ $(get_bootro_now) -eq 0 ] ; then
if ! mount -o remount,rw /boot 2>/dev/null ; then if ! mount -o remount,rw /boot 2>/dev/null ; then
echo "Unable to mount boot partition as writable - cannot disable" echo "Unable to mount boot partition as writable - cannot disable"
return 1 return 1
@ -2576,7 +2579,7 @@ disable_overlayfs() {
} }
enable_bootro() { enable_bootro() {
if get_overlay_now ; then if [ $(get_overlay_now) -eq 0 ] ; then
echo "Overlay in use; cannot update fstab" echo "Overlay in use; cannot update fstab"
return 1 return 1
fi fi
@ -2584,7 +2587,7 @@ enable_bootro() {
} }
disable_bootro() { disable_bootro() {
if get_overlay_now ; then if [ $(get_overlay_now) -eq 0 ] ; then
echo "Overlay in use; cannot update fstab" echo "Overlay in use; cannot update fstab"
return 1 return 1
fi fi
@ -2601,7 +2604,7 @@ do_overlayfs() {
return 1 return 1
fi fi
if get_overlay_conf; then if [ $(get_overlay_conf) -eq 0 ] ; then
DEFAULT= DEFAULT=
CURRENT=1 CURRENT=1
STATUS="enabled" STATUS="enabled"
@ -2634,8 +2637,8 @@ do_overlayfs() {
if [ "$INTERACTIVE" = True ]; then if [ "$INTERACTIVE" = True ]; then
whiptail --msgbox "The overlay file system is $STATUS." 20 60 1 whiptail --msgbox "The overlay file system is $STATUS." 20 60 1
fi fi
if get_overlay_now ; then if [ $(get_overlay_now) -eq 0 ] ; then
if get_bootro_conf; then if [ $(get_bootro_conf) -eq 0 ] ; then
BPRO="read-only" BPRO="read-only"
else else
BPRO="writable" BPRO="writable"
@ -2645,7 +2648,7 @@ do_overlayfs() {
DEFAULT=--defaultno DEFAULT=--defaultno
CURRENT=0 CURRENT=0
STATUS="writable" STATUS="writable"
if get_bootro_conf; then if [ $(get_bootro_conf) -eq 0 ]; then
DEFAULT= DEFAULT=
CURRENT=1 CURRENT=1
STATUS="read-only" STATUS="read-only"