aboutsummaryrefslogtreecommitdiff
path: root/www/subsonic-standalone/files/subsonic.in
blob: 56b698586e95fb606fee8d316740e3288b6575b5 (plain) (blame)
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
80
81
82
83
84
85
86
87
88
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: subsonic
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Configuration settings for subsonic in /etc/rc.conf:
#
# subsonic_enable (bool):
#   Set to "NO" by default.
#   Set it to "YES" to enable subsonic.
#
# subsonic_home (str):
#   Set to "%%SUBSONIC_HOME%%" by default.
#
# subsonic_host (str):
#   Set to "0.0.0.0" by default.
#   Specify which IP address to listen to.
#
# subsonic_port (int):
#   Set to "4040" by default.
#   Specify which port to listen on for HTTP(S).
#
# subsonic_ssl (bool):
#   Set to "NO" by default.
#   Set it to "YES" to enable SSL.
#
# subsonic_ssl_keystore (str):
#   Optionally set path to custom SSL keystore.
#
# subsonic_ssl_password (str):
#   Optionally set password for custom SSL keystore.
#
# subsonic_context_path (str):
#   Set to "/" by default.
#   Specify the last part of the Subsonic URL, typically "/" or "/subsonic".
#
# subsonic_max_memory (int):
#   Set to "100" by default.
#   Specify the memory limit (Java heap size) in megabytes.
#

. /etc/rc.subr

name=subsonic
rcvar=${name}_enable
procname="%%JAVA%%"

load_rc_config "${name}"

: ${subsonic_enable:="NO"}
: ${subsonic_user:="%%USER%%"}
: ${subsonic_group:="%%GROUP%%"}
: ${subsonic_home:="%%SUBSONIC_HOME%%"}
: ${subsonic_host:="0.0.0.0"}
: ${subsonic_port:="4040"}
: ${subsonic_ssl:="NO"}
: ${subsonic_context_path:="/"}
: ${subsonic_max_memory:="100"}

if checkyesno subsonic_ssl; then
	SUBSONIC_SSL_FLAGS="-Dsubsonic.httpsPort=${subsonic_port}" && subsonic_port="0"
	if [ ! -z ${subsonic_ssl_keystore} ]; then
		SUBSONIC_SSL_FLAGS=${SUBSONIC_SSL_FLAGS}" -Dsubsonic.ssl.keystore=${subsonic_ssl_keystore} -Dsubsonic.ssl.password=${subsonic_ssl_password}"
	fi
fi

start_precmd="export LC_CTYPE='en_US.UTF-8'"
subsonic_chdir="%%DATADIR%%"
command="/usr/sbin/daemon"
command_args="-f ${procname} \
	-Dsubsonic.home=${subsonic_home} \
	-Dsubsonic.host=${subsonic_host} \
	-Dsubsonic.port=${subsonic_port} \
	${SUBSONIC_SSL_FLAGS} \
	-Dsubsonic.contextPath=${subsonic_context_path} \
	-Dsubsonic.defaultMusicFolder=${subsonic_home}/music \
	-Dsubsonic.defaultPodcastFolder=${subsonic_home}/Podcast \
	-Dsubsonic.defaultPlaylistFolder=${subsonic_home}/playlists \
	-Xmx${subsonic_max_memory}m \
	-Djava.awt.headless=true \
	-jar ${subsonic_chdir}/subsonic-booter-jar-with-dependencies.jar"

run_rc_command "$1"