[LEDE-DEV] [PATCH v2] base-files: ensure reset only works if an overlay exists

Rafał Miłecki zajec5 at gmail.com
Wed Oct 19 23:05:33 PDT 2016


On 20 October 2016 at 07:37, Chris Blake <chrisrblake93 at gmail.com> wrote:
> On Thu, Oct 20, 2016 at 12:29 AM, Rafał Miłecki <zajec5 at gmail.com> wrote:
>> On 20 October 2016 at 05:23, Chris Blake <chrisrblake93 at gmail.com> wrote:
>>> diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset
>>> index c6dc7cf..fab9a6c 100755
>>> --- a/package/base-files/files/etc/rc.button/reset
>>> +++ b/package/base-files/files/etc/rc.button/reset
>>> @@ -11,15 +11,16 @@ timeout)
>>>         set_state failsafe
>>>  ;;
>>>  released)
>>> -       if [ "$SEEN" -lt 1 ]
>>> +       OVERLAY="$( grep ' /overlay ' /proc/mounts )"
>>> +       if [ "$SEEN" -gt 5 -a -n "$OVERLAY" ]
>>> +       then
>>> +               echo "FACTORY RESET" > /dev/console
>>> +               jffs2reset -y && reboot &
>>> +       elif [ "$SEEN" ]
>>>         then
>>>                 echo "REBOOT" > /dev/console
>>>                 sync
>>>                 reboot
>>> -       elif [ "$SEEN" -gt 5 ]
>>> -       then
>>> -               echo "FACTORY RESET" > /dev/console
>>> -               jffs2reset -y && reboot &
>>>         fi
>>>  ;;
>>>  esac
>>
>> Before:
>> if $SEEN < 1 => reboot
>> if $SEEN > 5 => factory
>>
>> After
>> if $SEEN > 5 => factory
>> else => reboot
>>
>> Can you see that changed behavior now?
>
> Rafal,
>
> Indeed I do. If you have a better idea for implementation I am all
> ears on feedback to resolve this bug.

Don't rework this script so much, just add:
OVERLAY="$( grep ' /overlay ' /proc/mounts )"
as you did and replace:
elif [ "$SEEN" -gt 5 ]
with:
elif [ "$SEEN" -gt 5 -a -n "$OVERLAY" ]



More information about the Lede-dev mailing list