1.先点击这里下载最新版本的glassfish。
解压后放到工程目录下。
然后根据自己的需要修改glassfish/domains/domain1/config/domain.xml文件的配置。
注意config/asenv.conf文件中添加jdk路径,防止JSP报错。
AS_Java=/usr/jdk1.6
2.现在需要几个函数帮助检查用户和组,并能够创建系统用户及其目录,创建用户组,
因此在tool.sh中添加了四个函数:
#$1 user name #return 1 if exists #return 0 if doesn't exist function haSUSEr { h=`grep "$1" /etc/passwd` echo "h: $h" if [ -n "$h" ] then return 1 else return 0 fi } #$1 user group name #return 1 if exists #return 0 if doesn't exist function hasUserGroup { h=`grep "$1" /etc/group` echo "h: $h" if [ -n "$h" ] then return 1 else return 0 fi } #remove user and home folder #then create then again function recreateSystemUserAndFolder { hasUser $1 r=$? if [ $r -eq 1 ] then echo "$1 exits already,remove it..." userdel -r $1 else echo "$1 doesn't exist,create it..." fi adduser --home /home/$1 --system --shell /bin/bash $1 } #remove user group #then create it again function recreateUserGroup { hasUserGroup $1 r=$? if [ $r -eq 1 ] then echo "$1 exists already, remove it..." delgroup $1 else echo "$1 doesn't exist, create it..." fi groupadd $1 }3.现在创建系统服务吧。
准备好glassfish脚本:
export AS_JAVA=/usr/jdk1.6 GLASSFISHPATH=/home/glassfish/bin case "$1" in start) echo "starting glassfish from $GLASSFISHPATH" sudo -u glassfish $GLASSFISHPATH/asadmin start-domain domain1 ;; restart) $0 stop $0 start ;; stop) echo "stopping glassfish from $GLASSFISHPATH" sudo -u glassfish $GLASSFISHPATH/asadmin stop-domain domain1 ;; *) echo $"usage: $0 {start|stop|restart}" exit 3 ;; esac :