Import www/subsonic-standalone version 5.2
[dports.git] / www / subsonic-standalone / files / subsonic.in
1 #!/bin/sh
2 #
3 # $FreeBSD: head/www/subsonic-standalone/files/subsonic.in 381942 2015-03-22 18:04:48Z jlh $
4 #
5
6 # PROVIDE: subsonic
7
8 #
9 # Configuration settings for subsonic in /etc/rc.conf:
10 #
11 # subsonic_enable (bool):
12 #   Set to "NO" by default.
13 #   Set it to "YES" to enable subsonic
14 #
15 # subsonic_home (str):
16 #   Set to "%%SUBSONIC_HOME%%" by default.
17 #
18 # subsonic_music_folder (str):
19 #   Set to "%%SUBSONIC_HOME%%"/music by default.
20 #
21 # subsonic_playlist_folder (str):
22 #   Set to "%%SUBSONIC_HOME%%"/playlist by default.
23 #
24 # subsonic_pidfile (str):
25 #   Set to "${subsonic_home}/subsonic.pid" by default.
26 #
27 # subsonic_host (str):
28 #   Set to "0.0.0.0" by default.
29 #   Specify which IP address to listen to.
30 #
31 # subsonic_http_port (int):
32 #   Set to "4040" by default.
33 #   Specify which port to listen on for HTTP.
34 #
35 # subsonic_https_port (int):
36 #   Set to "0" by default.
37 #   Specify which port to listen on for HTTPS.
38 #
39 # subsonic_context_path (str):
40 #   Set to "/" by default.
41 #   Specify the last part of the Subsonic URL, typically "/" or "/subsonic".
42 #
43 # subsonic_max_memory (int):
44 #   Set to "100" by defaut.
45 #   Specify the memory limit (Java heap size) in megabytes.
46 #
47
48 . /etc/rc.subr
49
50 case $0 in
51 /etc/rc*)
52         # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
53         # so get the name of the script from $_file
54         name=$_file
55         ;;
56 *)
57         name=$0
58         ;;
59 esac
60
61 name=${0##*/}
62 rcvar=${name}_enable
63 procname="%%JAVA%%"
64
65 load_rc_config "${name}"
66
67 eval "${rcvar}=\${${rcvar}:-'NO'}"
68 eval "${name}_user=\${${name}_user:-'subsonic'}"
69 eval "${name}_group=\${${name}_group:-'subsonic'}"
70 eval "_subsonic_max_memory=\${${name}_max_memory:-'100'}"
71 eval "_subsonic_home=\${${name}_home:-'%%SUBSONIC_HOME%%'}"
72 eval "_subsonic_music_folder=\${${name}_music_folder:-'%%SUBSONIC_HOME%%/music'}"
73 eval "_subsonic_playlist_folder=\${${name}folder:-'%%SUBSONIC_HOME%%/playlist'}"
74 eval "_subsonic_host=\${${name}_host:-'0.0.0.0'}"
75 eval "_subsonic_http_port=\${${name}_http_port:-'4040'}"
76 eval "_subsonic_https_port=\${${name}_https_port:-'0'}"
77 eval "_subsonic_context_path=\${${name}_context_path:-'/'}"
78 eval "_subsonic_pidfile=\${${name}_pidfile:-'%%SUBSONIC_HOME%%/subsonic.pid'}"
79 pidfile="${_subsonic_pidfile}"
80
81
82
83 command="%%SUBSONIC_DIR%%/subsonic.sh"
84 command_args="--home=${_subsonic_home} \
85         --host=${_subsonic_host} \
86         --port=${_subsonic_http_port} \
87         --https-port=${_subsonic_https_port} \
88         --context-path=${_subsonic_context_path} \
89         --max-memory=${_subsonic_max_memory} \
90         --pidfile=${_subsonic_pidfile} \
91         --default-music-folder=${_subsonic_music_folder} \
92         --default-playlist-folder=${_subsonic_playlist_folder}"
93
94 run_rc_command "$1"