Skip to content
Snippets Groups Projects
Commit 4fef2e5e authored by Nils Schneider's avatar Nils Schneider
Browse files

Merge pull request #7 from FreifunkBremen/master

gluon-autoupdater: get random number from /dev/urandom
parents 086efed4 7cdf3708
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,9 @@ BRANCH=$(uci get autoupdater.settings.branch) ...@@ -10,7 +10,9 @@ BRANCH=$(uci get autoupdater.settings.branch)
PROBABILITY=$(uci get autoupdater.${BRANCH}.probability) PROBABILITY=$(uci get autoupdater.${BRANCH}.probability)
if test "a$1" != "a-f"; then if test "a$1" != "a-f"; then
echo | awk "END{srand();exit rand() > $PROBABILITY}" # get one random byte from /dev/urandom, convert it to decimal and check
# against update_probability*255
hexdump -n1 -e '/1 "%d"' /dev/urandom | awk "{exit \$1 > $PROBABILITY * 255}"
if test $? -ne 0; then if test $? -ne 0; then
echo "No autoupdate this time. Use -f to override" echo "No autoupdate this time. Use -f to override"
exit 0 exit 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment