Temp upload dir

General discussions.

Moderator: moderators

Temp upload dir

Postby josquin » Mon Jun 06, 2016 2:27 pm

Hi,

First of all thanks for the good job, subsonic really is an amazing project.

Second, due to freespace concern I had to change the dir where subsonic store temporary uploaded files.
To do so, i did pass a "java.io.tmpdir" parameter to java when lauching subsonic.

That said, I've tried to make it clean. You'll find my humble contribition proposal to subsonic.sh attached.

I did add a "SUBSONIC_TMPDIR_PATH"
...
SUBSONIC_TMPDIR_PATH=/tmp
...


that can be fead via "--tmpdir-path" argument
document it
...
echo " --tmpdir-path=PATH The directory where files are temporarily stored during upload. Default '/tmp'"
...

then do the job
...
--tmpdir-path=?*)
SUBSONIC_TMPDIR_PATH=${1#--tmpdir-path=}
;;
...

and finally insert it in the command line
...
-Djava.io.tmpdir=${SUBSONIC_TMPDIR_PATH} \
...


That way it's possible to pass the argument through the /etc/default/subsonic file (debian).
Hope that somehow, this could be useful.

Greetings

Josquin

Code: Select all
#!/bin/sh

###################################################################################
# Shell script for starting Subsonic.  See http://subsonic.org.
#
# Author: Sindre Mehus
###################################################################################

SUBSONIC_HOME=/var/subsonic
SUBSONIC_HOST=0.0.0.0
SUBSONIC_PORT=4040
SUBSONIC_HTTPS_PORT=0
SUBSONIC_CONTEXT_PATH=/
SUBSONIC_TMPDIR_PATH=/tmp
SUBSONIC_MAX_MEMORY=150
SUBSONIC_PIDFILE=
SUBSONIC_DEFAULT_MUSIC_FOLDER=/var/music
SUBSONIC_DEFAULT_PODCAST_FOLDER=/var/music/Podcast
SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/var/playlists

quiet=0

usage() {
    echo "Usage: subsonic.sh [options]"
    echo "  --help               This small usage guide."
    echo "  --home=DIR           The directory where Subsonic will create files."
    echo "                       Make sure it is writable. Default: /var/subsonic"
    echo "  --host=HOST          The host name or IP address on which to bind Subsonic."
    echo "                       Only relevant if you have multiple network interfaces and want"
    echo "                       to make Subsonic available on only one of them. The default value"
    echo "                       will bind Subsonic to all available network interfaces. Default: 0.0.0.0"
    echo "  --port=PORT          The port on which Subsonic will listen for"
    echo "                       incoming HTTP traffic. Default: 4040"
    echo "  --https-port=PORT    The port on which Subsonic will listen for"
    echo "                       incoming HTTPS traffic. Default: 0 (disabled)"
    echo "  --context-path=PATH  The context path, i.e., the last part of the Subsonic"
    echo "                       URL. Typically '/' or '/subsonic'. Default '/'"
    echo "  --tmpdir-path=PATH   The directory where files are temporarily stored during upload. Default '/tmp'"
    echo "  --max-memory=MB      The memory limit (max Java heap size) in megabytes."
    echo "                       Default: 100"
    echo "  --pidfile=PIDFILE    Write PID to this file. Default not created."
    echo "  --quiet              Don't print anything to standard out. Default false."
    echo "  --default-music-folder=DIR    Configure Subsonic to use this folder for music.  This option "
    echo "                                only has effect the first time Subsonic is started. Default '/var/music'"
    echo "  --default-podcast-folder=DIR  Configure Subsonic to use this folder for Podcasts.  This option "
    echo "                                only has effect the first time Subsonic is started. Default '/var/music/Podcast'"
    echo "  --default-playlist-folder=DIR Configure Subsonic to use this folder for playlists.  This option "
    echo "                                only has effect the first time Subsonic is started. Default '/var/playlists'"
    exit 1
}

# Parse arguments.
while [ $# -ge 1 ]; do
    case $1 in
        --help)
            usage
            ;;
        --home=?*)
            SUBSONIC_HOME=${1#--home=}
            ;;
        --host=?*)
            SUBSONIC_HOST=${1#--host=}
            ;;
        --port=?*)
            SUBSONIC_PORT=${1#--port=}
            ;;
        --https-port=?*)
            SUBSONIC_HTTPS_PORT=${1#--https-port=}
            ;;
        --context-path=?*)
            SUBSONIC_CONTEXT_PATH=${1#--context-path=}
            ;;
   --tmpdir-path=?*)
            SUBSONIC_TMPDIR_PATH=${1#--tmpdir-path=}
       ;;
        --max-memory=?*)
            SUBSONIC_MAX_MEMORY=${1#--max-memory=}
            ;;
        --pidfile=?*)
            SUBSONIC_PIDFILE=${1#--pidfile=}
            ;;
        --quiet)
            quiet=1
            ;;
        --default-music-folder=?*)
            SUBSONIC_DEFAULT_MUSIC_FOLDER=${1#--default-music-folder=}
            ;;
        --default-podcast-folder=?*)
            SUBSONIC_DEFAULT_PODCAST_FOLDER=${1#--default-podcast-folder=}
            ;;
        --default-playlist-folder=?*)
            SUBSONIC_DEFAULT_PLAYLIST_FOLDER=${1#--default-playlist-folder=}
            ;;
        *)
            usage
            ;;
    esac
    shift
