Mad MAX85
Cadet 4th Year
- Dabei seit
- Nov. 2004
- Beiträge
- 73
Hallo.
Ich brächte mal ein Script was MLDonkey Stopt wenn ein bestimmter PC im netzwerk online ist, und es wieder Startet wenn er wieder offline ist....
Einen Ansatz habe ich schon...
P.s. Ich habs nicht so extrem mit Linux... bin noch ziemlicher Anfänger...
MfG
Mad MAX85
Ich brächte mal ein Script was MLDonkey Stopt wenn ein bestimmter PC im netzwerk online ist, und es wieder Startet wenn er wieder offline ist....
Einen Ansatz habe ich schon...
Code:
#!/bin/sh
#
# MLDonkey start/stop script - (c) 2003 Lucas Peetz Dulley
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# DESCRIPTION:
# An useful and simple(?) script for starting, stopping and restarting
# MLDonkey as a daemon.
#
# REQUIRES:
# - bash, ps, wc, grep, awk and netcat.
#
# INSTALL:
# - become root
# - copy this file to /etc/init.d/
# - make the file executable "chmod +x /etc/init.d/MLDonkey"
# - create links in the rc.* (in Debian: "update-rc.d MLDonkey defaults")
#
# USAGE:
# - run "/etc/init.d/MLDonkey start" (to start)
# - run "/etc/init.d/MLDonkey stop" (to stop)
# - run "/etc/init.d/MLDonkey restart" (to restart)
#
## BEGIN USER CONFIGURATION ##
#
# Set running directory and username (not root).
MLDONKEYDIR=/full/path/to/mldonkey/directory/
USERNAME=username
#
# Set Netcat's (TCP/IP swiss army knife) filename - usually "nc" or "netcat"
NETCAT=nc
#
## END USER CONFIGURATION ##
status() {
PID=`ps ax -o "pid user command" | grep -E [[:space:]]\{3\}./mlnet | awk {'print $1'}`
if [ $PID ];then
if [ `ps -p $PID | wc -l` -eq 2 ]; then
echo "mldonkey (pid $PID) running..."
return 1
else
echo "Stale PID"
fi
fi
echo "mldonkey is stopped"
return 0
}
start() {
# see if there is a mldonkey running
status &> /dev/null
if [ $? = 0 ]; then
echo "Starting mldonkey:"
cd $MLDONKEYDIR
# Remove old servers
rm -rf servers.ini*
# Remove tmp files
rm -rf *.tmp
# Run MLDonkey
su $USERNAME -c "nice -+19 ./mlnet -daemon &> /dev/null"
fi
return 0
}
stop() {
status &> /dev/null
if [ $? = 1 ]; then
echo "Stopping mldonkey:"
cd $MLDONKEYDIR
bash -c "$NETCAT 127.0.0.1 4000 <<STOPHERE
close_fds
kill
STOPHERE" &> /dev/null
sleep 10
return 0
fi
return 1
}
case "$1" in
'status')
status ;;
'start')
start ;;
'stop')
stop ;;
'restart')
stop
start ;;
*)
echo "usage $0 start|stop|restart"
exit 1 ;;
esac
exit $?
##-- eof
MfG
Mad MAX85
Zuletzt von einem Moderator bearbeitet: