Friday, December 31, 2010

Quick Guide setup Auto-Start script on Ubuntu 10.10 - Example nexus

Trick : to run File Browser(nautilus)  as root:
sudo nautilus

The product is installed in: /opt/server/nexus/nexus-oss-webapp-1.6.0/
The logs are in: /opt/server/nexus/nexus-oss-webapp-1.6.0/logs

1-      Give users the access to the logs dir:
sudo chmod -R 777 /opt/server/nexus/nexus-oss-webapp-1.6.0/logs

2-      Create the script and add as below:
sudo gedit /etc/init.d/nexus.sh

-------------------------------------------
# Nexus auto-start
#
# description: Auto-starts nexus
# processname: nexus
# pidfile: /var/run/nexus.pid

export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_23
export PATH=$PATH:$JAVA_HOME/bin
cd /opt/server/nexus/nexus-oss-webapp-1.6.0/bin/jsw/linux-x86-64

case $1 in
start)
     ./nexus start
     ;;
stop) 
     ./nexus stop
     ;;
restart)
     ./nexus restart
     ;;
esac  
exit 0
-------------------------------------------
3-      Make the script executable + link to execute on stop via K99 script and start via script S99

-- Make executable
sudo chmod 755 /etc/init.d/nexus.sh
sudo chmod 755 /opt/server/nexus/nexus-oss-webapp-1.6.0/bin/jsw/linux-x86-32/nexus
sudo chmod 755 /opt/server/nexus/nexus-oss-webapp-1.6.0/bin/jsw/linux-x86-32/wrapper
sudo ln -s /etc/init.d/nexus.sh /etc/rc1.d/K99nexus.sh
sudo ln -s /etc/init.d/nexus.sh /etc/rc2.d/S99nexus.sh

and all done.