|
发表于 2007-3-26 20:03:30
|
显示全部楼层
照猫画虎自己写了个daemon 不管用..
仔细一看 在/etc/rc.d/下已经有个mldonkey.......... - -!
看了下 自己还真写不出来...
终于可以抛弃amule了 没必要在为emule开个Xserver- #!/bin/bash
- if [ "$(id -u)" != 0 ]
- then
- echo "You must be root to start MLDonkey as daemon."
- exit 2
- fi
- # general config
- USEcolor="YES"
- . /etc/mldonkey.conf
- . /etc/rc.d/functions
- if [ -z $MLDUSER ]
- then
- echo "Unable to run MLDonkey. You must set the user in /etc/mldonkey.conf."
- exit 2
- fi
- confdir=$(su -l $MLDUSER -c "echo ~")/.mldonkey
- pidfile=$(su -l $MLDUSER -c "echo ~")/.mldonkey/mlnet.pid
- [ -f /tmp/mldonkey.log ] && rm -f /tmp/mldonkey.log
- case "$1" in
- start)
- stat_busy "Starting MLDonkey"
-
- if [ -f $pidfile ]
- then
- stat_fail
- echo "Unable to run MLDonkey, it is already running. If you're sure MLDonkey is not already running, you can remove ${pidfile}."
- exit 2
- else
- if [ -f ${confdir}/config_files_space.tmp ]
- then
- rm -f ${confdir}/config_files_space.tmp
- fi
- fi
-
- [ ! -d $confdir ] && su -l $MLDUSER -c "mkdir -p $confdir"
- su -l $MLDUSER -c "/usr/bin/mlnet &> /tmp/mldonkey.log &"
-
- i=0
- while [ "$i" -lt 20 ]
- do
- if [ ! -z "$(grep "Core started" /tmp/mldonkey.log)" ]
- then
- add_daemon mldonkey
- stat_done
- exit 0
- elif [ ! -z "$(grep "This means another MLDonkey" /tmp/mldonkey.log)" ]
- then
- stat_fail
- exit 2
- elif [ ! -z "$(grep "This is normally caused by another" /tmp/mldonkey.log)" ]
- then
- stat_fail
- exit 2
- else
- i="$(($i+1))"
- fi
- sleep 1
- done
- stat_fail
- ;;
- stop)
- stat_busy "Stopping MLDonkey"
- if [ -f $pidfile ]
- then
- kill `cat $pidfile` &> /dev/null
- else
- stat_fail
- echo "Unable to stop MLDonkey. It is not running."
- exit 2
- fi
- if [ $? -gt 0 ]; then
- stat_fail
- else
- rm -f $pidfile
- rm_daemon mldonkey
- stat_done
- fi
- ;;
- restart)
- $0 stop
- sleep 6
- $0 start
- ;;
- *)
- echo "usage: $0 {start|stop|restart}"
- ;;
- esac
- exit 0
复制代码
衷心感谢mmx384的帮助 祝福你 |
|