summaryrefslogtreecommitdiffstats
path: root/src/boot-env/pbs/rootfs/bin/handleEvents
blob: 9bb7895107836589d4862a5cc27fd817b480e9d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/hush

# wait for lock
while [ -f /tmp/bbinit.lock ]
do 
 sleep 0.1
done

# lock eventhandler
touch /tmp/bbinit.lock

# source list of finished events
[ -f /tmp/events ] && . /tmp/events

# go through all unhandled events
for f in $( ls -1 /etc/events.d/ )
do 
  .  /etc/events.d/$f

  # check dependencies
  eval dep=\$${f}_depends
  havealldeps=1
  for d in $dep
  do
    eval havedep=\$have${d}
    [ "x$havedep" == "x1" ] || havealldeps=0
  done

  # if nothing is missing execute script
  if [ "x$havealldeps" == "x1" ]; then
    echo executing $f
    /etc/bbinit.d/$f & 
    rm /etc/events.d/$f
  fi 
done

# unlock eventhandler
rm /tmp/bbinit.lock