3 ###################################################################################
4 # Shell script for starting Subsonic. See http://subsonic.org.
7 ###################################################################################
9 SUBSONIC_HOME
=/var
/subsonic
13 SUBSONIC_CONTEXT_PATH
=/
14 SUBSONIC_MAX_MEMORY
=100
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
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."
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'"
54 while [ $# -ge 1 ]; do
60 SUBSONIC_HOME
=${1#--home=}
63 SUBSONIC_HOST
=${1#--host=}
66 SUBSONIC_PORT
=${1#--port=}
69 SUBSONIC_HTTPS_PORT
=${1#--https-port=}
72 SUBSONIC_CONTEXT_PATH
=${1#--context-path=}
75 SUBSONIC_MAX_MEMORY
=${1#--max-memory=}
78 SUBSONIC_PIDFILE
=${1#--pidfile=}
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=}
99 # Use JAVA_HOME if set, otherwise assume java is in the path.
101 if [ -e "${JAVA_HOME}" ]
103 JAVA
=${JAVA_HOME}/bin
/java
106 # Create Subsonic home directory.
107 mkdir
-p ${SUBSONIC_HOME}
108 LOG
=${SUBSONIC_HOME}/subsonic_sh.log
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 \
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}]