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

fix: simplify and fix pwnagotchi-launcher logic #477

Closed

Conversation

neutralinsomniac
Copy link
Contributor

@neutralinsomniac neutralinsomniac commented Oct 30, 2019

Signed-off-by: Jeremy O'Brien neutral@fastmail.com

Self-explanatory

Description

It appears as though the launcher is broken right now. pi0 is always booting into manual mode regardless of network state.

Motivation and Context

It looks like the line that checks for a carrier on eth0 (for pi{1,2,3,4}) will evaluate to the same result as detecting a carrier when the interface doesn't exist (like on the pi0). By inverting the logic, we enter auto mode in both the case where the interface is present without a carrier (grep failure) and when the interface isn't present at all (grep failure).

I also simplified the logic flow a little to avoid nested if's.

How Has This Been Tested?

maxxer on slack tested by observing that the pi0 always boots into manual mode without this change, but properly boots into auto mode when appropriate when this change is applied.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s

@neutralinsomniac neutralinsomniac changed the title fix: only check for carrier on eth0 if eth0 exists fix: simplify and fix pwnagotchi-launcher logic Oct 30, 2019
@dipsylala
Copy link
Contributor

Good catch, @maxxer - to expand the comment:

Exit Status:
Normally, the exit status is 0 if selected lines are found and 1 otherwise. But the exit status is 2 if an error occurred, unless the -q or --quiet or --silent option is used and a selected line is found.

An explicit -eq 1 might be the way to go so we know there's no error (raised if the interface doesn't exist/isn't up), and no carrier (0). It's also a more explicit coding style too, which can't hurt.

@evilsocket
Copy link
Owner

let me know when this can be merged

Signed-off-by: Jeremy O'Brien <neutral@fastmail.com>
@evilsocket
Copy link
Owner

closed with 1306487

@evilsocket evilsocket closed this Oct 31, 2019
@neutralinsomniac neutralinsomniac deleted the fix_launcher branch October 31, 2019 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants