summaryrefslogtreecommitdiff
path: root/community/mldonkey/mldonkeyd
diff options
context:
space:
mode:
authorroot <root@rshg047.dnsready.net>2011-06-12 22:59:55 +0000
committerroot <root@rshg047.dnsready.net>2011-06-12 22:59:55 +0000
commitad4b2565385561c6ff56f1f91c1e40115cf939d7 (patch)
treea38f832867e30f3e23110e15089aa9b7221c9789 /community/mldonkey/mldonkeyd
parente392819937e37aa7f33ba83bb3e23bb1ccabaa37 (diff)
Sun Jun 12 22:59:55 UTC 2011
Diffstat (limited to 'community/mldonkey/mldonkeyd')
-rw-r--r--community/mldonkey/mldonkeyd21
1 files changed, 19 insertions, 2 deletions
diff --git a/community/mldonkey/mldonkeyd b/community/mldonkey/mldonkeyd
index bbd6954c2..6a458d68e 100644
--- a/community/mldonkey/mldonkeyd
+++ b/community/mldonkey/mldonkeyd
@@ -9,6 +9,15 @@ if [ -z $MLDUSER ] ; then
exit 2
fi
+if [ -z "$(getent passwd "$MLDUSER")" ]; then
+ # Perhaps we should create the account for the user?
+ echo "You must create the account $MLDUSER in order to run mldonkey."
+ echo "Please create the account manually, and try again."
+ exit 2
+fi
+
+MLDGROUPID=$(getent passwd "$MLDUSER" |cut -d':' -f4)
+MLDGROUP=$(getent group $MLDGROUPID |cut -d':' -f1)
USERDIR=$(getent passwd $MLDUSER | cut -d: -f6)
if [ ! -d $USERDIR ]; then
@@ -16,12 +25,20 @@ if [ ! -d $USERDIR ]; then
exit 2
fi
-PID=$(cat $USERDIR/.mldonkey/mlnet.pid 2>/dev/null)
+PIDDIR="/var/run/mldonkey"
+PIDFILE="$PIDDIR/mlnet.pid"
+PID=$(cat $PIDFILE 2>/dev/null)
case "$1" in
start)
stat_busy "Starting MLDonkey"
- [ -z $PID ] && su $MLDUSER -s /bin/sh -c "/usr/bin/mlnet $PARAMS -log_to_syslog true &> /tmp/mldonkey.log &"
+ if [ ! -d $PIDDIR ]; then
+ install -d -m755 -o "$MLDUSER" -g "$MLDGROUP" $PIDDIR
+ fi
+ if [ "$(stat -c %U $PIDDIR)" != "$MLDUSER" ]; then
+ chown -R "$MLDUSER:$MLDGROUP" $PIDDIR
+ fi
+ [ -z $PID ] && su $MLDUSER -s /bin/sh -c "/usr/bin/mlnet -pid $PIDDIR $PARAMS -log_to_syslog true &> /tmp/mldonkey.log &"
if [ $? -gt 0 ]; then
stat_fail
else