distributed.net
(Answer) (Category) distributed.net Faq-O-Matic : (Category) the Client software : (Category) Automatically starting the client at boot time : (Answer) Unix
All Unix systems are capable of starting the distributed.net client from a boot script or script in a boot script directory.

The quick and dirty way:

  • On BSD systems (FreeBSD, OpenBSD, NetBSD, BSD/OS, MacOS X etc):
    simply add '/path/to/dnetc -quiet' to /etc/rc.local
  • On SysV systems (UnixWare, Linux, Solaris etc):
    simply add '/path/to/dnetc -quiet' to /etc/rc.d/rc.local
    Note that this is not a good thing to do on SysV since the OS will simply kill the client when it shuts down (to be more precise, it will send a SIGTERM first, but a SIGKILL almost immediately after it).

The long way:

  • On BSD systems, each application may have its own startup script. These are generally located in /usr/local/etc/rc.d/. A script to start the client could look something like this:
    #!/bin/sh
    if [ -x /path/to/dnetc ]; then
      /path/to/dnetc -quiet
      echo -n " dnetc"
    fi
    
    The client will be stopped with a SIGTERM when when the machine is shutdown or rebooted.

  • SysV systems have a more complex init/shutdown sequence. Your OS probably has a man page for it. init(8) usually, 'apropos init' may show more.

    [2.8011-464 and above support -[un]install for Linux (SysV-style)]

    Create a file called '/etc[/rc.d]/init.d/dnetc' that looks like this:

        #!/bin/sh
        if [ -x /path/to/dnetc ]; then
           case "$1" in 
               *start)
                  #make sure we're only running one client
                  /path/to/dnetc -quiet -shutdown
                  /path/to/dnetc -quiet
                  echo "Started distributed.net client"
                  ;;
               *stop)
                  /path/to/dnetc -quiet -shutdown
                  echo "Stopped distributed.net client"
                  sleep 2
                  ;;
               *)
                  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/K10dnetc
        ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc1.d/K10dnetc
        ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc6.d/K10dnetc
        
    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/S90dnetc
        ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc3.d/S90dnetc
        ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc4.d/S90dnetc
        ln -s /etc[/rc.d]/init.d/dnetc /etc[/rc.d]/rc5.d/S90dnetc
        
    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.


This was submitted by Marc Barilley (barilley@noos.fr), and apparently works on Mandrake (but should work as well on RedHat).


Here it is. Distributed.net client is supposed to be in /home/dnetc and a user called 'dnetc' must exist on the system. The script launches dnetc as user 'dnetc' instead of 'root'. This is to controll the user's rights.

#!/bin/sh #Source function library. if [ -f /etc/init.d/functions ] ; then

   . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
   . /etc/rc.d/init.d/functions
else
  exit 0
fi
RETVAL=0
start() {
 echo -n "Starting Distributed.net client: "
        if [ -f /var/lock/subsys/dnetc ]; then
  failure
  else
   daemon --user=dnetc /home/dnetc/dnetc -quiet
   RETVAL=$?
          [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dnetc || RETVAL=1
  fi
  echo
        return $RETVAL
} stop() {
 echo -n "Shutting down Distributed.net client: "
 killproc /home/dnetc/dnetc -TERM
  RETVAL=$?
  echo
         [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dnetc
         return $RETVAL
}
if [ -x /home/dnetc/dnetc ]; then
 case "$1" in
   start)
        start
      ;;
   stop)
    stop
    ;;
   restart)
    stop
    start
    ;;
   status)
    status /home/dnetc/dnetc
    ;;
   *)
    echo "Syntax: $0 [start|stop|restart|status]"
    exit 1
    ;;
  esac
fi exit 0
This document is: http://faq.distributed.net/?file=84
[Search] [Appearance] [Show Expert Edit Commands]
This is a Faq-O-Matic 2.721.test.

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