如何在启动时自动将启动参数发送到Init脚本?

时间:2012-10-24 13:23:48

标签: shell unix debian

我正在使用debian系统,并希望为myapplication创建一个init启动脚本。在脚本中我有一个用于不同(start | stop | restart)参数的case body。当脚本在启动时启动时,它会进入无限循环,因为它会运行所有参数。这是我的剧本

#! /bin/sh
### BEGIN INIT INFO
# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO


 PATH should only include /usr/* if it runs after the mountnfs.sh script
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 DESC="Studio-service"
 NAME=application-studio
 automatey_nodetype=development
 vmargs="-DencryptorCredentials=currentPass|oldPass|1 -Xms512m -Xmx2048m
 - DLOGGING_HOME=configuration/ -Djava.io.tmpdir=/var/tmp 
 - Dorg.osgi.service.http.port=8081 -Declipse.ignoreApp=true 
 -Dosgi.noShutdown=true -Xdebug -Xnoagent -Djava.compiler=NONE 
  -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n 
  -Djava.net.preferIPv4Stack=true -DapplyDbMigrations=true -XX:MaxPermSize=128m 
  -XX:- HeapDumpOnOutOfMemoryError "
 SCRIPTNAME=/etc/init.d/$NAME
 DAEMON=start.sh
 STUDIO=/opt/application


case "$1" in
start)  
    set -e -x
    cd /opt/application
    ./firewall.sh
    ${STUDIO}/${DAEMON} ${automatey_nodetype} "$echo $vmargs"

;;
stop)
    screen -SX application-studio kill
;;


restart)
    set -e -x
    ${STUDIO}/${DAEMON} ${automatey_nodetype} "$echo $vmargs"
;;
esac

退出0

1 个答案:

答案 0 :(得分:1)

启动时,init脚本使用start参数运行。无需指定任何内容。 也许你需要评论这一行:

  

PATH应该只包含/ usr / *,如果它在mountnfs.sh脚本之后运行