Advertisement
Guest User

opqeQRM control script wrapper

a guest
Aug 30th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.14 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. LOGDIR=`dirname $0`/../../log/
  4. TIMESTAMP=$(date +"%H:%M:%S")
  5. DATE=$(date +%d-%m-%y)
  6.  
  7. if [[ ! -d $LOGDIR ]]; then
  8.     mkdir -p $LOGDIR
  9.     echo "$TIMESTAMP [WRAPPER] Logdir is set to $LOGDIR" >> $LOGDIR/stdlog_$DATE
  10. fi
  11.  
  12.  
  13. echo "$TIMESTAMP [WRAPPER] Call control script `dirname $0`/`basename $0`-wrapped with params [$@]" >> $LOGDIR/stdlog_$DATE
  14. # | sed -e "s/^/$TIMESTAMP/"
  15. `dirname $0`/`basename $0`-wrapped "$@" > >(sed -e "s/$TIMESTAMP //g;s/^/$TIMESTAMP /" | tee -a $LOGDIR/stdlog_$DATE) 2> >(sed -e "s/^/$TIMESTAMP /" | tee -a  $LOGDIR/errlog_$DATE)
  16.  
  17. WRAPPEDEXIT=$?
  18.  
  19. if [ $WRAPPEDEXIT -eq 1 ]; then
  20.     echo "$TIMESTAMP [WRAPPER] The control script `dirname $0`/`basename $0`-wrapped finished with exit code 1. Try $0 {start|stop|restart|init|uninstall}" >> $LOGDIR/errlog_$DATE
  21.     echo "$TIMESTAMP [WRAPPER] The control script `dirname $0`/`basename $0`-wrapped finished with exit code 1. See $LOGDIR/errlog_$DATE for more information" >> $LOGDIR/stdlog_$DATE
  22. else
  23.     echo "$TIMESTAMP [WRAPPER] The control script `dirname $0`/`basename $0`-wrapped finished with exit code $WRAPPEDEXIT" >> $LOGDIR/stdlog_$DATE
  24. fi
  25.  
  26. exit $WRAPPEDEXIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement