bootstrap.sh 645 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # bootstrap clam av service and clam av database updater shell script
  3. # presented by mko (Markus Kosmal<code@cnfg.io>)
  4. set -m
  5. # start clam service itself and the updater in background as daemon
  6. freshclam -d &
  7. clamd &
  8. # recognize PIDs
  9. pidlist=`jobs -p`
  10. # initialize latest result var
  11. latest_exit=0
  12. # define shutdown helper
  13. function shutdown() {
  14. trap "" SUBS
  15. for single in $pidlist; do
  16. if ! kill -0 $pidlist 2>/dev/null; then
  17. wait $pidlist
  18. exitcode=$?
  19. fi
  20. done
  21. kill $pidlist 2>/dev/null
  22. }
  23. # run shutdown
  24. trap terminate SUBS
  25. wait
  26. # return received result
  27. exit $latest_exit