[LUGOS] bash skripta

Uroš Golja goljau at comcom.si
Tue May 10 15:46:53 CEST 2005


Tole je kompletna skripta /etc/init.d/mldonkey-server iz Debiana. Najbrž 
si boš z njo lahko kaj pomagal.

LP,
U.
-------------- next part --------------
#! /bin/sh
#
# Original file :
#    Written by Miquel van Smoorenburg <miquels at cistron.nl>.
#    Modified for Debian GNU/Linux
#    by Ian Murdock <imurdock at gnu.ai.mit.edu>.
#
# Version:  @(#)skeleton  1.9.1  08-Apr-2002  miquels at cistron.nl
#
# 
# This file has been rewritten by Sylvain LE GALL <sylvain.le-gall at m4x.org>
# for mldonkey-package.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
WRAPPER=/usr/bin/mldonkey_server
NAME=mlnet
DESC="MLDonkey"
CONFIG=/etc/default/mldonkey-server
PIDFILE=/var/run/mldonkey/$NAME.pid

test -x $WRAPPER || exit 0

test -e $CONFIG || exit 0

set -e

. $CONFIG

if [ "$LAUNCH_AT_STARTUP" != "true" ]; then
  exit 0
fi

if [ ! -d $MLDONKEY_DIR ]; then
  if [ -z "$MDLONKEY_DIR" ]; then
    MLDONKEY_DIR="(unset)"
  fi
  echo "$MLDONKEY_DIR is not a valid directory"
  exit 0
fi

if [ ! -f $MLDONKEY_DIR/downloads.ini ]; then
  echo "$MLDONKEY_DIR/downloads.ini is not a valid file"
  exit 0
fi

if [ -e $MLDONKEY_DIR/files.ini ] && [ ! -e $MLDONKEY_DIR/files.ini.fasttrack ]; then
  echo "First reboot after Fasttrack problem see /usr/share/doc/mldonkey-server/README.Debian"
  echo -n "Splitting $MLDONKEY_DIR/files.ini to remove Fasttrack files : "
  /usr/bin/mldonkey_files --split Fasttrack -f0 $MLDONKEY_DIR/files.ini \
  -f1 $MLDONKEY_DIR/files.ini.fasttrack \
  -f2 $MLDONKEY_DIR/files.ini 
  echo "done."
fi

USER=`/usr/bin/stat --format="%U" $MLDONKEY_DIR/downloads.ini`

START_STOP_OPTIONS=""

if [ -n "$MLDONKEY_NICENESS" ]; then
  START_STOP_OPTIONS="$START_STOP_OPTIONS --nicelevel $MLDONKEY_NICENESS"
fi

case "$1" in
  start)
    echo -n "Starting $DESC: $NAME"
    
    # export MLDONKEY_CHROOT=$MLDONKEY_DIR

    # BUG : we should not need --background, but if not here, the 
    # invoke-rc.d hangs.
    start-stop-daemon --start --quiet --oknodo --background --pidfile $PIDFILE \
      $START_STOP_OPTIONS --exec $WRAPPER -- \
      --start --pidfile $PIDFILE --chdir $MLDONKEY_DIR --chuid $USER \
      --max-alive $MAX_ALIVE --umask $MLDONKEY_UMASK --daemon
    
    echo "."
  ;;
  stop)
    echo -n "Stopping $DESC: $NAME"
    
    start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE

    echo "."
  ;;
  restart)
    echo -n "Restarting $DESC: $NAME"
    
    start-stop-daemon --stop --oknodo --signal 1 --quiet --pidfile $PIDFILE
    
    echo "."
  ;;
  
  force-reload)
    echo -n "Reloading $DESC: $NAME."
    
    $0 stop
    sleep 1
    $0 start
  ;;
  
  *)
    echo "Usage: $0 {start|stop|restart|force-reload}" >&2
    exit 1
  ;;
esac

exit 0


More information about the lugos-list mailing list