updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / subsonic-beta / subsonic.sh.off
blob3778f011ab9a40d817f54027d8ddea891bea4f9e
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 export LANG="en_US.UTF-8"
20 export LC_CTYPE="en_US.UTF-8"
21 JAVA_HOME=/opt/java/jre
23 quiet=0
25 usage() {
26 echo "Usage: subsonic.sh [options]"
27 echo " --help This small usage guide."
28 echo " --home=DIR The directory where Subsonic will create files."
29 echo " Make sure it is writable. Default: /var/subsonic"
30 echo " --host=HOST The host name or IP address on which to bind Subsonic."
31 echo " Only relevant if you have multiple network interfaces and want"
32 echo " to make Subsonic available on only one of them. The default value"
33 echo " will bind Subsonic to all available network interfaces. Default: 0.0.0.0"
34 echo " --port=PORT The port on which Subsonic will listen for"
35 echo " incoming HTTP traffic. Default: 4040"
36 echo " --https-port=PORT The port on which Subsonic will listen for"
37 echo " incoming HTTPS traffic. Default: 0 (disabled)"
38 echo " --context-path=PATH The context path, i.e., the last part of the Subsonic"
39 echo " URL. Typically '/' or '/subsonic'. Default '/'"
40 echo " --max-memory=MB The memory limit (max Java heap size) in megabytes."
41 echo " Default: 100"
42 echo " --pidfile=PIDFILE Write PID to this file. Default not created."
43 echo " --quiet Don't print anything to standard out. Default false."
44 echo " --default-music-folder=DIR Configure Subsonic to use this folder for music. This option "
45 echo " only has effect the first time Subsonic is started. Default '/var/music'"
46 echo " --default-podcast-folder=DIR Configure Subsonic to use this folder for Podcasts. This option "
47 echo " only has effect the first time Subsonic is started. Default '/var/music/Podcast'"
48 echo " --default-playlist-folder=DIR Configure Subsonic to use this folder for playlists. This option "
49 echo " only has effect the first time Subsonic is started. Default '/var/playlists'"
50 exit 1
53 # Parse arguments.
54 while [ $# -ge 1 ]; do
55 case $1 in
56 --help)
57 usage
59 --home=?*)
60 SUBSONIC_HOME=${1#--home=}
62 --host=?*)
63 SUBSONIC_HOST=${1#--host=}
65 --port=?*)
66 SUBSONIC_PORT=${1#--port=}
68 --https-port=?*)
69 SUBSONIC_HTTPS_PORT=${1#--https-port=}
71 --context-path=?*)
72 SUBSONIC_CONTEXT_PATH=${1#--context-path=}
74 --max-memory=?*)
75 SUBSONIC_MAX_MEMORY=${1#--max-memory=}
77 --pidfile=?*)
78 SUBSONIC_PIDFILE=${1#--pidfile=}
80 --quiet)
81 quiet=1
83 --default-music-folder=?*)
84 SUBSONIC_DEFAULT_MUSIC_FOLDER=${1#--default-music-folder=}
86 --default-podcast-folder=?*)
87 SUBSONIC_DEFAULT_PODCAST_FOLDER=${1#--default-podcast-folder=}
89 --default-playlist-folder=?*)
90 SUBSONIC_DEFAULT_PLAYLIST_FOLDER=${1#--default-playlist-folder=}
93 usage
95 esac
96 shift
97 done
99 # Use JAVA_HOME if set, otherwise assume java is in the path.
100 JAVA=java
101 if [ -e "${JAVA_HOME}" ]
102 then
103 JAVA=${JAVA_HOME}/bin/java
106 # Create Subsonic home directory.
107 mkdir -p ${SUBSONIC_HOME}
108 LOG=${SUBSONIC_HOME}/subsonic_sh.log
109 rm -f ${LOG}
111 cd $(dirname $0)
112 if [ -L $0 ] && ([ -e /bin/readlink ] || [ -e /usr/bin/readlink ]); then
113 cd $(dirname $(readlink $0))
116 ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \
117 -Dsubsonic.home=${SUBSONIC_HOME} \
118 -Dsubsonic.host=${SUBSONIC_HOST} \
119 -Dsubsonic.port=${SUBSONIC_PORT} \
120 -Dsubsonic.httpsPort=${SUBSONIC_HTTPS_PORT} \
121 -Dsubsonic.contextPath=${SUBSONIC_CONTEXT_PATH} \
122 -Dsubsonic.defaultMusicFolder=${SUBSONIC_DEFAULT_MUSIC_FOLDER} \
123 -Dsubsonic.defaultPodcastFolder=${SUBSONIC_DEFAULT_PODCAST_FOLDER} \
124 -Dsubsonic.defaultPlaylistFolder=${SUBSONIC_DEFAULT_PLAYLIST_FOLDER} \
125 -Djava.awt.headless=true \
126 -verbose:gc \
127 -jar subsonic-booter-jar-with-dependencies.jar > ${LOG} 2>&1 &
129 # Write pid to pidfile if it is defined.
130 if [ $SUBSONIC_PIDFILE ]; then
131 echo $! > ${SUBSONIC_PIDFILE}
134 if [ $quiet = 0 ]; then
135 echo Started Subsonic [PID $!, ${LOG}]