done

# Use JAVA_HOME if set, otherwise assume java is in the path.
JAVA=java
if [ -e "${JAVA_HOME}" ]
    then
    JAVA=${JAVA_HOME}/bin/java
fi

# Create Subsonic home directory.
mkdir -p ${SUBSONIC_HOME}
LOG=${SUBSONIC_HOME}/subsonic_sh.log
rm -f ${LOG}

cd $(dirname $0)
if [ -L $0 ] && ([ -e /bin/readlink ] || [ -e /usr/bin/readlink ]); then
    cd $(dirname $(readlink $0))
fi

${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \
  -Dsubsonic.home=${SUBSONIC_HOME} \
  -Dsubsonic.host=${SUBSONIC_HOST} \
  -Dsubsonic.port=${SUBSONIC_PORT} \
  -Dsubsonic.httpsPort=${SUBSONIC_HTTPS_PORT} \
  -Dsubsonic.contextPath=${SUBSONIC_CONTEXT_PATH} \
  -Djava.io.tmpdir=${SUBSONIC_TMPDIR_PATH} \
  -Dsubsonic.defaultMusicFolder=${SUBSONIC_DEFAULT_MUSIC_FOLDER} \
  -Dsubsonic.defaultPodcastFolder=${SUBSONIC_DEFAULT_PODCAST_FOLDER} \
  -Dsubsonic.defaultPlaylistFolder=${SUBSONIC_DEFAULT_PLAYLIST_FOLDER} \
  -Djava.awt.headless=true \
  -verbose:gc \
  -jar subsonic-booter-jar-with-dependencies.jar > ${LOG} 2>&1 &

# Write pid to pidfile if it is defined.
if [ $SUBSONIC_PIDFILE ]; then
    echo $! > ${SUBSONIC_PIDFILE}
fi

if [ $quiet = 0 ]; then
    echo Started Subsonic [PID $!, ${LOG}]
fi
User avatar
josquin
 
Posts: 21
Joined: Mon Jun 06, 2016 1:51 pm

Re: Temp upload dir

Postby josquin » Tue Jun 07, 2016 1:29 pm

Here is the .bat version

Code: Select all
@echo off

REM  The directory where Subsonic will create files. Make sure it is writable.
set SUBSONIC_HOME=c:\subsonic

REM  The host name or IP address on which to bind Subsonic. Only relevant if you have
REM  multiple network interfaces and want to make Subsonic available on only one of them.
REM  The default value 0.0.0.0 will bind Subsonic to all available network interfaces.
set SUBSONIC_HOST=0.0.0.0

REM  The port on which Subsonic will listen for incoming HTTP traffic.
set SUBSONIC_PORT=4040

REM  The port on which Subsonic will listen for incoming HTTPS traffic (0 to disable).
set SUBSONIC_HTTPS_PORT=0

REM  The context path (i.e., the last part of the Subsonic URL).  Typically "/" or "/subsonic".
set SUBSONIC_CONTEXT_PATH=/

REM The directory where files are temporarily stored during upload. Default 'c:\Windows\Temp'"
set SUBSONIC_TMPDIR_PATH=c:\Windows\Temp

REM  The memory limit (max Java heap size) in megabytes.
set MAX_MEMORY=150

java -Xmx%MAX_MEMORY%m -Dsubsonic.home=%SUBSONIC_HOME% -Dsubsonic.host=%SUBSONIC_HOST% -Dsubsonic.port=%SUBSONIC_PORT%  -Dsubsonic.httpsPort=%SUBSONIC_HTTPS_PORT% -Dsubsonic.contextPath=%SUBSONIC_CONTEXT_PATH% -Djava.io.tmpdir=%SUBSONIC_TMPDIR_PATH% -jar subsonic-booter-jar-with-dependencies.jar


It may be necessary to add a field to the subsonic agent to modify subsonic-service.exe.vmoptions I guess.

Have a good day.

Josquin
User avatar
josquin
 
Posts: 21
Joined: Mon Jun 06, 2016 1:51 pm


Return to General

Who is online

Users browsing this forum: No registered users and 9 guests