updated on Tue Jan 10 04:01:21 UTC 2012
[aur-mirror.git] / subsonic-beta / subsonic.sh.off
blobb795ab2ccd0621a1269dd5c402d86828b6a765e8
1 #!/bin/sh
3 ###################################################################################
4 # Shell script for starting Subsonic. See http://subsonic.org.
6 # Author: Sindre Mehus
7 ###################################################################################
9 SUBSONIC_HOME=/var/subsonic
10 SUBSONIC_HOST=0.0.0.0
11 SUBSONIC_PORT=4040
12 SUBSONIC_HTTPS_PORT=0
13 SUBSONIC_CONTEXT_PATH=/
14 SUBSONIC_MAX_MEMORY=100
15 SUBSONIC_PIDFILE=
16 SUBSONIC_DEFAULT_MUSIC_FOLDER=/var/music
17 SUBSONIC_DEFAULT_PODCAST_FOLDER=/var/music/Podcast
18 SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/var/playlists
19 JAVA_HOME=/opt/java/jre
21 quiet=0
23 usage() {
24 echo "Usage: subsonic.sh [options]"
25 echo " --help This small usage guide."
26 echo " --home=DIR The directory where Subsonic will create files."
27 echo " Make sure it is writable. Default: /var/subsonic"
28 echo " --host=HOST The host name or IP address on which to bind Subsonic."
29 echo " Only relevant if you have multiple network interfaces and want"
30 echo " to make Subsonic available on only one of them. The default value"
31 echo " will bind Subsonic to all available network interfaces. Default: 0.0.0.0"
32 echo " --port=PORT The port on which Subsonic will listen for"
33 echo " incoming HTTP traffic. Default: 4040"
34 echo " --https-port=PORT The port on which Subsonic will listen for"
35 echo " incoming HTTPS traffic. Default: 0 (disabled)"
36 echo " --context-path=PATH The context path, i.e., the last part of the Subsonic"
37 echo " URL. Typically '/' or '/subsonic'. Default '/'"
38 echo " --max-memory=MB The memory limit (max Java heap size) in megabytes."
39 echo " Default: 100"
40 echo " --pidfile=PIDFILE Write PID to this file. Default not created."
41 echo " --quiet Don't print anything to standard out. Default false."
42 echo " --default-music-folder=DIR Configure Subsonic to use this folder for music. This option "
43 echo " only has effect the first time Subsonic is started. Default '/var/music'"
44 echo " --default-podcast-folder=DIR Configure Subsonic to use this folder for Podcasts. This option "
45 echo " only has effect the first time Subsonic is started. Default '/var/music/Podcast'"
46 echo " --default-playlist-folder=DIR Configure Subsonic to use this folder for playlists. This option "
47 echo " only has effect the first time Subsonic is started. Default '/var/playlists'"
48 exit 1
51 # Parse arguments.
52 while [ $# -ge 1 ]; do
53 case $1 in
54 --help)
55 usage
57 --home=?*)
58 SUBSONIC_HOME=${1#--home=}
60 --host=?*)
61 SUBSONIC_HOST=${1#--host=}
63 --port=?*)
64 SUBSONIC_PORT=${1#--port=}
66 --https-port=?*)
67 SUBSONIC_HTTPS_PORT=${1#--https-port=}
69 --context-path=?*)
70 SUBSONIC_CONTEXT_PATH=${1#--context-path=}
72 --max-memory=?*)
73 SUBSONIC_MAX_MEMORY=${1#--max-memory=}
75 --pidfile=?*)
76 SUBSONIC_PIDFILE=${1#--pidfile=}
78 --quiet)
79 quiet=1
81 --default-music-folder=?*)
82 SUBSONIC_DEFAULT_MUSIC_FOLDER=${1#--default-music-folder=}
84 --default-podcast-folder=?*)
85 SUBSONIC_DEFAULT_PODCAST_FOLDER=${1#--default-podcast-folder=}
87 --default-playlist-folder=?*)
88 SUBSONIC_DEFAULT_PLAYLIST_FOLDER=${1#--default-playlist-folder=}
91 usage
93 esac
94 shift
95 done
97 # Use JAVA_HOME if set, otherwise assume java is in the path.
98 JAVA=java
99 if [ -e "${JAVA_HOME}" ]
100 then
101 JAVA=${JAVA_HOME}/bin/java
104 # Create Subsonic home directory.
105 mkdir -p ${SUBSONIC_HOME}
106 LOG=${SUBSONIC_HOME}/subsonic_sh.log
107 rm -f ${LOG}
109 cd $(dirname $0)
110 if [ -L $0 ] && ([ -e /bin/readlink ] || [ -e /usr/bin/readlink ]); then
111 cd $(dirname $(readlink $0))
114 ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \
115 -Dsubsonic.home=${SUBSONIC_HOME} \
116 -Dsubsonic.host=${SUBSONIC_HOST} \
117 -Dsubsonic.port=${SUBSONIC_PORT} \
118 -Dsubsonic.httpsPort=${SUBSONIC_HTTPS_PORT} \
119 -Dsubsonic.contextPath=${SUBSONIC_CONTEXT_PATH} \
120 -Dsubsonic.defaultMusicFolder=${SUBSONIC_DEFAULT_MUSIC_FOLDER} \
121 -Dsubsonic.defaultPodcastFolder=${SUBSONIC_DEFAULT_PODCAST_FOLDER} \
122 -Dsubsonic.defaultPlaylistFolder=${SUBSONIC_DEFAULT_PLAYLIST_FOLDER} \
123 -Djava.awt.headless=true \
124 -verbose:gc \
125 -jar subsonic-booter-jar-with-dependencies.jar > ${LOG} 2>&1 &
127 # Write pid to pidfile if it is defined.
128 if [ $SUBSONIC_PIDFILE ]; then
129 echo $! > ${SUBSONIC_PIDFILE}
132 if [ $quiet = 0 ]; then
133 echo Started Subsonic [PID $!, ${LOG}]