bootstrap.sh 486 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. set -u
  3. # User params
  4. USER_PARAMS=$@
  5. # Internal params
  6. RUN_CMD="snmpd -f ${USER_PARAMS}"
  7. #######################################
  8. # Echo/log function
  9. # Arguments:
  10. # String: value to log
  11. #######################################
  12. log() {
  13. if [[ "$@" ]]; then echo "[`date +'%Y-%m-%d %T'`] $@";
  14. else echo; fi
  15. }
  16. # Launch
  17. log $RUN_CMD
  18. $RUN_CMD
  19. # Exit immidiately in case of any errors or when we have interactive terminal
  20. if [[ $? != 0 ]] || test -t 0; then exit $?; fi
  21. log