WHo would like to contribute for a little project?

Topics about the Software of Revolution Pi
Post Reply
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

WHo would like to contribute for a little project?

Post by volker »

Hi,
today I was exchanging thoughts with a customer who had a big problem: They have added some software to make it easy for their customers to change the RevPi's IP by using a web based GUI. One of the customers has used this feature and then forgot the newly entered IP address. There was no possibility for our customer to get in contact with the system because of this change and he could also not start any full IP scan in his customer's LAN because of any router's configuration. Thus he was left with telling his customer to attach an hdmi monitor and keyboard and guiding him through the system in order to restore the dhcpcd.conf file to the original IP.
Could anyone of our community contribute to this small project in order to give a "last chance obligation" in such cases? I could imagine a little agent working in the background and waiting for a special keyboard entry like "CTRL ALT R". It then would react by resetting the dhcpcd.conf to a predefined content and resetting the system. This would enable the user to simply connect any keyboard to the USB and enter the special keys to reset the IP.
Any better ideas are welcome and even more any bash code solving the problem.
Please refrain from negative comments on the customer's sw allowing his customer to get the system totally stuck in such a condition. I think by now he knows himself he would have to double warn or even prevent the user from doing so. But still there are applications where you need to allow such changes and thus take the risk. This little project is all about minimizing the risk or trying to get the system out of the unreachable condition without hdmi monitors and system knowledge.
Looking forward for your ideas and code :-)
Unser RevPi Motto: Don't just claim it - make it!
Timo
Posts: 44
Joined: 25 Jan 2017, 10:08

Re: WHo would like to contribute for a little project?

Post by Timo »

Challenge accepted Volker! ;-)

Here is my (quick and dirty) solution:
  1. Power up your RevPi and connect via SSH or directly.
  2. Copy your dhcpd.conf file as a preset:

    Code: Select all

    pi@RevPi ~ $ sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.failsafe
  3. Copy your interfaces file as preset:

    Code: Select all

    pi@RevPi ~ $ sudo cp /etc/network/interfaces /etc/network/interfaces.failsafe
  4. Download the attached zip file, extract failsafe.sh and copy it to /sbin on your RevPi
  5. Make it executable:

    Code: Select all

    sudo chmod +x /sbin/failsafe.sh
  6. Now we need to enable a global keyboard shortcut:

    Code: Select all

    pi@RevPi ~ $ sudo nano /etc/inittab
  7. Add the line "kb::kbrequest:/sbin/failsafe.sh" to the file
  8. Save and close nano (CNTRL+"X", Press "Y", Backspace)
  9. Restart the RevPi:

    Code: Select all

    pi@RevPi ~ $ sudo shutdown -r now
You can now change your network configuration.
If you screwed it up, you can reset the network configuration to your preset at any time by pressing ALT + Arrow Up with a keyboard connected to the RevPi. The keyboard shortcut is even working on the login screen - so no need for username and password.

So far there are only some small drawbacks:
  • It does only work, if you connect a keyboard directly to the pi. It does not work via SSH. (Or is it a security bonus?)
  • Shortcut works on the login screen. Better disconnect the keyboard, if you do not need it.
  • I was unable to figure out, how to use other shortcuts than the default one. In the kbd package might be some additional information related to that topic: https://manpages.debian.org/stretch/sys ... .5.en.html
  • There is currently no error handling and no security check done in the script.
Attachments
failsafe.zip
(419 Bytes) Downloaded 517 times
User avatar
volker
Posts: 1046
Joined: 09 Nov 2016, 15:41

Re: WHo would like to contribute for a little project?

Post by volker »

wow! That was quick man! Thanks for your contribution, that's how community works :-)
Unser RevPi Motto: Don't just claim it - make it!
Post Reply