Advertisement
Guest User

Untitled

a guest
Sep 10th, 2018
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Make sure umask is set to owner only
  4. umask 0077
  5.  
  6. # find the current path to master executable
  7. FINDNAME=$0
  8. while [ -h $FINDNAME ] ; do FINDNAME=`command -v awk > /dev/null && ls -ld $FINDNAME | awk '{print $NF}' || ls -ld $FINDNAME | rev | cut -d ' ' -f 1 | rev` ; done
  9. RUNDIR=`echo $FINDNAME | sed -e 's@/[^/]*$@@'`
  10. unset FINDNAME
  11.  
  12. # cd to top level agent home
  13. if test -d $RUNDIR; then
  14. cd $RUNDIR/..
  15. else
  16. cd ..
  17. fi
  18.  
  19. #create log directory, in case it doesn't exist
  20. _AGENTOPERATIONSLOGFOLDER=`pwd`/log
  21. if ! test -d $_AGENTOPERATIONSLOGFOLDER ; then
  22. mkdir $_AGENTOPERATIONSLOGFOLDER
  23. fi
  24. _AGENTOPERATIONSLOGFILE=$_AGENTOPERATIONSLOGFOLDER/agent.operations.log
  25.  
  26. # Create header of execution log: 2 lines, command, date_time.
  27. NAME=`basename "$0"`
  28.  
  29. echo "" >> $_AGENTOPERATIONSLOGFILE
  30. echo "=================================================================================" >> $_AGENTOPERATIONSLOGFILE
  31. echo "The outer script $NAME started successfully at $(date)" >> $_AGENTOPERATIONSLOGFILE
  32. echo "Requested command: ${1} ">> $_AGENTOPERATIONSLOGFILE
  33. echo "=================================================================================" >> $_AGENTOPERATIONSLOGFILE
  34. # echo user for audit
  35. ID_COMMAND=`id`
  36. CURRENT_USER=`expr "$ID_COMMAND" : '.*(\(.*\)) gid='`
  37. echo "currentUser="$CURRENT_USER >> $_AGENTOPERATIONSLOGFILE
  38.  
  39. ROLLBACK_PROPERTIES=conf/rollback.properties
  40. PROP_NAME=set.HQ_AGENT_BUNDLE
  41.  
  42. # resolve the HQ Agent Bundle property
  43. AGENT_BUNDLE=`command -v awk > /dev/null && grep $PROP_NAME $ROLLBACK_PROPERTIES | awk -F= '{print $2}' || grep $PROP_NAME $ROLLBACK_PROPERTIES | cut -d '=' -f 2`
  44. echo "AGENT_BUNDLE = $AGENT_BUNDLE" >> $_AGENTOPERATIONSLOGFILE
  45.  
  46. if test -d "./bundles/$AGENT_BUNDLE"; then
  47. # be safe and set permissions for the invoked script
  48. echo "Setting permissions:" >> $_AGENTOPERATIONSLOGFILE
  49. echo " 1. chmod -R +x ./bundles/$AGENT_BUNDLE/bin/*" >> $_AGENTOPERATIONSLOGFILE
  50. chmod -R +x ./bundles/$AGENT_BUNDLE/bin/* 2>&1 | tee -a $_AGENTOPERATIONSLOGFILE
  51. # Fix permissions issues on HPUX
  52. echo " 2. chmod -R +x ./bundles/$AGENT_BUNDLE/pdk/lib/*.sl" >> $_AGENTOPERATIONSLOGFILE
  53. chmod -R +x ./bundles/$AGENT_BUNDLE/pdk/lib/*.sl 2>&1 | tee -a $_AGENTOPERATIONSLOGFILE
  54. #also for backround.sh which is in different folder
  55. echo " 3. chmod +x ./bundles/$AGENT_BUNDLE/*" >> $_AGENTOPERATIONSLOGFILE
  56. chmod +x ./bundles/$AGENT_BUNDLE/* 2>&1 | tee -a $_AGENTOPERATIONSLOGFILE
  57. # pass on the command to the bundle
  58. #echo "Invoking agent bundle $AGENT_BUNDLE"
  59. if [ "$1" = "set-property" ]; then
  60. echo "invoking script: ./bundles/$AGENT_BUNDLE/bin/hq-agent-nowrapper.sh $@" >> $_AGENTOPERATIONSLOGFILE
  61. ./bundles/$AGENT_BUNDLE/bin/hq-agent-nowrapper.sh "$@"
  62. else
  63. echo "invoking script: ./bundles/$AGENT_BUNDLE/bin/ep-agent.sh $@" >> $_AGENTOPERATIONSLOGFILE
  64. ./bundles/$AGENT_BUNDLE/bin/ep-agent.sh "$@"
  65. fi
  66. else
  67. echo "Bundle $AGENT_BUNDLE does not exist!" | tee -a $_AGENTOPERATIONSLOGFILE
  68. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement