distributed.net
(Answer) (Category) distributed.net Faq-O-Matic : (Category) the Personal Proxy software : (Answer) Automatically starting the proxyper at boot time (Linux)
This describes the init/shutdown sequence for Linux (SysV systems).
Create a file called '/etc[/rc.d]/init.d/proxyper' that looks like this:

  #!/bin/sh
  if [ -x /path/to/proxyper ]; then
        case "$1" in
                *start)
                        if [ -f /path/to/rc5desproxy.pid ]; then
                                proxyper_pid=$(cat /path/to/rc5desproxy.pid )
                                kill -15 $proxyper_pid
                        fi
                        /path/to/proxyper -detach
                        echo "started distributed.net personal proxy"
                        ;;
                *stop)
                        if [ -f /path/to/rc5desproxy.pid ]; then
                                proxyper_pid=$(cat /path/to/rc5desproxy.pid )
                                kill -15 $proxyper_pid
                                sleep 2
                                echo "stopped distributed.net personal proxy"
                        fi
                        ;;
                *)
                        echo "Syntax: $0 [start|stop]"
                        exit 1
                        ;;
        esac
  fi
  exit 0
Then create a symlink in each of the /etc[/rc.d]/rc?.d/ subdirectories as follows:
For the 0, 1 and 6 runlevels (halt, single-user and reboot respectively):
    ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc0.d/K10proxyper
    ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc1.d/K10proxyper
    ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc6.d/K10proxyper
    
For the 2, 3, 4 and 5 runlevels: (runlevels 7, 8 and 9 are also valid, but not many unix variants have them)
    ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc2.d/S90proxyper
    ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc3.d/S90proxyper
    ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc4.d/S90proxyper
    ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc5.d/S90proxyper
    
On entering a new runlevel, init(8) will run the scripts in the /etc[/rc.d]/rc[runlevel].d/ directory of the runlevel it is entering. 'K' scripts are 'kill' scripts, and will be run with the "stop" command. 'S' scripts are 'start' scripts, and will be run with "start". More on how scripts are processed may be found in your init(8) man page. According to the above described scheme then, the client will be started on entry into runlevel 2, 3, 4 or 5, and stopped on entry into any other runlevel.
For recent versions of Redhat Linux, this is a more appropriate 
startup script.  Note that you can specify a user to "runas" with
the "runas" variable.

To install this:
1.  Add the script to /etc/rc.d/init.d/proxyper (edit the stuff that
    says "path/to" and "runas" - it should all be at the front of the file.
2.  chkconfig --add proxyper

This should automatically create the symlinks based on the comments at the 
beginning of the script.  They will be addeed with the right names in the 
right directories.

Check your installation with:

chkconfig --list proxyper.

Start the service with 

service proxyper start

The messages will look like the others that are issued by the startup scripts as well.

#!/bin/bash
#
# proxyper      This shell script takes care of starting and stopping
#               rc5des personal proxy.
#
# chkconfig: 2345 86 25
# description: This starts and stops the rc5des personal proxy
# processname: proxyper
# config: /path/to/proxyper
# pidfile: /path/to/proxyper.pid

proxyper="/path/to/proxyper"
pidfile="/path/to/proxyper.pid"
runas="nobody"


# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Source proxyper configureation.
if [ -f /etc/sysconfig/proxyper ] ; then
        . /etc/sysconfig/proxyper
fi

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x "$proxyper" ] || exit 0

RETVAL=0
prog="proxyper"

start() {
    # Start daemons.

    echo -n $"Starting $prog: "
    if [ -f "$pidfile" ]; then
        proxyper_pid=$(cat "$pidfile" )
        kill -15 $proxyper_pid
    fi
    daemon --user "$runas" "$proxyper" -detach
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
    return $RETVAL
}

stop() {
    # Stop daemons.
    echo -n $"Shutting down $prog: "
    killproc $prog
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
    return $RETVAL
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f /var/lock/subsys/$prog ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $RETVAL
This document is: http://faq.distributed.net/?file=262
[Search] [Appearance] [Show Expert Edit Commands]
This is a Faq-O-Matic 2.721.test.

© Copyright distributed.net 1997-2013 - All rights reserved