開発

Gehirn RS2 に Subsonic 入れてみた

2012年11月21日

@dmnlkさん が、「Gehirn RS2ではSubSonic動かなそう」と言うので、試しに入れてみたら動いたっていう話。

まずは適当にGehirn RS2のアカウントを取得してきます。
SSHにログインしたら

rs2 install fakeroot

で、fakerootするための一式をインストール。
途中結構動きが止まったように見えるけど、のんびりお待ちを。
処理が全部終わったらコンソールが戻ってくるので

rs2 use fakeroot

で、fakerootモードに入る。

cd

で /root に移動する。(pwdで確認してね)

vi /etc/apt/sources.list

で、mainの後ろに contrib non-free を付ける。

多分、こうなってるはず

deb http://ftp.jp.debian.org/debian squeeze main contrib non-free
apt-get update

を実行します。

これやってる間も99%とか0%とか結構動かないようにみえるけどしばらく待つ。

コンソールが帰ってきたら

apt-get install sun-java6-jre less vim

これで、 Y/n を聞かれるので Y する。

終わったら、余計なデーモンがはいるので

apt-get purge avahi-daemon

で消しておく。

wget -O /root/subsonic-4.7.deb 'http://downloads.sourceforge.net/project/subsonic/subsonic/4.7/subsonic-4.7.deb?r=http%3A%2F%2Fwww.subsonic.org%2Fpages%2Fdownload2.jsp%3Ftarget%3Dsubsonic-4.7.deb&ts=1353425174&use_mirror=jaist'

で、Subsonicをダウンロードしてくる。

dpkg -i /root/subsonic-4.7.deb

これでいれ終わったら、

exit

で一旦fakerootを抜ける。

vi ~/root/usr/share/subsonic/subsonic.sh

で、起動ファイルを修正する。
修正箇所は

SUBSONIC_HOME=/home/USERNAME/root/var/subsonic
SUBSONIC_PORT=MyPORT
SUBSONIC_MAX_MEMORY=256
SUBSONIC_PIDFILE=/home/USERNAME/root/tmp/subsonic.pid
SUBSONIC_DEFAULT_MUSIC_FOLDER=/home/USERNAME/root/var/music
SUBSONIC_DEFAULT_PODCAST_FOLDER=/home/USERNAME/root/var/music/Podcast
SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/home/USERNAME/root/var/playlists

と97行目の

JAVA=/home/USERNAME/root/usr/bin/java

かな。例文はこちら

#!/bin/sh

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

SUBSONIC_HOME=/home/techtest/root/var/subsonic
SUBSONIC_HOST=0.0.0.0
SUBSONIC_PORT=61061
SUBSONIC_HTTPS_PORT=0
SUBSONIC_CONTEXT_PATH=/
SUBSONIC_MAX_MEMORY=256
SUBSONIC_PIDFILE=/home/techtest/root/tmp/subsonic.pid
SUBSONIC_DEFAULT_MUSIC_FOLDER=/home/techtest/root/var/music
SUBSONIC_DEFAULT_PODCAST_FOLDER=/home/techtest/root/var/music/Podcast
SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/home/techtest/root/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 "  --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=}
            ;;
        --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=/home/techtest/root/usr/bin/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} 
  -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

そんで

cd ~/root/usr/share/subsonic && ./subsonic.sh

で起動するはず。

Pocket

You Might Also Like