自启动脚本resin放置在/etc/init.d/目录下,如下:
定义环境变量
JAVA_HOME="/usr/local/java/jdk1.6.0_23" #java目录
RESIN_HOME="/usr/local/resin" #resin安装目录
export JAVA_HOME RESIN_HOME
JAVA=$JAVA_HOME/bin/java
USER=
CONF="-conf $RESIN_HOME/conf/resin.conf"
ARGS="-resin-home $RESIN_HOME $SERVER $CONF"
if test -r /lib/lsb/init-functions; then
. /lib/lsb/init-functions
else
log_daemon_msg () {
if [ -z "$1" ]; then
return 1
fi
if [ -z "$2" ]; then
echo -n "$1:"
return
fi
echo -n "$1: $2"
}
log_end_msg () {
[ -z "$1" ] && return 1
if [ $1 -eq 0 ]; then
echo " ."
else
echo " failed!"
fi
return $1
}
fi
case "$1" in
start)
log_daemon_msg "Starting resin"
if test -n "$USER"; then
su $USER -c "$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS start" 1>/dev/null 2>/dev/null
else
$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS start 1>/dev/null 2>/dev/null
fi
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping resin"
if test -n "$USER"; then
su $USER -c "$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS stop" 1>/dev/null 2>/dev/null
else
$JAVA -jar $RESIN_HOME/lib/resin.jar $ARGS stop 1>/dev/null 2>/dev/null
fi
log_end_msg $?
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit 0
阅读(409) | 评论(0) | 转发(0) |