home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / wrapper / make-wrapper-init.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2012-04-01  |  5.4 KB  |  181 lines

  1. #!/bin/sh
  2. # Create an application-specific initscript that runs service-wrapper.
  3.  
  4. QUIET=false
  5. PREINIT_SH=/dev/null
  6.  
  7. case "$1" in
  8. -q|--quiet)
  9.     QUIET=true
  10.     ;;
  11. -h|--help)
  12.     echo >&2 "Usage: cat <PARAMS> | $0 [-q|--quiet]"
  13.     exit 1
  14. esac
  15.  
  16. if ! $QUIET; then
  17.     cat >&2 <<EOF
  18. This script will generate an initscript that runs service-wrapper. I will now
  19. read from STDIN; please input your parameters in the following format:
  20.  
  21. ==== start of input stream ====
  22. APP_NAME
  23. APP_LONG_NAME
  24. APP_DESCRIPTION
  25. NAME1 VALUE1
  26. NAME2 VALUE2
  27. ...
  28. NAMEn VALUEn
  29.  
  30. PREINIT_SHELL_SCRIPT_LINE1
  31. PREINIT_SHELL_SCRIPT_LINE2
  32. ...
  33. PREINIT_SHELL_SCRIPT_LINEn
  34. ==== end of input stream ====
  35.  
  36. where:
  37.  
  38. APP_NAME: short system name of application, e.g. avahi-daemon, apache2
  39.     This is used to refer to scripts like /etc/default/APP_NAME
  40. APP_LONG_NAME: long name of application, e.g. Apache Web Server
  41.     This is used to refer to the application in messages for the end user.
  42. APP_DESCRIPTION: longer description for your application
  43.     This serves as documentation for the end user.
  44. NAMEn VALUEn: optional name-value pairs that set application-specific defaults
  45.     for service-wrapper variables. At run-time, these may be overridden by user
  46.     settings in /etc/default/APP_NAME. Note: a space separates NAME VALUE, not
  47.     an equals sign (=). Also, currently VALUE cannot contain "|".
  48. PREINIT_SHELL_SCRIPTn: at run-time, these commands will be run after the script
  49. sources /etc/default/APP_NAME, to do further processing on any variables set.
  50.  
  51. Please enter your input; press Ctrl-D when you are done:
  52. EOF
  53. fi
  54.  
  55. # splice params
  56.  
  57. SED_ARGS=""
  58. push_sed_expr() { SED_ARGS="$SED_ARGS -e '$1'"; }
  59.  
  60. read APP_NAME
  61. push_sed_expr "s/@app.name@/$APP_NAME/g"
  62.  
  63. read APP_LONG_NAME
  64. push_sed_expr "s/@app.long.name@/$APP_LONG_NAME/g"
  65.  
  66. read APP_DESCRIPTION
  67. push_sed_expr "s/@app.description@/$APP_DESCRIPTION/g"
  68.  
  69. while read ARG VAL; do
  70.     if [ -z "$ARG" ]; then break; fi
  71.     push_sed_expr 's|^\s*#\?\s*\('"$ARG"'=\).*|\1"'"$VAL"'"|g'
  72. done
  73.  
  74. PREINIT_SH="$(tempfile)"
  75. cat - > "$PREINIT_SH"
  76.  
  77. if ! $QUIET; then set -x; fi
  78. eval sed $SED_ARGS <<EOF | sed -e "/WRAPPER_PREINIT START/r$PREINIT_SH"
  79. #! /bin/sh
  80.  
  81. #
  82. # Copyright (c) 1999, 2010 Tanuki Software, Ltd.
  83. # http://www.tanukisoftware.com
  84. # All rights reserved.
  85. #
  86. # This software is the proprietary information of Tanuki Software.
  87. # You shall use it only in accordance with the terms of the
  88. # license agreement you entered into with Tanuki Software.
  89. # http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html
  90. #
  91. # Java Service Wrapper sh script.  Suitable for starting and stopping
  92. #  wrapped Java applications on UNIX platforms.
  93. #
  94.  
  95. #-----------------------------------------------------------------------------
  96. # These settings can be modified to fit the needs of your application
  97. # Optimized for use with version 3.5.3 of the Wrapper.
  98.  
  99. # Application
  100. APP_NAME="@app.name@"
  101. APP_LONG_NAME="@app.long.name@"
  102.  
  103. # Wrapper
  104. WRAPPER_CMD="/usr/sbin/wrapper"
  105. WRAPPER_CONF="../conf/wrapper.conf"
  106.  
  107. # Priority at which to run the wrapper.  See "man nice" for valid priorities.
  108. #  nice is only used if a priority is specified.
  109. PRIORITY=
  110.  
  111. # Location of the pid file.
  112. PIDDIR="."
  113.  
  114. # If uncommented, causes the Wrapper to be shutdown using an anchor file.
  115. #  When launched with the 'start' command, it will also ignore all INT and
  116. #  TERM signals.
  117. #IGNORE_SIGNALS=true
  118.  
  119. # Wrapper will start the JVM asynchronously. Your application may have some
  120. #  initialization tasks and it may be desirable to wait a few seconds
  121. #  before returning.  For example, to delay the invocation of following
  122. #  startup scripts.  Setting WAIT_AFTER_STARTUP to a positive number will
  123. #  cause the start command to delay for the indicated period of time 
  124. #  (in seconds).
  125. WAIT_AFTER_STARTUP=0
  126.  
  127. # If set, wait for the wrapper to report that the daemon has started
  128. WAIT_FOR_STARTED_STATUS=true
  129. WAIT_FOR_STARTED_TIMEOUT=120
  130.  
  131. # If set, the status, start_msg and stop_msg commands will print out detailed
  132. #   state information on the Wrapper and Java processes.
  133. #DETAIL_STATUS=true
  134.  
  135. # If specified, the Wrapper will be run as the specified user.
  136. # IMPORTANT - Make sure that the user has the required privileges to write
  137. #  the PID file and wrapper.log files.  Failure to be able to write the log
  138. #  file will cause the Wrapper to exit without any way to write out an error
  139. #  message.
  140. # NOTE - This will set the user which is used to run the Wrapper as well as
  141. #  the JVM and is not useful in situations where a privileged resource or
  142. #  port needs to be allocated prior to the user being changed.
  143. #RUN_AS_USER=
  144.  
  145. # The following two lines are used by the chkconfig command. Change as is
  146. #  appropriate for your application.  They should remain commented.
  147. # chkconfig: 2345 20 80
  148. # description: @app.long.name@
  149.  
  150. # When installing on On Mac OSX platforms, the following domain will be used to
  151. #  prefix the plist file name.
  152. PLIST_DOMAIN=org.tanukisoftware.wrapper
  153.  
  154. # Initialization block for the install_initd and remove_initd scripts used by
  155. #  SUSE linux distributions.
  156. ### BEGIN INIT INFO
  157. # Provides: @app.name@
  158. # Required-Start: $local_fs $network $syslog
  159. # Should-Start: 
  160. # Required-Stop:
  161. # Default-Start: 2 3 4 5
  162. # Default-Stop: 0 1 6
  163. # Short-Description: @app.long.name@
  164. # Description: @app.description@
  165. ### END INIT INFO
  166.  
  167. # Do not modify anything beyond this point
  168. #-----------------------------------------------------------------------------
  169.  
  170. if [ -f "/etc/default/$APP_NAME" ]; then
  171.     . "/etc/default/$APP_NAME"
  172. fi
  173.  
  174. # WRAPPER_PREINIT START
  175. # WRAPPER_PREINIT END
  176.  
  177. . "/usr/share/wrapper/daemon.sh"
  178.  
  179. EOF
  180.