Guest User

Untitled

a guest
Feb 8th, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #set default privileges to -rw-r-----
  4. umask 027
  5.  
  6. set -a
  7. if [ -r "/etc/default/puppetserver" ] ; then
  8. . /etc/default/puppetserver
  9. elif [ -r "/etc/sysconfig/puppetserver" ] ; then
  10. . /etc/sysconfig/puppetserver
  11. elif [ `uname` == "OpenBSD" ] ; then
  12. JAVA_BIN=$(javaPathHelper -c puppetserver)
  13. JAVA_ARGS="-Xms2g -Xmx2g -XX:MaxPermSize=256m"
  14. USER="_puppet"
  15. INSTALL_DIR="/opt/puppetlabs/server/apps/puppetserver"
  16. CONFIG="/etc/puppetlabs/puppetserver/conf.d"
  17. else
  18. echo "You seem to be missing some important configuration files; could not find /etc/default/puppetserver or /etc/sysconfig/puppetserver" >&2
  19. exit 1
  20. fi
  21. set +a
  22.  
  23. CLI_DIR="${INSTALL_DIR}/cli"
  24. CLI_APP_DIR="${CLI_DIR}/apps"
  25. APPS=`ls ${CLI_APP_DIR} 2>/dev/null`
  26.  
  27. #############
  28. # FUNCTIONS #
  29. #############
  30.  
  31. # Display usage then exit
  32. function usage {
  33.  
  34. if [ "$APPS" == "" ]; then
  35. echo "ERROR: No sub-commands found in ${CLI_APP_DIR}"
  36. exit 1
  37. fi
  38.  
  39. cat <<EOD
  40. usage: $(basename $0) ([--help] | [--version]) <command> [<args>]
  41.  
  42. The most commonly used puppetserver commands are:
  43. EOD
  44.  
  45. # Iterate and display commands in the CLI_APP_DIR
  46. for f in $APPS; do
  47. echo " $f"
  48. done
  49.  
  50. cat << EOD
  51.  
  52. See '$(basename $0) <command> -h' for more information on a specific command.
  53. EOD
  54. exit 0
  55. }
  56.  
  57. function show_version {
  58. cat <<EOD
  59. puppetserver version: 2.7.2
  60. EOD
  61. exit 0
  62. }
  63.  
  64. # Execute the subcommand if available.
  65. #
  66. # $1 - subcommand
  67. # $n - arguments
  68. #
  69. # Example:
  70. #
  71. # execsubcommand export -o test.dump -H 1.1.1.1
  72. #
  73. function execsubcommand {
  74. sub=$1
  75. shift
  76. cmd="${CLI_APP_DIR}/${sub}"
  77.  
  78. if [ -e ${cmd} ]; then
  79. exec "${cmd}" "$@"
  80. else
  81. echo "puppetserver: '${sub}' is not a puppetserver command. See '$(basename $0) --help'."
  82. fi
  83. }
  84.  
  85. ########
  86. # MAIN #
  87. ########
  88.  
  89. if [ -z $1 ] || [ $1 = "--help" ] || [ $1 = "-h" ]; then
  90. usage
  91. fi
  92. if [ $1 = "--version" ] || [ $1 = "-v" ]; then
  93. show_version
  94. fi
  95.  
  96. execsubcommand "$@"
Advertisement
Add Comment
Please, Sign In to add comment