packages/net/deluge/files/deluge.init
dingo 9eb3db5c50 [patchteam] - New Package - Deluge - with daemon, console and web ui
Singed off by alexander@sulfrian.net


git-svn-id: svn://svn.openwrt.org/openwrt/packages@20178 3c298f89-4303-0410-b956-a3cf2f4a3e73
2010-03-13 03:02:58 +00:00

61 lines
1.3 KiB
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2010 OpenWrt.org
# Copyright (C) 2010 Alexander Sulfrian
NAME=deluge
PIDFILE=/var/run/deluged.pid
START=50
STOP=50
load_config()
{
config_get_bool enabled $1 enabled 0
[ "${enabled}" -eq 0 ] && return 1
config_get user $1 user
if [ "${user}" == "" ]; then
echo "Please check your uci config. User for '$1' should not be empty."
return 1
fi
username=$(echo ${user} | cut -d ':' -f 1)
group=$(echo ${user} | cut -d ':' -f 2)
if ! $(cut -d ':' -f 1 /etc/passwd | grep -sq "${username}"); then
echo "Please check your uci config. User for '$1' should exist."
return 1
fi
if [ "${group}" != "" ]; then
if ! $(cut -d ':' -f 1 /etc/passwd | grep -sq "${group}"); then
echo "Please check your uci config. Group for '$1' should exist."
return 1
fi
fi
}
start()
{
config_load "${NAME}"
load_config deluged || return $?
config_get options deluged options
config_get home deluged home
if [ "${home}" == "" ]; then
home=$(grep "^${username}:" /etc/passwd | cut -d ':' -f 6)
fi
HOME="${home}" /sbin/start-stop-daemon -S -u "${username}" \
-p "${PIDFILE}" -b -m -x "/usr/bin/python2.6" -a deluged \
-c "${user}" -- --do-not-daemonize ${options}
}
stop()
{
config_load "${NAME}"
load_config deluged || return $?
/sbin/start-stop-daemon -K -u "${username}" -n deluged -p "${PIDFILE}"
}