Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset button - factory reset #172

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Conversation

njkeng
Copy link

@njkeng njkeng commented Mar 11, 2018

Hi Bill,
RE Issue #156
I'm putting together this branch to implement a "factory reset" for RaspAP using a physical push button. The reset function simply restores the default RaspAP configuration files.
I need to develop this functionality for my own purposes, but I'm keen to contribute it back to the community. Let me know what you think about the idea.
My changes are not yet complete. I have opened this pull request early to give us a means of communicating about this branch.
So far, I have implemented the reset shell script and the changes necessary to common.sh auto installer. I am still working on the push button implementation, but I have some good information on implementing this without installing any dependencies. Should be good to go in another day or two.
Nathan.

Original page extends a long way to the right on mobile devices.  This
re-format contains the same data and controls, but narrows the size of
the display.  The page now displays on mobile devices with no need for
scrolling to the right.
The reset script restores the default RaspAP configuration files.
Basically this is a "factory reset" for the device. This script is to be
triggered using a physical push button.
@DecryptingElectrons
Copy link

I love the idea.
Haven't looked at the code yet.
An addition I thought off would be that the reset button could get the default configuration from a file so that the user could decide the settings it "resets" too

@njkeng
Copy link
Author

njkeng commented Mar 13, 2018

Getting there. I have tested the code for the reset functions from the command line. All is OK. Next, I will implement your idea about selecting which settings are used for the reset. I intend to tackle this by taking a snapshot of the current files: dhcpcd.conf dnsmasq.conf and hostapd.conf. The reset function can simply copy these into place. I'm going to add a simple control that allow the user to take this snapshot. I'll also put in some sort of selection to record if the user wants to use the snapshot or the RaspAP defaults upon reset.
A bit more about the reset button itself. I have coded the reset button (just one button) to implement three functions:
A short press reboots the Pi (> 2 seconds)
A longer press shuts down the Pi (>6 seconds)
A very long press performs the reset of the settings and then reboots the pi (>15 seconds)
I'm indicating which time period the sequence is in using different flash rates on an LED connected to GPIO. Just remembered that I can take over the power LED on the raspberry Pi main board. I can make it duplicate these flash functions. I should implement this.
After that, I need to test it all with a clean Raspbian and the quick installer. Finally, I'll update the documentation.

@njkeng
Copy link
Author

njkeng commented Mar 13, 2018

The power LED thing only works on early Pi versions. It won't work on Pi 3 or Pi Zero, so I won't be implementing that.

@TanerYavuzCybercom
Copy link

Hi! Great idea, just what is needed for me.
So the reset would change back everything to the same IP and login credentials? of course depending on which config file that is chosen that you guys mentioned previously

Added functions to save current RaspAP settings as "User" defaults.
Added a selection for RaspAP factory reset to use User defaults or
RaspAP defaults.
Changed the sed regex delimiting character from a / to a ?
The script substitutes a string $raspap_dir.  This string can be changed
and it will not be escaped. It is not possible to escape the string
without the use of additional regex. So, the sed regex delimiting
character has been changed to eliminate the need for escaping.
@njkeng
Copy link
Author

njkeng commented Mar 20, 2018

Saving user-defined data for factory reset was more involved than I had anticipated. Completed now though.
I have now tested everything from the command line and the browser. For the final step, I need to run an end-to-end test with the quick installer and see if anything breaks.

Commands to set interface up or down used ifconfig to check if interface
was already up or down. The rest of the page uses "ip s a".  The results
of these two checks sometimes conflict.  As ifconfig is now obsolete
(refer https://linux.die.net/man/8/ifconfig), script has been edited so
that everything uses the "ip s a" check.
Warnings that the interface was already up/down were output in plain
text.  Edited to output these warnings as status->messages.
Refresh button was using javascript to reload the identical page.  This
had the consequence of re-submitting the form as well, including Start
and Stop commands.  Replaced the javascript reload with a link back to
the dashboard page. Used a button class id that has a nifty reload
symbol.
Page was attempting to both change the status of the interface and check
the status of the interface on the same page load.  This is not
possible.  Added a javascript timed page refresh after an interface
state change so that the interface status can be correctly displayed.
Intitialisation was not putting quotes around string data.  All
subsequent writes were inserting quotes. Formatting is now consistent.
Full write-up including images
Changed all links back to billz repository
@njkeng
Copy link
Author

njkeng commented Apr 8, 2018

Everything is done. I have tested all changes on fresh Raspbian installations and installing RaspAP using the quick installer. I did testing on Raspberry Pi model B+ and Pi Zero W. Both were using fresh installations of Raspbian Stretch. I've updated the Readme, so check that out for instructions on how to use the button. I have also made a YouTube clip showing how to operate the system.
Over to you.

@DecryptingElectrons
Copy link

I'm no expert when it comes to the git system..... Was this merged to the main branch yet?

@njkeng
Copy link
Author

njkeng commented May 25, 2018

Hasn't been merged yet. Hopefully it can still be merged without conflicts.
If you want or need to use the code you could fork the whole project and perform the merge yourself. Once the change is officially merged into raspap you could drop your own project and go back to the official project.

@njkeng
Copy link
Author

njkeng commented Nov 12, 2018

Guys, I made the final commit on this seven months ago.
"Is there life out there? Almost definitely, say UK scientists."

@billz billz mentioned this pull request Mar 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants