Commit c3ac02bb authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

Better handling of overlayroot fs enable / disable

parent 278dc94d
...@@ -243,9 +243,13 @@ while true; do ...@@ -243,9 +243,13 @@ while true; do
fi fi
[[ $(apt-cache search --names-only '^linux-'$(lsb_release -cs)'-root.*.'$BOARD'' | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' \ [[ $(apt-cache search --names-only '^linux-'$(lsb_release -cs)'-root.*.'$BOARD'' | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' \
| wc -l) -gt 1 ]] && LIST+=( "Switch" "Switch to alternative kernels" ) | wc -l) -gt 1 ]] && LIST+=( "Switch" "Switch to alternative kernels" )
[[ "$DISTRO" == "Ubuntu" && "$(modinfo overlay > /dev/null 2>&1; echo $?)" == "0" ]] && \ if [[ "$DISTRO" == "Ubuntu" && "$(modinfo overlay > /dev/null 2>&1; echo $?)" == "0" ]]; then
LIST+=( "Overlayroot" "Toggle virtual read-only root filesystem" ) if [ -n "$(mount | grep -w tmpfs-root)" ]; then
LIST+=( "Overlayroot" "Disable virtual read-only root filesystem" )
else
LIST+=( "Overlayroot" "Enable virtual read-only root filesystem" )
fi
fi
# count number of menu items to adjust window sizee # count number of menu items to adjust window sizee
LISTLENGHT="$((7+${#LIST[@]}/2))" LISTLENGHT="$((7+${#LIST[@]}/2))"
BOXLENGHT=${#LIST[@]} BOXLENGHT=${#LIST[@]}
...@@ -394,11 +398,11 @@ while true; do ...@@ -394,11 +398,11 @@ while true; do
--no-label "Cancel" \ --no-label "Cancel" \
--yesno "\nYour system is already virtual read-only.\n\nDo you want to disable this feature and reboot?" 9 60 --yesno "\nYour system is already virtual read-only.\n\nDo you want to disable this feature and reboot?" 9 60
[[ $? = 0 ]] && overlayroot-chroot sed -i "s/^overlayroot=.*/overlayroot=\"\"/" /etc/overlayroot.conf && \ [[ $? = 0 ]] && overlayroot-chroot sed -i "s/^overlayroot=.*/overlayroot=\"\"/" /etc/overlayroot.conf && \
rm /etc/update-motd.d/97-overlayroot && reboot overlayroot-chroot rm /etc/update-motd.d/97-overlayroot && reboot
else else
debconf-apt-progress -- apt-get -y --no-install-recommends install overlayroot debconf-apt-progress -- apt-get -y --no-install-recommends install overlayroot
echo '#!/bin/bash' > /etc/update-motd.d/97-overlayroot echo '#!/bin/bash' > /etc/update-motd.d/97-overlayroot
echo 'echo -e "[\e[0m \e[1mremember: root is in virtual read only mode\e[0m ]\n"' >> /etc/update-motd.d/97-overlayroot echo 'if [ -n "$(mount | grep -w tmpfs-root)" ]; then echo -e "[\e[0m \e[1mremember: root is in virtual read only mode\e[0m ]";fi' >> /etc/update-motd.d/97-overlayroot
dialog --title "Root overlay" --backtitle "$BACKTITLE" --yes-label "Reboot" \ dialog --title "Root overlay" --backtitle "$BACKTITLE" --yes-label "Reboot" \
--no-label "Cancel" --yesno "\nEnable virtual read-only root and reboot." 7 45 --no-label "Cancel" --yesno "\nEnable virtual read-only root and reboot." 7 45
[[ $? = 0 ]] && sed -i "s/^overlayroot=.*/overlayroot=\"tmpfs\"/" /etc/overlayroot.conf && reboot [[ $? = 0 ]] && sed -i "s/^overlayroot=.*/overlayroot=\"tmpfs\"/" /etc/overlayroot.conf && reboot
......
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