Hyperic HQ Startup on Ubuntu 9.04

There is an almost complete installation guide to installing Hyperic on Ubuntu here Hyperic on Ubuntu . The only part missing is adding the agent and server as part of the automatic startup. This post shows you how to do this.

To ensure the hyperic agent and server startup automatically each time you reboot or restart try this.
Copy agent.rc file located in HYPERIC_HOME/agent3.1.0/rcfiles.agent.rc to server.rc and modify like below

#!/bin/sh
#
# description: Starts and stops the Hyperic Agent.
#

PROGRAM="Hyperic Server"

#
# Set the USER variable to the user to start the agent as
#
USER=nick

#
# Set SERVER_DIR to your server installation path.
#
SERVER_DIR=/home/hyperic/server-3.1.0/bin

# Set HQ_JAVA_HOME if you want to use a different JDK
# export HQ_JAVA_HOME=/opt/bea/jrockit81sp1_141_03

start() {
    echo -n "Starting $PROGRAM services: "
    su - $USER -c "$SERVER_DIR/hq-server.sh start > /dev/null 2>&1"
    return $?
}	

stop() {
    echo -n "Shutting down $PROGRAM services: "
    su - $USER -c "$SERVER_DIR/hq-server.sh stop > /dev/null 2>&1"
    return $?
}

restart() {
    stop
    start
}	

ping() {
    echo -n "Pinging $PROGRAM"
    su - $USER -c "$SERVER_DIR/hq-server.sh ping > /dev/null 2>&1"
    return $?
}

case "$1" in
start)
    start
    ;;
stop)
    stop
    ;;
restart)
    restart
    ;;
ping)
    ping
    ;;
*)
    echo $"Usage: $0 {start|stop|restart|ping}"
    exit 1
esac
    
exit $?

Make sure you change the USER, PROGRAM and SERVER_DIR as appropriate.

next copy both the agent.rc and server.rc to /etc/init.d

cp /home/hyperic/agent-3.1.0/rcfiles/* /etc/init.d

Update the startup script links using update-rc.d command

sudo update-rc.d agent.rc defaults
sudo update-rc.d server.rc defaults

Next modify the permissions of the files under /etc/init.d to ensure they are executable

sudo chmod 715 agent.rc 
sudo chmod 715 server.rc

Then you are done.