geerlingguy / raspberry-pi-dramble

DEPRECATED - Raspberry Pi Kubernetes cluster that runs HA/HP Drupal 8
http://www.pidramble.com/
MIT License
1.67k stars 260 forks source link

microsd-benchmark.sh without sudo #86

Closed gddeen closed 7 years ago

gddeen commented 7 years ago

I hope this is right repos...

the microsd-benchmark.sh script, if invoked without sudo (That's kinda ok... just installs and iotest fail, BUT SUDO_USER is blank.

That causes getent to return every root directory for ever system ID and then go erase all of them and the last one with '/test' on the end... Kinda of an unlucky today, I am...

s-e-a-n-s commented 7 years ago

(landed here chasing the same issue) This script is referenced several places on the web, so I'd like to help make it a little more forgiving. Running the script directly as root (vs. through sudo) can wipe your SD card.

@geerlingguy - I'm going to submit a pull request with a simple if [ -z "$SUDO_USER" ]; then ....; exit 1; - this will prevent accidental 'rm -f /root ...' calls.

If this script is being more widely used, I'm happy to add a bit more, such as..

Please let me know if you have any questions/concerns/feedback.

geerlingguy commented 7 years ago

Yikes, yeah @s-e-a-n-s it sounds like that would be a very good idea.