wrapper-compute-engine 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614
  1. #! /bin/sh
  2. #
  3. # Copyright (c) 1999, 2012 Tanuki Software, Ltd.
  4. # http://www.tanukisoftware.com
  5. # All rights reserved.
  6. #
  7. # This software is the proprietary information of Tanuki Software.
  8. # You shall use it only in accordance with the terms of the
  9. # license agreement you entered into with Tanuki Software.
  10. # http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html
  11. #
  12. # Java Service Wrapper sh script. Suitable for starting and stopping
  13. # wrapped Java applications on UNIX platforms.
  14. #
  15. #-----------------------------------------------------------------------------
  16. # These settings can be modified to fit the needs of your application
  17. # Optimized for use with version 3.5.15 of the Wrapper.
  18. #********************************************************************
  19. # NOTE - This script has been modified to run the TestWrapper sample
  20. # application and should NOT be used as a base for your own
  21. # applications. All of the documentation assumes that you are
  22. # working from the default source script:
  23. # WRAPPER_HOME/src/bin/sh.script.in
  24. #********************************************************************
  25. # Application
  26. APP_NAME="wrapper-compute-engine"
  27. APP_LONG_NAME="wrapper-compute-engine"
  28. # Wrapper
  29. WRAPPER_CMD="./wrapper"
  30. WRAPPER_CONF="../conf/wrapper.conf"
  31. # Priority at which to run the wrapper. See "man nice" for valid priorities.
  32. # nice is only used if a priority is specified.
  33. PRIORITY=
  34. # Location of the pid file.
  35. PIDDIR="."
  36. # FIXED_COMMAND tells the script to use a hard coded action rather than
  37. # expecting the first parameter of the command line to be the command.
  38. # By default the command will will be expected to be the first parameter.
  39. #FIXED_COMMAND=console
  40. # PASS_THROUGH tells the script to pass all arguments through to the JVM
  41. # as is. If FIXED_COMMAND is specified then all arguments will be passed.
  42. # If not set then all arguments starting with the second will be passed.
  43. PASS_THROUGH=true
  44. # If uncommented, causes the Wrapper to be shutdown using an anchor file.
  45. # When launched with the 'start' command, it will also ignore all INT and
  46. # TERM signals.
  47. #IGNORE_SIGNALS=true
  48. # Wrapper will start the JVM asynchronously. Your application may have some
  49. # initialization tasks and it may be desirable to wait a few seconds
  50. # before returning. For example, to delay the invocation of following
  51. # startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will
  52. # cause the start command to delay for the indicated period of time
  53. # (in seconds).
  54. #
  55. WAIT_AFTER_STARTUP=0
  56. # If set, wait for the wrapper to report that the daemon has started
  57. WAIT_FOR_STARTED_STATUS=true
  58. WAIT_FOR_STARTED_TIMEOUT=120
  59. # If set, the status, start_msg and stop_msg commands will print out detailed
  60. # state information on the Wrapper and Java processes.
  61. #DETAIL_STATUS=true
  62. # If set, the 'pause' and 'resume' commands will be enabled. These make it
  63. # possible to pause the JVM or Java application without completely stopping
  64. # the Wrapper. See the wrapper.pausable and wrapper.pausable.stop_jvm
  65. # properties for more information.
  66. #PAUSABLE=true
  67. # If specified, the Wrapper will be run as the specified user.
  68. # IMPORTANT - Make sure that the user has the required privileges to write
  69. # the PID file and wrapper.log files. Failure to be able to write the log
  70. # file will cause the Wrapper to exit without any way to write out an error
  71. # message.
  72. # NOTE - This will set the user which is used to run the Wrapper as well as
  73. # the JVM and is not useful in situations where a privileged resource or
  74. # port needs to be allocated prior to the user being changed.
  75. #RUN_AS_USER=
  76. # By default we show a detailed usage block. Uncomment to show brief usage.
  77. #BRIEF_USAGE=true
  78. # flag for using upstart when installing (rather than init.d rc.d)
  79. USE_UPSTART=
  80. # When installing on On Mac OSX platforms, the following domain will be used to
  81. # prefix the plist file name.
  82. PLIST_DOMAIN=org.tanukisoftware.wrapper
  83. # The following two lines are used by the chkconfig command. Change as is
  84. # appropriate for your application. They should remain commented.
  85. # chkconfig: 2345 20 80
  86. # description: @app.long.name@
  87. # Initialization block for the install_initd and remove_initd scripts used by
  88. # SUSE linux distributions.
  89. ### BEGIN INIT INFO
  90. # Provides: @app.name@
  91. # Required-Start: $local_fs $network $syslog
  92. # Should-Start:
  93. # Required-Stop:
  94. # Default-Start: 2 3 4 5
  95. # Default-Stop: 0 1 6
  96. # Short-Description: @app.long.name@
  97. # Description: @app.description@
  98. ### END INIT INFO
  99. # Do not modify anything beyond this point
  100. #-----------------------------------------------------------------------------
  101. if [ -n "$FIXED_COMMAND" ]
  102. then
  103. COMMAND="$FIXED_COMMAND"
  104. else
  105. COMMAND="$1"
  106. fi
  107. # Required for HP-UX Startup
  108. if [ `uname -s` = "HP-UX" -o `uname -s` = "HP-UX64" ] ; then
  109. PATH=$PATH:/usr/bin
  110. fi
  111. # Get the fully qualified path to the script
  112. case $0 in
  113. /*)
  114. SCRIPT="$0"
  115. ;;
  116. *)
  117. PWD=`pwd`
  118. SCRIPT="$PWD/$0"
  119. ;;
  120. esac
  121. # Resolve the true real path without any sym links.
  122. CHANGED=true
  123. while [ "X$CHANGED" != "X" ]
  124. do
  125. # Change spaces to ":" so the tokens can be parsed.
  126. SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
  127. # Get the real path to this script, resolving any symbolic links
  128. TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'`
  129. REALPATH=
  130. for C in $TOKENS; do
  131. # Change any ":" in the token back to a space.
  132. C=`echo $C | sed -e 's;:; ;g'`
  133. REALPATH="$REALPATH/$C"
  134. # If REALPATH is a sym link, resolve it. Loop for nested links.
  135. while [ -h "$REALPATH" ] ; do
  136. LS="`ls -ld "$REALPATH"`"
  137. LINK="`expr "$LS" : '.*-> \(.*\)$'`"
  138. if expr "$LINK" : '/.*' > /dev/null; then
  139. # LINK is absolute.
  140. REALPATH="$LINK"
  141. else
  142. # LINK is relative.
  143. REALPATH="`dirname "$REALPATH"`""/$LINK"
  144. fi
  145. done
  146. done
  147. if [ "$REALPATH" = "$SCRIPT" ]
  148. then
  149. CHANGED=""
  150. else
  151. SCRIPT="$REALPATH"
  152. fi
  153. done
  154. # Get the location of the script.
  155. REALDIR=`dirname "$REALPATH"`
  156. # Normalize the path
  157. REALDIR=`cd "${REALDIR}"; pwd`
  158. # If the PIDDIR is relative, set its value relative to the full REALPATH to avoid problems if
  159. # the working directory is later changed.
  160. FIRST_CHAR=`echo $PIDDIR | cut -c1,1`
  161. if [ "$FIRST_CHAR" != "/" ]
  162. then
  163. PIDDIR=$REALDIR/$PIDDIR
  164. fi
  165. # Same test for WRAPPER_CMD
  166. FIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1`
  167. if [ "$FIRST_CHAR" != "/" ]
  168. then
  169. WRAPPER_CMD=$REALDIR/$WRAPPER_CMD
  170. fi
  171. # Same test for WRAPPER_CONF
  172. FIRST_CHAR=`echo $WRAPPER_CONF | cut -c1,1`
  173. if [ "$FIRST_CHAR" != "/" ]
  174. then
  175. WRAPPER_CONF=$REALDIR/$WRAPPER_CONF
  176. fi
  177. # Process ID
  178. ANCHORFILE="$PIDDIR/$APP_NAME.anchor"
  179. COMMANDFILE="$PIDDIR/$APP_NAME.command"
  180. STATUSFILE="$PIDDIR/$APP_NAME.status"
  181. JAVASTATUSFILE="$PIDDIR/$APP_NAME.java.status"
  182. PIDFILE="$PIDDIR/$APP_NAME.pid"
  183. LOCKDIR="/var/lock/subsys"
  184. LOCKFILE="$LOCKDIR/$APP_NAME"
  185. pid=""
  186. # Resolve the location of the 'ps' command
  187. PSEXE="/usr/ucb/ps"
  188. if [ ! -x "$PSEXE" ]
  189. then
  190. PSEXE="/usr/bin/ps"
  191. if [ ! -x "$PSEXE" ]
  192. then
  193. PSEXE="/bin/ps"
  194. if [ ! -x "$PSEXE" ]
  195. then
  196. eval echo `gettext 'Unable to locate "ps".'`
  197. eval echo `gettext 'Please report this message along with the location of the command on your system.'`
  198. exit 1
  199. fi
  200. fi
  201. fi
  202. TREXE="/usr/bin/tr"
  203. if [ ! -x "$TREXE" ]
  204. then
  205. TREXE="/bin/tr"
  206. if [ ! -x "$TREXE" ]
  207. then
  208. eval echo `gettext 'Unable to locate "tr".'`
  209. eval echo `gettext 'Please report this message along with the location of the command on your system.'`
  210. exit 1
  211. fi
  212. fi
  213. # Resolve the os
  214. DIST_OS=`uname -s | $TREXE "[A-Z]" "[a-z]" | $TREXE -d ' '`
  215. case "$DIST_OS" in
  216. 'sunos')
  217. DIST_OS="solaris"
  218. ;;
  219. 'hp-ux' | 'hp-ux64')
  220. # HP-UX needs the XPG4 version of ps (for -o args)
  221. DIST_OS="hpux"
  222. UNIX95=""
  223. export UNIX95
  224. ;;
  225. 'darwin')
  226. DIST_OS="macosx"
  227. ;;
  228. 'unix_sv')
  229. DIST_OS="unixware"
  230. ;;
  231. 'os/390')
  232. DIST_OS="zos"
  233. ;;
  234. esac
  235. # Resolve the architecture
  236. if [ "$DIST_OS" = "macosx" ]
  237. then
  238. OS_VER=`sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*'`
  239. DIST_ARCH="universal"
  240. if [[ "$OS_VER" < "10.5.0" ]]
  241. then
  242. DIST_BITS="32"
  243. else
  244. if [ "X`sysctl -n hw.cpu64bit_capable`" == "X1" ]
  245. then
  246. DIST_BITS="64"
  247. else
  248. DIST_BITS="32"
  249. fi
  250. fi
  251. APP_PLIST_BASE=${PLIST_DOMAIN}.${APP_NAME}
  252. APP_PLIST=${APP_PLIST_BASE}.plist
  253. else
  254. DIST_ARCH=
  255. DIST_ARCH=`uname -p 2>/dev/null | $TREXE "[A-Z]" "[a-z]" | $TREXE -d ' '`
  256. if [ "X$DIST_ARCH" = "X" ]
  257. then
  258. DIST_ARCH="unknown"
  259. fi
  260. if [ "$DIST_ARCH" = "unknown" ]
  261. then
  262. DIST_ARCH=`uname -m 2>/dev/null | $TREXE "[A-Z]" "[a-z]" | $TREXE -d ' '`
  263. fi
  264. case "$DIST_ARCH" in
  265. 'athlon' | 'i386' | 'i486' | 'i586' | 'i686')
  266. DIST_ARCH="x86"
  267. if [ "${DIST_OS}" = "solaris" ] ; then
  268. DIST_BITS=`isainfo -b`
  269. else
  270. DIST_BITS="32"
  271. fi
  272. ;;
  273. 'amd64' | 'x86_64')
  274. DIST_ARCH="x86"
  275. DIST_BITS="64"
  276. ;;
  277. 'ia32')
  278. DIST_ARCH="ia"
  279. DIST_BITS="32"
  280. ;;
  281. 'ia64' | 'ia64n' | 'ia64w')
  282. DIST_ARCH="ia"
  283. DIST_BITS="64"
  284. ;;
  285. 'ip27')
  286. DIST_ARCH="mips"
  287. DIST_BITS="32"
  288. ;;
  289. 'power' | 'powerpc' | 'power_pc' | 'ppc64')
  290. if [ "${DIST_ARCH}" = "ppc64" ] ; then
  291. DIST_BITS="64"
  292. else
  293. DIST_BITS="32"
  294. fi
  295. DIST_ARCH="ppc"
  296. if [ "${DIST_OS}" = "aix" ] ; then
  297. if [ `getconf KERNEL_BITMODE` -eq 64 ]; then
  298. DIST_BITS="64"
  299. else
  300. DIST_BITS="32"
  301. fi
  302. fi
  303. ;;
  304. 'pa_risc' | 'pa-risc')
  305. DIST_ARCH="parisc"
  306. if [ `getconf KERNEL_BITS` -eq 64 ]; then
  307. DIST_BITS="64"
  308. else
  309. DIST_BITS="32"
  310. fi
  311. ;;
  312. 'sun4u' | 'sparcv9' | 'sparc')
  313. DIST_ARCH="sparc"
  314. DIST_BITS=`isainfo -b`
  315. ;;
  316. '9000/800' | '9000/785')
  317. DIST_ARCH="parisc"
  318. if [ `getconf KERNEL_BITS` -eq 64 ]; then
  319. DIST_BITS="64"
  320. else
  321. DIST_BITS="32"
  322. fi
  323. ;;
  324. '2064' | '2066' | '2084' | '2086' | '2094' | '2096' | '2097' | '2098' | '2817')
  325. DIST_ARCH="390"
  326. DIST_BITS="64"
  327. ;;
  328. esac
  329. fi
  330. # OSX always places Java in the same location so we can reliably set JAVA_HOME
  331. if [ "$DIST_OS" = "macosx" ]
  332. then
  333. if [ -z "$JAVA_HOME" ]; then
  334. JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
  335. fi
  336. fi
  337. # Test Echo
  338. ECHOTEST=`echo -n "x"`
  339. if [ "$ECHOTEST" = "x" ]
  340. then
  341. ECHOOPT="-n "
  342. else
  343. ECHOOPT=""
  344. fi
  345. gettext() {
  346. "$WRAPPER_CMD" --translate "$1" "$WRAPPER_CONF" 2>/dev/null
  347. if [ $? != 0 ] ; then
  348. echo "$1"
  349. fi
  350. }
  351. outputFile() {
  352. if [ -f "$1" ]
  353. then
  354. eval echo `gettext ' $1 Found but not executable.'`;
  355. else
  356. echo " $1"
  357. fi
  358. }
  359. # Decide on the wrapper binary to use.
  360. # If the bits of the OS could be detected, we will try to look for the
  361. # binary with the correct bits value. If it doesn't exist, fall back
  362. # and look for the 32-bit binary. If that doesn't exist either then
  363. # look for the default.
  364. WRAPPER_TEST_CMD=""
  365. if [ -f "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS" ]
  366. then
  367. WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS"
  368. if [ ! -x "$WRAPPER_TEST_CMD" ]
  369. then
  370. chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null
  371. fi
  372. if [ -x "$WRAPPER_TEST_CMD" ]
  373. then
  374. WRAPPER_CMD="$WRAPPER_TEST_CMD"
  375. else
  376. outputFile "$WRAPPER_TEST_CMD"
  377. WRAPPER_TEST_CMD=""
  378. fi
  379. fi
  380. if [ -f "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32" -a -z "$WRAPPER_TEST_CMD" ]
  381. then
  382. WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
  383. if [ ! -x "$WRAPPER_TEST_CMD" ]
  384. then
  385. chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null
  386. fi
  387. if [ -x "$WRAPPER_TEST_CMD" ]
  388. then
  389. WRAPPER_CMD="$WRAPPER_TEST_CMD"
  390. else
  391. outputFile "$WRAPPER_TEST_CMD"
  392. WRAPPER_TEST_CMD=""
  393. fi
  394. fi
  395. if [ -f "$WRAPPER_CMD" -a -z "$WRAPPER_TEST_CMD" ]
  396. then
  397. WRAPPER_TEST_CMD="$WRAPPER_CMD"
  398. if [ ! -x "$WRAPPER_TEST_CMD" ]
  399. then
  400. chmod +x "$WRAPPER_TEST_CMD" 2>/dev/null
  401. fi
  402. if [ -x "$WRAPPER_TEST_CMD" ]
  403. then
  404. WRAPPER_CMD="$WRAPPER_TEST_CMD"
  405. else
  406. outputFile "$WRAPPER_TEST_CMD"
  407. WRAPPER_TEST_CMD=""
  408. fi
  409. fi
  410. if [ -z "$WRAPPER_TEST_CMD" ]
  411. then
  412. eval echo `gettext 'Unable to locate any of the following binaries:'`
  413. outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS"
  414. if [ ! "$DIST_BITS" = "32" ]
  415. then
  416. outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
  417. fi
  418. outputFile "$WRAPPER_CMD"
  419. exit 1
  420. fi
  421. # Build the nice clause
  422. if [ "X$PRIORITY" = "X" ]
  423. then
  424. CMDNICE=""
  425. else
  426. CMDNICE="nice -$PRIORITY"
  427. fi
  428. # Build the anchor file clause.
  429. if [ "X$IGNORE_SIGNALS" = "X" ]
  430. then
  431. ANCHORPROP=
  432. IGNOREPROP=
  433. else
  434. ANCHORPROP=wrapper.anchorfile=\"$ANCHORFILE\"
  435. IGNOREPROP=wrapper.ignore_signals=TRUE
  436. fi
  437. # Build the status file clause.
  438. if [ "X$DETAIL_STATUS$WAIT_FOR_STARTED_STATUS" = "X" ]
  439. then
  440. STATUSPROP=
  441. else
  442. STATUSPROP="wrapper.statusfile=\"$STATUSFILE\" wrapper.java.statusfile=\"$JAVASTATUSFILE\""
  443. fi
  444. # Build the command file clause.
  445. if [ -n "$PAUSABLE" ]
  446. then
  447. COMMANDPROP="wrapper.commandfile=\"$COMMANDFILE\" wrapper.pausable=TRUE"
  448. else
  449. COMMANDPROP=
  450. fi
  451. if [ ! -n "$WAIT_FOR_STARTED_STATUS" ]
  452. then
  453. WAIT_FOR_STARTED_STATUS=true
  454. fi
  455. if [ $WAIT_FOR_STARTED_STATUS = true ] ; then
  456. DETAIL_STATUS=true
  457. fi
  458. # Build the lock file clause. Only create a lock file if the lock directory exists on this platform.
  459. LOCKPROP=
  460. if [ -d $LOCKDIR ]
  461. then
  462. if [ -w $LOCKDIR ]
  463. then
  464. LOCKPROP=wrapper.lockfile=\"$LOCKFILE\"
  465. fi
  466. fi
  467. prepAdditionalParams() {
  468. ADDITIONAL_PARA=""
  469. if [ -n "$PASS_THROUGH" ] ; then
  470. ADDITIONAL_PARA="--"
  471. fi
  472. while [ -n "$1" ] ; do
  473. ADDITIONAL_PARA="$ADDITIONAL_PARA \"$1\""
  474. shift
  475. done
  476. }
  477. checkUser() {
  478. # $1 touchLock flag
  479. # $2.. [command] args
  480. # Check the configured user. If necessary rerun this script as the desired user.
  481. if [ "X$RUN_AS_USER" != "X" ]
  482. then
  483. # Resolve the location of the 'id' command
  484. IDEXE="/usr/xpg4/bin/id"
  485. if [ ! -x "$IDEXE" ]
  486. then
  487. IDEXE="/usr/bin/id"
  488. if [ ! -x "$IDEXE" ]
  489. then
  490. eval echo `gettext 'Unable to locate "id".'`
  491. eval echo `gettext 'Please report this message along with the location of the command on your system.'`
  492. exit 1
  493. fi
  494. fi
  495. if [ "`$IDEXE -u -n`" = "$RUN_AS_USER" ]
  496. then
  497. # Already running as the configured user. Avoid password prompts by not calling su.
  498. RUN_AS_USER=""
  499. fi
  500. fi
  501. if [ "X$RUN_AS_USER" != "X" ]
  502. then
  503. # If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be
  504. # able to create the lock file. The Wrapper will be able to update this file once it
  505. # is created but will not be able to delete it on shutdown. If $1 is set then
  506. # the lock file should be created for the current command
  507. if [ "X$LOCKPROP" != "X" ]
  508. then
  509. if [ "X$1" != "X" ]
  510. then
  511. # Resolve the primary group
  512. RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1`
  513. if [ "X$RUN_AS_GROUP" = "X" ]
  514. then
  515. RUN_AS_GROUP=$RUN_AS_USER
  516. fi
  517. touch $LOCKFILE
  518. chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE
  519. fi
  520. fi
  521. # Still want to change users, recurse. This means that the user will only be
  522. # prompted for a password once. Variables shifted by 1
  523. shift
  524. # Wrap the parameters so they can be passed.
  525. ADDITIONAL_PARA=""
  526. while [ -n "$1" ] ; do
  527. ADDITIONAL_PARA="$ADDITIONAL_PARA \"$1\""
  528. shift
  529. done
  530. # Use "runuser" if this exists. runuser should be used on RedHat in preference to su.
  531. #
  532. if test -f "/sbin/runuser"
  533. then
  534. /sbin/runuser - $RUN_AS_USER -c "\"$REALPATH\" $ADDITIONAL_PARA"
  535. else
  536. su - $RUN_AS_USER -c "\"$REALPATH\" $ADDITIONAL_PARA"
  537. fi
  538. RUN_AS_USER_EXITCODE=$?
  539. # Now that we are the original user again, we may need to clean up the lock file.
  540. if [ "X$LOCKPROP" != "X" ]
  541. then
  542. getpid
  543. if [ "X$pid" = "X" ]
  544. then
  545. # Wrapper is not running so make sure the lock file is deleted.
  546. if [ -f "$LOCKFILE" ]
  547. then
  548. rm "$LOCKFILE"
  549. fi
  550. fi
  551. fi
  552. exit $RUN_AS_USER_EXITCODE
  553. fi
  554. }
  555. getpid() {
  556. pid=""
  557. if [ -f "$PIDFILE" ]
  558. then
  559. if [ -r "$PIDFILE" ]
  560. then
  561. pid=`cat "$PIDFILE"`
  562. if [ "X$pid" != "X" ]
  563. then
  564. # It is possible that 'a' process with the pid exists but that it is not the
  565. # correct process. This can happen in a number of cases, but the most
  566. # common is during system startup after an unclean shutdown.
  567. # The ps statement below looks for the specific wrapper command running as
  568. # the pid. If it is not found then the pid file is considered to be stale.
  569. case "$DIST_OS" in
  570. 'freebsd')
  571. pidtest=`$PSEXE -p $pid -o args | tail -1`
  572. if [ "X$pidtest" = "XCOMMAND" ]
  573. then
  574. pidtest=""
  575. fi
  576. ;;
  577. 'macosx')
  578. pidtest=`$PSEXE -ww -p $pid -o command | grep -F "$WRAPPER_CMD" | tail -1`
  579. ;;
  580. 'solaris')
  581. if [ -f "/usr/bin/pargs" ]
  582. then
  583. pidtest=`pargs $pid | fgrep "$WRAPPER_CMD" | tail -1`
  584. else
  585. case "$PSEXE" in
  586. '/usr/ucb/ps')
  587. pidtest=`$PSEXE -auxww $pid | fgrep "$WRAPPER_CMD" | tail -1`
  588. ;;
  589. '/usr/bin/ps')
  590. TRUNCATED_CMD=`$PSEXE -o comm -p $pid | tail -1`
  591. COUNT=`echo $TRUNCATED_CMD | wc -m`
  592. COUNT=`echo ${COUNT}`
  593. COUNT=`expr $COUNT - 1`
  594. TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT`
  595. pidtest=`$PSEXE -o comm -p $pid | fgrep "$TRUNCATED_CMD" | tail -1`
  596. ;;
  597. '/bin/ps')
  598. TRUNCATED_CMD=`$PSEXE -o comm -p $pid | tail -1`
  599. COUNT=`echo $TRUNCATED_CMD | wc -m`
  600. COUNT=`echo ${COUNT}`
  601. COUNT=`expr $COUNT - 1`
  602. TRUNCATED_CMD=`echo $WRAPPER_CMD | cut -c1-$COUNT`
  603. pidtest=`$PSEXE -o comm -p $pid | fgrep "$TRUNCATED_CMD" | tail -1`
  604. ;;
  605. *)
  606. echo "Unsupported ps command $PSEXE"
  607. exit 1
  608. ;;
  609. esac
  610. fi
  611. ;;
  612. 'hpux')
  613. pidtest=`$PSEXE -p $pid -x -o args | grep -F "$WRAPPER_CMD" | tail -1`
  614. ;;
  615. *)
  616. pidtest=`$PSEXE -p $pid -o args | grep -F "$WRAPPER_CMD" | tail -1`
  617. ;;
  618. esac
  619. if [ "X$pidtest" = "X" ]
  620. then
  621. # This is a stale pid file.
  622. rm -f "$PIDFILE"
  623. eval echo `gettext 'Removed stale pid file: $PIDFILE'`
  624. pid=""
  625. fi
  626. fi
  627. else
  628. eval echo `gettext 'Cannot read $PIDFILE.'`
  629. exit 1
  630. fi
  631. fi
  632. }
  633. getstatus() {
  634. STATUS=
  635. if [ -f "$STATUSFILE" ]
  636. then
  637. if [ -r "$STATUSFILE" ]
  638. then
  639. STATUS=`cat "$STATUSFILE"`
  640. fi
  641. fi
  642. if [ "X$STATUS" = "X" ]
  643. then
  644. STATUS="Unknown"
  645. fi
  646. JAVASTATUS=
  647. if [ -f "$JAVASTATUSFILE" ]
  648. then
  649. if [ -r "$JAVASTATUSFILE" ]
  650. then
  651. JAVASTATUS=`cat "$JAVASTATUSFILE"`
  652. fi
  653. fi
  654. if [ "X$JAVASTATUS" = "X" ]
  655. then
  656. JAVASTATUS="Unknown"
  657. fi
  658. }
  659. testpid() {
  660. case "$DIST_OS" in
  661. 'solaris')
  662. case "$PSEXE" in
  663. '/usr/ucb/ps')
  664. pid=`$PSEXE $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
  665. ;;
  666. '/usr/bin/ps')
  667. pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
  668. ;;
  669. '/bin/ps')
  670. pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1`
  671. ;;
  672. *)
  673. echo "Unsupported ps command $PSEXE"
  674. exit 1
  675. ;;
  676. esac
  677. ;;
  678. *)
  679. pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` 2>/dev/null
  680. ;;
  681. esac
  682. if [ "X$pid" = "X" ]
  683. then
  684. # Process is gone so remove the pid file.
  685. rm -f "$PIDFILE"
  686. pid=""
  687. fi
  688. }
  689. launchdtrap() {
  690. stopit
  691. exit
  692. }
  693. waitforwrapperstop() {
  694. getpid
  695. while [ "X$pid" != "X" ] ; do
  696. sleep 1
  697. getpid
  698. done
  699. }
  700. launchinternal() {
  701. getpid
  702. trap launchdtrap TERM
  703. if [ "X$pid" = "X" ]
  704. then
  705. prepAdditionalParams "$@"
  706. # The string passed to eval must handles spaces in paths correctly.
  707. COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.15 $ADDITIONAL_PARA"
  708. eval $COMMAND_LINE
  709. else
  710. eval echo `gettext '$APP_LONG_NAME is already running.'`
  711. exit 1
  712. fi
  713. # launchd expects that this script stay up and running so we need to do our own monitoring of the Wrapper process.
  714. if [ $WAIT_FOR_STARTED_STATUS = true ]
  715. then
  716. waitforwrapperstop
  717. fi
  718. }
  719. console() {
  720. eval echo `gettext 'Running $APP_LONG_NAME...'`
  721. getpid
  722. if [ "X$pid" = "X" ]
  723. then
  724. trap '' 3
  725. prepAdditionalParams "$@"
  726. # The string passed to eval must handles spaces in paths correctly.
  727. COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.15 $ADDITIONAL_PARA"
  728. eval $COMMAND_LINE
  729. else
  730. eval echo `gettext '$APP_LONG_NAME is already running.'`
  731. exit 1
  732. fi
  733. }
  734. waitforjavastartup() {
  735. getstatus
  736. eval echo $ECHOOPT `gettext 'Waiting for $APP_LONG_NAME...'`
  737. # Wait until the timeout or we have something besides Unknown.
  738. counter=15
  739. while [ "$JAVASTATUS" = "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do
  740. echo $ECHOOPT"."
  741. sleep 1
  742. getstatus
  743. counter=`expr $counter - 1`
  744. done
  745. if [ -n "$WAIT_FOR_STARTED_TIMEOUT" ] ; then
  746. counter=$WAIT_FOR_STARTED_TIMEOUT
  747. else
  748. counter=120
  749. fi
  750. while [ "$JAVASTATUS" != "STARTED" -a "$JAVASTATUS" != "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do
  751. echo $ECHOOPT"."
  752. sleep 1
  753. getstatus
  754. counter=`expr $counter - 1`
  755. done
  756. if [ "X$ECHOOPT" != "X" ] ; then
  757. echo ""
  758. fi
  759. }
  760. startwait() {
  761. if [ $WAIT_FOR_STARTED_STATUS = true ]
  762. then
  763. waitforjavastartup
  764. fi
  765. # Sleep for a few seconds to allow for intialization if required
  766. # then test to make sure we're still running.
  767. #
  768. i=0
  769. while [ $i -lt $WAIT_AFTER_STARTUP ]
  770. do
  771. sleep 1
  772. echo $ECHOOPT"."
  773. i=`expr $i + 1`
  774. done
  775. if [ $WAIT_AFTER_STARTUP -gt 0 -o $WAIT_FOR_STARTED_STATUS = true ]
  776. then
  777. getpid
  778. if [ "X$pid" = "X" ]
  779. then
  780. eval echo `gettext ' WARNING: $APP_LONG_NAME may have failed to start.'`
  781. exit 1
  782. else
  783. eval echo `gettext ' running: PID:$pid'`
  784. fi
  785. else
  786. echo ""
  787. fi
  788. }
  789. macosxstart() {
  790. # The daemon has been installed.
  791. eval echo `gettext 'Starting $APP_LONG_NAME. Detected Mac OSX and installed launchd daemon.'`
  792. if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then
  793. eval echo `gettext 'Must be root to perform this action.'`
  794. exit 1
  795. fi
  796. getpid
  797. if [ "X$pid" != "X" ] ; then
  798. eval echo `gettext '$APP_LONG_NAME is already running.'`
  799. exit 1
  800. fi
  801. # If the daemon was just installed, it may not be loaded.
  802. LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}`
  803. if [ "X${LOADED_PLIST}" = "X" ] ; then
  804. launchctl load /Library/LaunchDaemons/${APP_PLIST}
  805. fi
  806. # If launchd is set to run the daemon already at Load, we don't need to call start
  807. getpid
  808. if [ "X$pid" == "X" ] ; then
  809. launchctl start ${APP_PLIST_BASE}
  810. fi
  811. startwait
  812. }
  813. upstartstart() {
  814. # The daemon has been installed.
  815. eval echo `gettext 'Starting $APP_LONG_NAME. Detected Linux and installed upstart.'`
  816. if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then
  817. eval echo `gettext 'Must be root to perform this action.'`
  818. exit 1
  819. fi
  820. getpid
  821. if [ "X$pid" != "X" ] ; then
  822. eval echo `gettext '$APP_LONG_NAME is already running.'`
  823. exit 1
  824. fi
  825. /sbin/start ${APP_NAME}
  826. startwait
  827. }
  828. start() {
  829. eval echo `gettext 'Starting $APP_LONG_NAME...'`
  830. getpid
  831. if [ "X$pid" = "X" ]
  832. then
  833. prepAdditionalParams "$@"
  834. # The string passed to eval must handles spaces in paths correctly.
  835. COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.15 $ADDITIONAL_PARA"
  836. eval $COMMAND_LINE
  837. else
  838. eval echo `gettext '$APP_LONG_NAME is already running.'`
  839. exit 1
  840. fi
  841. startwait
  842. }
  843. stopit() {
  844. # $1 exit if down flag
  845. eval echo `gettext 'Stopping $APP_LONG_NAME...'`
  846. getpid
  847. if [ "X$pid" = "X" ]
  848. then
  849. eval echo `gettext '$APP_LONG_NAME was not running.'`
  850. if [ "X$1" = "X1" ]
  851. then
  852. exit 1
  853. fi
  854. else
  855. if [ "X$IGNORE_SIGNALS" = "X" ]
  856. then
  857. # Running so try to stop it.
  858. kill $pid
  859. if [ $? -ne 0 ]
  860. then
  861. # An explanation for the failure should have been given
  862. eval echo `gettext 'Unable to stop $APP_LONG_NAME.'`
  863. exit 1
  864. fi
  865. else
  866. rm -f "$ANCHORFILE"
  867. if [ -f "$ANCHORFILE" ]
  868. then
  869. # An explanation for the failure should have been given
  870. eval echo `gettext 'Unable to stop $APP_LONG_NAME.'`
  871. exit 1
  872. fi
  873. fi
  874. # We can not predict how long it will take for the wrapper to
  875. # actually stop as it depends on settings in wrapper.conf.
  876. # Loop until it does.
  877. savepid=$pid
  878. CNT=0
  879. TOTCNT=0
  880. while [ "X$pid" != "X" ]
  881. do
  882. # Show a waiting message every 5 seconds.
  883. if [ "$CNT" -lt "5" ]
  884. then
  885. CNT=`expr $CNT + 1`
  886. else
  887. eval echo `gettext 'Waiting for $APP_LONG_NAME to exit...'`
  888. CNT=0
  889. fi
  890. TOTCNT=`expr $TOTCNT + 1`
  891. sleep 1
  892. testpid
  893. done
  894. pid=$savepid
  895. testpid
  896. if [ "X$pid" != "X" ]
  897. then
  898. eval echo `gettext 'Failed to stop $APP_LONG_NAME.'`
  899. exit 1
  900. else
  901. eval echo `gettext 'Stopped $APP_LONG_NAME.'`
  902. fi
  903. fi
  904. }
  905. pause() {
  906. eval echo `gettext 'Pausing $APP_LONG_NAME.'`
  907. }
  908. resume() {
  909. eval echo `gettext 'Resuming $APP_LONG_NAME.'`
  910. }
  911. status() {
  912. getpid
  913. if [ "X$pid" = "X" ]
  914. then
  915. eval echo `gettext '$APP_LONG_NAME is not running.'`
  916. exit 1
  917. else
  918. if [ "X$DETAIL_STATUS" = "X" ]
  919. then
  920. eval echo `gettext '$APP_LONG_NAME is running: PID:$pid'`
  921. else
  922. getstatus
  923. eval echo `gettext '$APP_LONG_NAME is running: PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS'`
  924. fi
  925. exit 0
  926. fi
  927. }
  928. installUpstart() {
  929. eval echo `gettext ' Installing the $APP_LONG_NAME daemon using upstart..'`
  930. if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then
  931. eval echo `gettext ' a custom upstart conf file ${APP_NAME}.install found'`
  932. cp "${REALDIR}/${APP_NAME}.install" "/etc/init/${APP_NAME}.conf"
  933. else
  934. eval echo `gettext ' creating default upstart conf file..'`
  935. echo "# ${APP_NAME} - ${APP_LONG_NAME}" > "/etc/init/${APP_NAME}.conf"
  936. echo "description \"${APP_LONG_NAME}\"" >> "/etc/init/${APP_NAME}.conf"
  937. echo "author \"Tanuki Software Ltd. <info@tanukisoftware.com>\"" >> "/etc/init/${APP_NAME}.conf"
  938. echo "start on runlevel [2345]" >> "/etc/init/${APP_NAME}.conf"
  939. echo "stop on runlevel [!2345]" >> "/etc/init/${APP_NAME}.conf"
  940. echo "env LANG=${LANG}" >> "/etc/init/${APP_NAME}.conf"
  941. echo "exec \"${REALPATH}\" upstartinternal" >> "/etc/init/${APP_NAME}.conf"
  942. fi
  943. }
  944. installdaemon() {
  945. if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then
  946. eval echo `gettext 'Must be root to perform this action.'`
  947. exit 1
  948. else
  949. APP_NAME_LOWER=`echo "$APP_NAME" | $TREXE "[A-Z]" "[a-z]"`
  950. if [ "$DIST_OS" = "solaris" ] ; then
  951. eval echo `gettext 'Detected Solaris:'`
  952. if [ -f /etc/init.d/$APP_NAME ] ; then
  953. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  954. exit 1
  955. else
  956. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  957. ln -s "$REALPATH" "/etc/init.d/$APP_NAME"
  958. ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/K20$APP_NAME_LOWER"
  959. ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S20$APP_NAME_LOWER"
  960. fi
  961. elif [ "$DIST_OS" = "linux" ] ; then
  962. if [ -f /etc/redhat-release -o -f /etc/redhat_version -o -f /etc/fedora-release ] ; then
  963. eval echo `gettext 'Detected RHEL or Fedora:'`
  964. if [ -f "/etc/init.d/$APP_NAME" -o -f "/etc/init/${APP_NAME}.conf" ] ; then
  965. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  966. exit 1
  967. else
  968. if [ -n "$USE_UPSTART" -a -d "/etc/init" ] ; then
  969. installUpstart
  970. else
  971. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  972. ln -s "$REALPATH" "/etc/init.d/$APP_NAME"
  973. /sbin/chkconfig --add "$APP_NAME"
  974. /sbin/chkconfig "$APP_NAME" on
  975. fi
  976. fi
  977. elif [ -f /etc/SuSE-release ] ; then
  978. eval echo `gettext 'Detected SuSE or SLES:'`
  979. if [ -f "/etc/init.d/$APP_NAME" ] ; then
  980. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  981. exit 1
  982. else
  983. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  984. ln -s "$REALPATH" "/etc/init.d/$APP_NAME"
  985. insserv "/etc/init.d/$APP_NAME"
  986. fi
  987. elif [ -f /etc/lsb-release ] ; then
  988. eval echo `gettext 'Detected Ubuntu:'`
  989. if [ -f "/etc/init.d/$APP_NAME" -o -f "/etc/init/${APP_NAME}.conf" ] ; then
  990. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  991. exit 1
  992. else
  993. if [ -n "$USE_UPSTART" -a -d "/etc/init" ] ; then
  994. installUpstart
  995. else
  996. eval echo `gettext ' Installing the $APP_LONG_NAME daemon using init.d..'`
  997. ln -s "$REALPATH" "/etc/init.d/$APP_NAME"
  998. update-rc.d "$APP_NAME" defaults
  999. fi
  1000. fi
  1001. else
  1002. eval echo `gettext 'Detected Linux:'`
  1003. if [ -f "/etc/init.d/$APP_NAME" ] ; then
  1004. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  1005. exit 1
  1006. else
  1007. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  1008. ln -s "$REALPATH" /etc/init.d/$APP_NAME
  1009. ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/K20$APP_NAME_LOWER"
  1010. ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S20$APP_NAME_LOWER"
  1011. ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/S20$APP_NAME_LOWER"
  1012. ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/K20$APP_NAME_LOWER"
  1013. fi
  1014. fi
  1015. elif [ "$DIST_OS" = "hpux" ] ; then
  1016. eval echo `gettext 'Detected HP-UX:'`
  1017. if [ -f "/sbin/init.d/$APP_NAME" ] ; then
  1018. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  1019. exit 1
  1020. else
  1021. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  1022. ln -s "$REALPATH" "/sbin/init.d/$APP_NAME"
  1023. ln -s "/sbin/init.d/$APP_NAME" "/sbin/rc3.d/K20$APP_NAME_LOWER"
  1024. ln -s "/sbin/init.d/$APP_NAME" "/sbin/rc3.d/S20$APP_NAME_LOWER"
  1025. fi
  1026. elif [ "$DIST_OS" = "aix" ] ; then
  1027. eval echo `gettext 'Detected AIX:'`
  1028. if [ -f "/etc/rc.d/init.d/$APP_NAME" ] ; then
  1029. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed as rc.d script.'`
  1030. exit 1
  1031. elif [ -n "`/usr/sbin/lsitab $APP_NAME`" -a -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then
  1032. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed as SRC service.'`
  1033. exit 1
  1034. else
  1035. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  1036. if [ -n "`/usr/sbin/lsitab install_assist`" ] ; then
  1037. eval echo `gettext ' The task /usr/sbin/install_assist was found in the inittab, this might cause problems for all subsequent tasks to launch at this process is known to block the init task. Please make sure this task is not needed anymore and remove/deactivate it.'`
  1038. fi
  1039. /usr/bin/mkssys -s "$APP_NAME" -p "$REALPATH" -a "launchdinternal" -u 0 -f 9 -n 15 -S
  1040. /usr/sbin/mkitab "$APP_NAME":2:once:"/usr/bin/startsrc -s \"${APP_NAME}\" >/dev/console 2>&1"
  1041. fi
  1042. elif [ "$DIST_OS" = "freebsd" ] ; then
  1043. eval echo `gettext 'Detected FreeBSD:'`
  1044. if [ -f "/etc/rc.d/$APP_NAME" ] ; then
  1045. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  1046. exit 1
  1047. else
  1048. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  1049. sed -i .bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf
  1050. if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then
  1051. ln -s "${REALDIR}/${APP_NAME}.install" "/etc/rc.d/$APP_NAME"
  1052. else
  1053. echo '#!/bin/sh' > "/etc/rc.d/$APP_NAME"
  1054. echo "#" >> "/etc/rc.d/$APP_NAME"
  1055. echo "# PROVIDE: $APP_NAME" >> "/etc/rc.d/$APP_NAME"
  1056. echo "# REQUIRE: NETWORKING" >> "/etc/rc.d/$APP_NAME"
  1057. echo "# KEYWORD: shutdown" >> "/etc/rc.d/$APP_NAME"
  1058. echo ". /etc/rc.subr" >> "/etc/rc.d/$APP_NAME"
  1059. echo "name=\"$APP_NAME\"" >> "/etc/rc.d/$APP_NAME"
  1060. echo "rcvar=\`set_rcvar\`" >> "/etc/rc.d/$APP_NAME"
  1061. echo "command=\"${REALPATH}\"" >> "/etc/rc.d/$APP_NAME"
  1062. echo 'start_cmd="${name}_start"' >> "/etc/rc.d/$APP_NAME"
  1063. echo 'load_rc_config $name' >> "/etc/rc.d/$APP_NAME"
  1064. echo 'status_cmd="${name}_status"' >> "/etc/rc.d/$APP_NAME"
  1065. echo 'stop_cmd="${name}_stop"' >> "/etc/rc.d/$APP_NAME"
  1066. echo "${APP_NAME}_status() {" >> "/etc/rc.d/$APP_NAME"
  1067. echo '${command} status' >> "/etc/rc.d/$APP_NAME"
  1068. echo '}' >> "/etc/rc.d/$APP_NAME"
  1069. echo "${APP_NAME}_stop() {" >> "/etc/rc.d/$APP_NAME"
  1070. echo '${command} stop' >> "/etc/rc.d/$APP_NAME"
  1071. echo '}' >> "/etc/rc.d/$APP_NAME"
  1072. echo "${APP_NAME}_start() {" >> "/etc/rc.d/$APP_NAME"
  1073. echo '${command} start' >> "/etc/rc.d/$APP_NAME"
  1074. echo '}' >> "/etc/rc.d/$APP_NAME"
  1075. echo 'run_rc_command "$1"' >> "/etc/rc.d/$APP_NAME"
  1076. fi
  1077. echo "${APP_NAME}_enable=\"YES\"" >> /etc/rc.conf
  1078. chmod 555 "/etc/rc.d/$APP_NAME"
  1079. fi
  1080. elif [ "$DIST_OS" = "macosx" ] ; then
  1081. eval echo `gettext 'Detected Mac OSX:'`
  1082. if [ -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then
  1083. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  1084. exit 1
  1085. else
  1086. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  1087. if [ -f "${REALDIR}/${APP_PLIST}" ] ; then
  1088. ln -s "${REALDIR}/${APP_PLIST}" "/Library/LaunchDaemons/${APP_PLIST}"
  1089. else
  1090. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > "/Library/LaunchDaemons/${APP_PLIST}"
  1091. echo "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1092. echo "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1093. echo "<plist version=\"1.0\">" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1094. echo " <dict>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1095. echo " <key>Label</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1096. echo " <string>${APP_PLIST_BASE}</string>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1097. echo " <key>ProgramArguments</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1098. echo " <array>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1099. echo " <string>${REALPATH}</string>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1100. echo " <string>launchdinternal</string>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1101. echo " </array>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1102. echo " <key>OnDemand</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1103. echo " <true/>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1104. echo " <key>RunAtLoad</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1105. echo " <true/>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1106. if [ "X$RUN_AS_USER" != "X" ] ; then
  1107. echo " <key>UserName</key>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1108. echo " <string>${RUN_AS_USER}</string>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1109. fi
  1110. echo " </dict>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1111. echo "</plist>" >> "/Library/LaunchDaemons/${APP_PLIST}"
  1112. fi
  1113. chmod 555 "/Library/LaunchDaemons/${APP_PLIST}"
  1114. fi
  1115. elif [ "$DIST_OS" = "zos" ] ; then
  1116. eval echo `gettext 'Detected z/OS:'`
  1117. if [ -f /etc/rc.bak ] ; then
  1118. eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'`
  1119. exit 1
  1120. else
  1121. eval echo `gettext ' Installing the $APP_LONG_NAME daemon..'`
  1122. cp /etc/rc /etc/rc.bak
  1123. sed "s:echo /etc/rc script executed, \`date\`::g" /etc/rc.bak > /etc/rc
  1124. echo "_BPX_JOBNAME='${APP_NAME}' \"${REALDIR}/${APP_NAME}\" start" >>/etc/rc
  1125. echo '/etc/rc script executed, `date`' >>/etc/rc
  1126. fi
  1127. else
  1128. eval echo `gettext 'Install not currently supported for $DIST_OS'`
  1129. exit 1
  1130. fi
  1131. fi
  1132. }
  1133. removedaemon() {
  1134. if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then
  1135. eval echo `gettext 'Must be root to perform this action.'`
  1136. exit 1
  1137. else
  1138. APP_NAME_LOWER=`echo "$APP_NAME" | $TREXE "[A-Z]" "[a-z]"`
  1139. if [ "$DIST_OS" = "solaris" ] ; then
  1140. eval echo `gettext 'Detected Solaris:'`
  1141. if [ -f "/etc/init.d/$APP_NAME" ] ; then
  1142. stopit "0"
  1143. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1144. for i in "/etc/rc3.d/S20$APP_NAME_LOWER" "/etc/rc3.d/K20$APP_NAME_LOWER" "/etc/init.d/$APP_NAME"
  1145. do
  1146. rm -f $i
  1147. done
  1148. else
  1149. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1150. exit 1
  1151. fi
  1152. elif [ "$DIST_OS" = "linux" ] ; then
  1153. if [ -f /etc/redhat-release -o -f /etc/redhat_version -o -f /etc/fedora-release ] ; then
  1154. eval echo `gettext 'Detected RHEL or Fedora:'`
  1155. if [ -f "/etc/init.d/$APP_NAME" ] ; then
  1156. stopit "0"
  1157. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1158. /sbin/chkconfig "$APP_NAME" off
  1159. /sbin/chkconfig --del "$APP_NAME"
  1160. rm -f "/etc/init.d/$APP_NAME"
  1161. elif [ -f "/etc/init/${APP_NAME}.conf" ] ; then
  1162. stopit "0"
  1163. eval echo `gettext ' Removing $APP_LONG_NAME daemon from upstart...'`
  1164. rm "/etc/init/${APP_NAME}.conf"
  1165. else
  1166. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1167. exit 1
  1168. fi
  1169. elif [ -f /etc/SuSE-release ] ; then
  1170. eval echo `gettext 'Detected SuSE or SLES:'`
  1171. if [ -f "/etc/init.d/$APP_NAME" ] ; then
  1172. stopit "0"
  1173. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1174. insserv -r "/etc/init.d/$APP_NAME"
  1175. rm -f "/etc/init.d/$APP_NAME"
  1176. else
  1177. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1178. exit 1
  1179. fi
  1180. elif [ -f /etc/lsb-release ] ; then
  1181. eval echo `gettext 'Detected Ubuntu:'`
  1182. if [ -f "/etc/init.d/$APP_NAME" ] ; then
  1183. stopit "0"
  1184. eval echo `gettext ' Removing $APP_LONG_NAME daemon from init.d...'`
  1185. update-rc.d -f "$APP_NAME" remove
  1186. rm -f "/etc/init.d/$APP_NAME"
  1187. elif [ -f "/etc/init/${APP_NAME}.conf" ] ; then
  1188. stopit "0"
  1189. eval echo `gettext ' Removing $APP_LONG_NAME daemon from upstart...'`
  1190. rm "/etc/init/${APP_NAME}.conf"
  1191. else
  1192. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1193. exit 1
  1194. fi
  1195. else
  1196. eval echo `gettext 'Detected Linux:'`
  1197. if [ -f "/etc/init.d/$APP_NAME" ] ; then
  1198. stopit "0"
  1199. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1200. for i in "/etc/rc3.d/K20$APP_NAME_LOWER" "/etc/rc5.d/K20$APP_NAME_LOWER" "/etc/rc3.d/S20$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" "/etc/rc5.d/S20$APP_NAME_LOWER"
  1201. do
  1202. rm -f $i
  1203. done
  1204. else
  1205. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1206. exit 1
  1207. fi
  1208. fi
  1209. elif [ "$DIST_OS" = "hpux" ] ; then
  1210. eval echo `gettext 'Detected HP-UX:'`
  1211. if [ -f "/sbin/init.d/$APP_NAME" ] ; then
  1212. stopit "0"
  1213. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1214. for i in "/sbin/rc3.d/K20$APP_NAME_LOWER" "/sbin/rc3.d/S20$APP_NAME_LOWER" "/sbin/init.d/$APP_NAME"
  1215. do
  1216. rm -f $i
  1217. done
  1218. else
  1219. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1220. exit 1
  1221. fi
  1222. elif [ "$DIST_OS" = "aix" ] ; then
  1223. eval echo `gettext 'Detected AIX:'`
  1224. if [ -f "/etc/rc.d/init.d/$APP_NAME" -o -n "`/usr/sbin/lsitab $APP_NAME`" -o -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then
  1225. stopit "0"
  1226. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1227. if [ -f "/etc/rc.d/init.d/$APP_NAME" ] ; then
  1228. for i in "/etc/rc.d/rc2.d/S20$APP_NAME_LOWER" "/etc/rc.d/rc2.d/K20$APP_NAME_LOWER" "/etc/rc.d/init.d/$APP_NAME"
  1229. do
  1230. rm -f $i
  1231. done
  1232. fi
  1233. if [ -n "`/usr/sbin/lsitab $APP_NAME`" -o -n "`/usr/bin/lssrc -S -s $APP_NAME`" ] ; then
  1234. /usr/sbin/rmitab $APP_NAME
  1235. /usr/bin/rmssys -s $APP_NAME
  1236. fi
  1237. else
  1238. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1239. exit 1
  1240. fi
  1241. elif [ "$DIST_OS" = "freebsd" ] ; then
  1242. eval echo `gettext 'Detected FreeBSD:'`
  1243. if [ -f "/etc/rc.d/$APP_NAME" ] ; then
  1244. stopit "0"
  1245. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1246. for i in "/etc/rc.d/$APP_NAME"
  1247. do
  1248. rm -f $i
  1249. done
  1250. sed -i .bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf
  1251. else
  1252. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1253. exit 1
  1254. fi
  1255. elif [ "$DIST_OS" = "macosx" ] ; then
  1256. eval echo `gettext 'Detected Mac OSX:'`
  1257. if [ -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then
  1258. stopit "0"
  1259. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1260. # Make sure the plist is installed
  1261. LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}`
  1262. if [ "X${LOADED_PLIST}" != "X" ] ; then
  1263. launchctl unload "/Library/LaunchDaemons/${APP_PLIST}"
  1264. fi
  1265. rm -f "/Library/LaunchDaemons/${APP_PLIST}"
  1266. else
  1267. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1268. exit 1
  1269. fi
  1270. elif [ "$DIST_OS" = "zos" ] ; then
  1271. eval echo `gettext 'Detected z/OS:'`
  1272. if [ -f /etc/rc.bak ] ; then
  1273. stopit "0"
  1274. eval echo `gettext ' Removing $APP_LONG_NAME daemon...'`
  1275. cp /etc/rc /etc/rc.bak
  1276. sed "s/_BPX_JOBNAME=\'APP_NAME\'.*//g" /etc/rc.bak > /etc/rc
  1277. rm /etc/rc.bak
  1278. else
  1279. eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'`
  1280. exit 1
  1281. fi
  1282. else
  1283. eval echo `gettext 'Remove not currently supported for $DIST_OS'`
  1284. exit 1
  1285. fi
  1286. fi
  1287. }
  1288. dump() {
  1289. eval echo `gettext 'Dumping $APP_LONG_NAME...'`
  1290. getpid
  1291. if [ "X$pid" = "X" ]
  1292. then
  1293. eval echo `gettext '$APP_LONG_NAME was not running.'`
  1294. else
  1295. kill -3 $pid
  1296. if [ $? -ne 0 ]
  1297. then
  1298. eval echo `gettext 'Failed to dump $APP_LONG_NAME.'`
  1299. exit 1
  1300. else
  1301. eval echo `gettext 'Dumped $APP_LONG_NAME.'`
  1302. fi
  1303. fi
  1304. }
  1305. # Used by HP-UX init scripts.
  1306. startmsg() {
  1307. getpid
  1308. if [ "X$pid" = "X" ]
  1309. then
  1310. eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:Stopped'`
  1311. else
  1312. if [ "X$DETAIL_STATUS" = "X" ]
  1313. then
  1314. eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:Running'`
  1315. else
  1316. getstatus
  1317. eval echo `gettext 'Starting $APP_LONG_NAME... Wrapper:$STATUS, Java:$JAVASTATUS'`
  1318. fi
  1319. fi
  1320. }
  1321. # Used by HP-UX init scripts.
  1322. stopmsg() {
  1323. getpid
  1324. if [ "X$pid" = "X" ]
  1325. then
  1326. eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:Stopped'`
  1327. else
  1328. if [ "X$DETAIL_STATUS" = "X" ]
  1329. then
  1330. eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:Running'`
  1331. else
  1332. getstatus
  1333. eval echo `gettext 'Stopping $APP_LONG_NAME... Wrapper:$STATUS, Java:$JAVASTATUS'`
  1334. fi
  1335. fi
  1336. }
  1337. showUsage() {
  1338. # $1 bad command
  1339. if [ -n "$1" ]
  1340. then
  1341. eval echo `gettext 'Unexpected command: $1'`
  1342. echo "";
  1343. fi
  1344. eval MSG=`gettext 'Usage: '`
  1345. if [ -n "$FIXED_COMMAND" ] ; then
  1346. if [ -n "$PASS_THROUGH" ] ; then
  1347. echo "${MSG} $0 {JavaAppArgs}"
  1348. else
  1349. echo "${MSG} $0"
  1350. fi
  1351. else
  1352. if [ -n "$PAUSABLE" ] ; then
  1353. if [ -n "$PASS_THROUGH" ] ; then
  1354. echo "${MSG} $0 [ console {JavaAppArgs} | start {JavaAppArgs} | stop | restart {JavaAppArgs} | condrestart {JavaAppArgs} | pause | resume | status | install | remove | dump ]"
  1355. else
  1356. echo "${MSG} $0 [ console | start | stop | restart | condrestart | pause | resume | status | install | remove | dump ]"
  1357. fi
  1358. else
  1359. if [ -n "$PASS_THROUGH" ] ; then
  1360. echo "${MSG} $0 [ console {JavaAppArgs} | start {JavaAppArgs} | stop | restart {JavaAppArgs} | condrestart {JavaAppArgs} | status | install | remove | dump ]"
  1361. else
  1362. echo "${MSG} $0 [ console | start | stop | restart | condrestart | status | install | remove | dump ]"
  1363. fi
  1364. fi
  1365. fi
  1366. if [ ! -n "$BRIEF_USAGE" ]
  1367. then
  1368. echo "";
  1369. if [ ! -n "$FIXED_COMMAND" ] ; then
  1370. echo "`gettext 'Commands:'`"
  1371. echo "`gettext ' console Launch in the current console.'`"
  1372. echo "`gettext ' start Start in the background as a daemon process.'`"
  1373. echo "`gettext ' stop Stop if running as a daemon or in another console.'`"
  1374. echo "`gettext ' restart Stop if running and then start.'`"
  1375. echo "`gettext ' condrestart Restart only if already running.'`"
  1376. if [ -n "$PAUSABLE" ] ; then
  1377. echo "`gettext ' pause Pause if running.'`"
  1378. echo "`gettext ' resume Resume if paused.'`"
  1379. fi
  1380. echo "`gettext ' status Query the current status.'`"
  1381. echo "`gettext ' install Install to start automatically when system boots.'`"
  1382. echo "`gettext ' remove Uninstall.'`"
  1383. echo "`gettext ' dump Request a Java thread dump if running.'`"
  1384. echo "";
  1385. fi
  1386. if [ -n "$PASS_THROUGH" ] ; then
  1387. echo "`gettext 'JavaAppArgs: Zero or more arguments which will be passed to the Java application.'`"
  1388. echo "";
  1389. fi
  1390. fi
  1391. exit 1
  1392. }
  1393. docommand() {
  1394. case "$COMMAND" in
  1395. 'console')
  1396. checkUser touchlock "$@"
  1397. if [ ! -n "$FIXED_COMMAND" ] ; then
  1398. shift
  1399. fi
  1400. console "$@"
  1401. ;;
  1402. 'start')
  1403. if [ "$DIST_OS" = "macosx" -a -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then
  1404. macosxstart
  1405. elif [ "$DIST_OS" = "linux" -a -f "/etc/init/${APP_NAME}.conf" ] ; then
  1406. upstartstart
  1407. else
  1408. checkUser touchlock "$@"
  1409. if [ ! -n "$FIXED_COMMAND" ] ; then
  1410. shift
  1411. fi
  1412. start "$@"
  1413. fi
  1414. ;;
  1415. 'stop')
  1416. checkUser "" "$COMMAND"
  1417. stopit "0"
  1418. ;;
  1419. 'restart')
  1420. checkUser touchlock "$COMMAND"
  1421. if [ ! -n "$FIXED_COMMAND" ] ; then
  1422. shift
  1423. fi
  1424. stopit "0"
  1425. start "$@"
  1426. ;;
  1427. 'condrestart')
  1428. checkUser touchlock "$COMMAND"
  1429. if [ ! -n "$FIXED_COMMAND" ] ; then
  1430. shift
  1431. fi
  1432. stopit "1"
  1433. start "$@"
  1434. ;;
  1435. 'pause')
  1436. if [ -n "$PAUSABLE" ]
  1437. then
  1438. pause
  1439. else
  1440. showUsage "$COMMAND"
  1441. fi
  1442. ;;
  1443. 'resume')
  1444. if [ -n "$PAUSABLE" ]
  1445. then
  1446. resume
  1447. else
  1448. showUsage "$COMMAND"
  1449. fi
  1450. ;;
  1451. 'status')
  1452. status
  1453. ;;
  1454. 'install')
  1455. installdaemon
  1456. ;;
  1457. 'remove')
  1458. removedaemon
  1459. ;;
  1460. 'dump')
  1461. checkUser "" "$COMMAND"
  1462. dump
  1463. ;;
  1464. 'start_msg')
  1465. # Internal command called by launchd on HP-UX.
  1466. checkUser "" "$COMMAND"
  1467. startmsg
  1468. ;;
  1469. 'stop_msg')
  1470. # Internal command called by launchd on HP-UX.
  1471. checkUser "" "$COMMAND"
  1472. stopmsg
  1473. ;;
  1474. 'launchdinternal' | 'upstartinternal')
  1475. if [ ! "$DIST_OS" = "macosx" -o ! -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then
  1476. checkUser touchlock "$@"
  1477. fi
  1478. # Internal command called by launchd on Max OSX.
  1479. # We do not want to call checkUser here as it is handled in the launchd plist file. Doing it here would confuse launchd.
  1480. if [ ! -n "$FIXED_COMMAND" ] ; then
  1481. shift
  1482. fi
  1483. launchinternal "$@"
  1484. ;;
  1485. *)
  1486. showUsage "$COMMAND"
  1487. ;;
  1488. esac
  1489. }
  1490. docommand "$@"
  1491. exit 0