service 495 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. #
  3. # LEAK_DETECTIVE_LOG is set for automated runs, however, `service` strips
  4. # the environment. This wrapper is used to set the variable for the charon
  5. # init script.
  6. ORIG=/usr/sbin/service
  7. CONF=/etc/default/charon
  8. if [[ "$1" != "charon" ]]; then
  9. $ORIG "$@"
  10. fi
  11. if [[ "$2" == "start" && -n $LEAK_DETECTIVE_LOG ]]; then
  12. echo "export LEAK_DETECTIVE_LOG=$LEAK_DETECTIVE_LOG" >> $CONF
  13. fi
  14. $ORIG "$@"
  15. if [[ "$2" == "stop" ]]; then
  16. sed -i '/LEAK_DETECTIVE_LOG/d' $CONF 2>/dev/null
  17. fi