I have installed tomcat in /opt/tomcat6 and made one of it's instance in ~/tomcatHost directory.The /opt/tomcat6 is owned by user tomcat and group tomcat. Unix "ls -l" produce following -
drwxr-xr-x 9 tomcat tomcat 4096 Dec 15 03:37 tomcat6
In this case, to run tomcat instance in ~/tomcatHost I need to do the following steps -
- Copy conf, webapps, logs from /opt/tomcat6 to ~/tomcatHost. Make some changes server.xml in ~tomcatHost/conf (eg- changing the port number in "Connector" element)
- give execute permission to ~/tocatHost for all user by chmod -
$ chmod -R 777 tomcatHost
- and run the following commands -
$ export CATALINA_BASE=/home/guestUser/tomcatHost
$ su tomcat
$ cd /opt/tomcat6/bin
$ sh startup.sh
Now the tomcat is start at the port configured in server.xml. I'm trying to write a shell script which do the task performed above. I'm new in shell scripting and can not able to solve this problem. I think there is an ownership issue, can anyone tell me how can I handle the ownership issue in shell script? Or, how can I write a script to run "startup.sh" (owned by tomcat user) from other user. Can you suggest any good tutorial for this?