summaryrefslogtreecommitdiff
blob: 157a1e358842a1c38d744d64dd9e04d476246e7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/sbin/runscript
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

depend() {
	use net
}

start() {
	ebegin "Starting uShare"
	
	# Sanity check to avoid ushare failling on booting with no
	# shared dirs
	if [[ -z "${USHARE_DIRS}" ]] ; then
		eerror "Please set shared dirs in /etc/conf.d/ushare"
		return 1
	fi

	if [[ -z "${USHARE_PORT}" ]] ; then
		einfo "${USHARE_NAME} runs on a dynamic port"
		local ushare_port=
	else
		local ushare_port="--port ${USHARE_PORT}"
		einfo "${USHARE_NAME} using port ${USHARE_PORT}"
	fi

	if [[ "${USHARE_TELNET}" == "yes" ]] ; then
                local ushare_telnet=
        else
                local ushare_telnet="--no-telnet"
        fi

	if [[ -z "${ushare_telnet}" ]] ; then
		if [[ -z "${USHARE_TELNET_PORT}" ]] ; then
                	local ushare_telnet_port=
			einfo "${USHARE_NAME} runs telnet on the default port"
		else
			local ushare_telnet_port="--telnet-port ${USHARE_TELNET_PORT}"
			einfo "${USHARE_NAME} runs telnet on port ${USHARE_TELNET_PORT}"
		fi
        else
                local ushare_telnet_port=
        fi

	if [[ "${USHARE_WEB}" == "yes" ]] ; then
                local ushare_web=
        else
                local ushare_web="--no-web"
        fi

	if [[ "${USHARE_XBOX}" == "yes" ]] ; then
		local ushare_xbox="--xbox"
	else
		local ushare_xbox=
	fi

	if [[ "${USHARE_DLNA}" == "yes" ]] ; then
		local ushare_dlna="--dlna"
	else
		local ushare_dlna=
	fi

	start-stop-daemon --start --quiet -u ${USHARE_USER:-root} \
	--exec /usr/bin/ushare -- -D -i ${USHARE_IFACE}           \
	-n ${USHARE_NAME} ${USHARE_OPTS} ${USHARE_DIRS}           \
	${ushare_port}                                            \
	${ushare_telnet} ${ushare_telnet_port}                    \
	${ushare_web}                                             \
	${ushare_xbox}                                            \
	${ushare_dlna}
	eend $?
}

stop() {
	ebegin "Stopping uShare"
	start-stop-daemon --stop --quiet --exec /usr/bin/ushare
	eend $?
}