Question

I have a server running Gentoo 2.6.12 r6 and I want to run Apache Archiva as a standalone server at startup. Does anyone have a working init.d script to accomplish this? Thanks!

Was it helpful?

Solution

Assuming that you have created a user account called archiva and Archiva is installed at /opt/archiva-1.0.

While logged as root, create a the script /etc/rc.d/init.d/archiva as follows:

\#! /bin/sh

start() {
    echo "Starting Archiva..."
    su -l archiva -c '/opt/archiva-1.0/bin/archiva start > /dev/null 2> /dev/null &'
}

stop() {
    echo "Stopping Archiva..."
    su -l archiva -c '/opt/archiva-1.0/bin/archiva stop &'
}

restart() {
    stop
    sleep 60
    su -l archiva -c 'killall java'
    start
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        echo "Usage: archiva {start|stop|restart}"
        exit 1

esac

exit 0

Now execute the following commands as root where SXX and KXX specify the startup and shutdown order. For example S63 and K37

$ chmod 775 /etc/rc.d/init.d/archiva
$ ln -s /etc/rc.d/init.d/archiva /etc/rc3.d/SXXarchiva
$ ln -s /etc/rc.d/init.d/archiva /etc/rc3.d/KXXarchiva
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top