rc.services 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/ash
  2. #(c) Copyright Barry Kauler Nov. 2010. License GPL v3 /usr/share/doc/legal.
  3. #101119 complete rewrite.
  4. #101121 variable delay, based on snd_ modules.
  5. #101210 new path /tmp/pup_event_backend for files logged by /sbin/pup_event_backend_*.
  6. #101121 wait for snd_ modules to complete loading...
  7. #worst case is 6 seconds. best is 2. this sleep benefits all slow peripherals.
  8. BRKCNT=1 ; GOODFLAG=0
  9. while [ $BRKCNT -lt 7 ];do
  10. sleep 1
  11. echo "BRKCNT=${BRKCNT} SNDPATTERN='${SNDPATTERN}'" >> /tmp/rc_d_rc_services_log #for debugging.
  12. BRKCNT=$(($BRKCNT + 1))
  13. [ "`find /tmp/pup_event_backend -maxdepth 1 -type f -name 'pup_event_alsa_cnt*'`" = "" ] && continue #see /sbin/pup_event_backend_modprobe
  14. SNDPATTERN="`cat /tmp/pup_event_backend/pup_event_module_devpath_log* | grep '^MODULE=snd_.*DEVPATH' | cut -f 1 -d ' ' | cut -f 2 -d '=' | sort -u | tr '\n' ' ' | sed -e 's% $%%' -e 's% %.*%g'`" #see /sbin/pup_event_backend_modprobe
  15. #ex1: SNDPATTERN=emu10k1.*maestro3 (two snd modules). ex2: SNDPATTERN=snd_hda_intel
  16. if [ "`lsmod | grep -o '^snd_[^ ]*' | sort -u | tr '\n' ' ' | grep "$SNDPATTERN"`" != "" ];then
  17. BRKCNT=$(($BRKCNT + 2))
  18. GOODFLAG=1
  19. fi
  20. done
  21. [ $GOODFLAG -eq 1 ] && touch /tmp/rc_d_rc_services_alsa_ok #read by /usr/sbin/delayedrun, /etc/init.d/10alsa.
  22. for service_script in /etc/init.d/*
  23. do
  24. [ -x $service_script ] && $service_script start
  25. done
  26. unset service_script
  27. ###END###