| Prev | 2   10     11   12   13   | Next
maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Design (https://talk.maemo.org/forumdisplay.php?f=46)
-   -   Multiple boot videos? (https://talk.maemo.org/showthread.php?t=43840)

b666m 2010-02-21 07:32

Re: Multiple boot videos?
 
ehm... this line is ONLY for generating a RANDOM number (because $RANDOM doesn't seem to work).

it makes a copy (dd) of /dev/urandom but only of the first block (count 1) and deletes the rest (2> /dev/null).
because urandom doesn't only consists of numbers - but we want a number/integer - you have to change this using the checksum (cksum).
but this checksum is way too long so we are cutting (cut) it off. (:

i'm only searching for another way of getting randomness in my script on startup.
i tried it with rn=$(date +%S) which saves only the seconds of the current timestamp in rn... but on startup date-command only counts up and doesn't show the actual time :(
so i'm only getting 1 and 2... -.-

i've been searching google for the last few hours... but i can't find anything useful...

btw: i'm awake for over 40 hours... my eyes are bloody-red... so i'll go in my bed now ^^

if somebody knows a solution for getting a random number at startup... please post :)

good night. (:

tuminoid 2010-02-21 07:44

Re: Multiple boot videos?
 
Quote:

Originally Posted by b666m (Post 539305)
i tried to launch the script on shutdown with "start on shutdown" but this doesn't work.

I think it should be
Code:

start on starting shutdown
as you can see from other event.d scripts:
Code:

grep shutdown /etc/event.d/*

rolan900d 2010-02-21 10:49

Re: Multiple boot videos?
 
Editing the first line in rvid to :

"start on starting shutdown"

made it run 3 diff. for now....

I have to go but try one more...
Look all right to me now!

Loop went like this:

1

2

5

1

2

5



Only 3 loops now

b666m 2010-02-21 16:19

Re: Multiple boot videos?
 
as far as i understand /dev/urandom gets seeded with noise from drivers during operations from the user.
so if you just startup and shutdown there are very small chances that there are any differences.

unfortunately i don't know when the entropy pool gets seeded exactly. it could be when you open any app. but it could be that it's only seeded when special things happen.

so my suggestion would be a "longer" testing of this:
1. edit /etc/event.d/rvid and change the line "start on startup" to "start on starting shutdown" and then do "chmod 777 /etc/event.d/rvid"
2. but don't startup and then shutdown your phone immediatly.
3. after startup maybe you want to open different apps. for example: surf the web with browser and things you would also do normally.
(hopefully by doing so the pool gets seeded)

if this doesn't bring any improvements i could write some additional code which saves some blocks of on shutdown /dev/urandom to a file and then seeds /dev/urandom on startup first before doing my random number generation.
(that would be a very freaky solution ^^)

one other thing you can do when you have changed to "start on starting shutdown":
open /etc/event.d/rvid and comment out the line "rn=$(dd ... )". make a new line right under this one and type "rn=$(date +%s)".
Quote:

seconds since 00:00:00, Jan 1, 1970 (a GNU extension)
Note that this value is defined by the localtime system
call.
ok... it's not 100% random but hey... chances are nearly equal for all of the x.conf to get loaded.

b666m 2010-02-21 16:41

Re: Multiple boot videos?
 
2 Attachment(s)
blubb... working... the bootvideo gets set on shutdown... here's the code:

Code:

start on starting shutdown

script

  cd /etc/hildon-welcome.d/dconfs/

  if [ -f 1.conf ]; then

    # check which file is currently used
    if [ -f *.lock ]; then
      cuf=$(ls *.lock)
      ruf=$cuf
      rm *.lock
    else
      cuf="1.lock"
      ruf=$cuf
    fi

    # determine number of files in /dconfs
    nof=$(ls *.conf | wc -l)

    while [ "$ruf" = "$cuf" ]; do

      # get "random" number lol
      rn=$(date +%s)

      # in range of 1 - nof
      let "rr = $rn % $nof + 1"

      # choose random conf
      ruf="$rr.lock"
      rf="$rr.conf"
 
    done
 
    # set file for checking which file is in use
    rb="$rr.lock"
    echo "rb $rb - rf $rf"

    # copy it over to default.conf
    cp $rf ../default.conf
    touch $rb

  fi

end script

will update the instructions with a this new file. thanks for testing again! :)

edit: instructions and attachment on page 4 updated.
and i attached the file here too. (but you could also copy & paste the code from this post ^^)

how it works:

rolan900d 2010-02-21 16:42

Re: Multiple boot videos?
 
It did indeed.
I forgot to chmod 777 the file

All is good over here...

Thanx 2 Tuminoid as well

Buddy. where you have updated it?

On page 4 it is stated that the last update was done yesterday

b666m 2010-02-21 16:45

Re: Multiple boot videos?
 
i would take "rn=$(date +%s)" instead of random number generation out of /dev/urandom.

we just need something which is different every time we look at it and it don't have to be something for strong cryptography. (:

b666m 2010-02-21 16:53

Re: Multiple boot videos?
 
Quote:

Originally Posted by rolan900d (Post 539779)
Buddy. where you have updated it?

On page 4 it is stated that the last update was done yesterday

the attachment of page 4 is updated now.
but i posted the code above.
so you could just make a new file and copy & paste it. *G*

edit:
sorry... but i have to say it... /dev/urandom is a b*tch !!! ^^

rolan900d 2010-02-21 17:06

Re: Multiple boot videos?
 
Got it!

Cheers

b666m 2010-02-21 17:08

Re: Multiple boot videos?
 
wow... that was really tricky... but like hatebreed would shout it:

a lesson lived is a lesson learned :p


| Prev | 2   10     11   12   13   | Next
All times are GMT. The time now is 12:35.

vBulletin® Version 3.8.8