Posted 2007/07/28 (土) 00:53
記事No.56
インストール方法については前回書いたとおりで正常にいけますが設定については続きに記載します。
とりあえず、オートスキャンを働かせていますので、まだ実験は終わってないのですが、いい感じのところまではいっているので現状の設定内容を公開したいと思います。
tarボールからインストールした場合、サーバとしての起動スクリプトも設定ファイルも何も無い状況なので、簡単ながら起動スクリプトをRPMインストール時に入っていた物をコピー保存していたものを流用しています。
# vi /etc/rc.d/init.d/mediatomb
ファイル内容は以下
#!/bin/sh
#
# mediatomb This script starts and stops the mediatomb daemon
#
# chkconfig: - 95 30
# processname: mediatomb
# description: mediatomb is a daemon process which provides a UPnP service
# config: /etc/mediatomb
# config: /etc/mediatomb/config.xml
# pidfile: /var/run/mediatomb.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# Set default mediatomb configuration.
# either make an installation in /etc/mediatomb and leave this blank,
# or specify an alternative config file location using the -c option
# Note: be aware, that -i parameter is used to set the ip of the
# interface specified above
. /etc/mediatomb.conf
###############################
# make sure to run it as nobody
MEDIATOMB="-d -u $MT_USER -g $MT_GROUP -P $MT_PIDFILE -l $MT_LOGFILE -m $MT_HOME -f $MT_CFGDIR -p $MT_PORT"
[ -f /usr/bin/mediatomb ] || exit 0
[ ${MT_INTERFACE} = "NOT_SET" ] && echo "Please edit /etc/mediatomb.conf and change ¥
the MT_INTERFACE variable to your network device (eth0, eth1, etc.)" && exit 0
PATH=$PATH:/usr/bin:/usr/local/bin
IFACE_IP=`ifconfig | grep -i "$MT_INTERFACE" -A 1|grep "inet addr"|cut -d " " -f 12|cut -d ":" -f 2`
# By default it's all good
RETVAL=0
# See how we were called.
case "$1" in
start)
# Start daemon.
echo -n "Applying multicast settings to $MT_INTERFACE... "
# those settings are necessary for us to react to M-SEARCH requests
route add -net 239.0.0.0 netmask 255.0.0.0 $MT_INTERFACE >/dev/null 2>&1
ifconfig $MT_INTERFACE allmulti
touch $MT_PIDFILE
chown nobody $MT_PIDFILE
mkdi$ -p "/$MT_HOME/$MT_CFGDIR"
chown nobody "/$MT_HOME/$MT_CFGDIR"
echo -n "Starting mediatomb: "
daemon $NICELEVEL mediatomb $MEDIATOMB -i $IFACE_IP $MT_OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/mediatomb
;;
stop)
# Stop daemons.
echo -n "Shutting down mediatomb: "
killproc mediatomb
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/mediatomb
;;
restart)
$0 stop
$0 start
;;
condrestart)
[ -e /var/lock/subsys/mediatomb ] && $0 restart
;;
status)
status mediatomb
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|restart|status|condrestart}"
RETVAL=1
;;
esac
exit $RETVAL
chkconfigで起動スクリプトを反映する。
# chkconfig --add /etc/rc.d/init.d/mediatomb
サーバ自動起動フラグを設定する。
# chkconfig mediatomb on
起動スクリプトを動作させる設定ファイルを作成する。
# vi /etc/mediatomb.conf
ファイル内容は以下
## This is a sambel configuration file for the MediaTomb daemon script
## used on Fedora Core
## By default the configuration will be created in /etc/mediatomb
## Network interface on which the server will run, you need to edit this!
MT_INTERFACE="eth0"
## User defined command line options that may be passed to the server
MT_OPTIONS=""
## MediaTomb will be started on port 50500
MT_PORT="50500"
## MediaTomb will run as nobody
MT_USER="nobody"
MT_GROUP="nobody"
## Location of the PID file
MT_PIDFILE="/var/run/mediatomb.pid"
## Location of the log file
MT_LOGFILE="/var/log/mediatomb"
## Location of the config file/database
MT_HOME="/etc"
MT_CFGDIR="mediatomb"
mediatombのコンフィグファイルを作成する。
# vi /etc/mediatomb/config.xml
ファイル内容は以下
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://mediatomb.cc/0.10.0/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:
schemaLocation="http://mediatomb.cc/0.10.0/config http://mediatomb.cc/0.10.0/config.xsd">
<server>
<ui enabled="yes">
<accounts enabled="no" session-timeout="30"/>
</ui>
<name>MediaTomb</name>
<udn>uuid:ba9e4ff3-02e8-4b85-b08e-1509c3cf0a26</udn>
<home>/etc/mediatomb</home>
<webroot>/usr/share/mediatomb/web</webroot>
<storage driver="mysql">
<database-file>mediatomb.db</database-file> ←Sqlite3で使用される物だが省略すると起動しない
<host>localhost</host> ←MySQLのホスト名(localhostのままでいい)
<database>media</database> ←データベース名
<username>media</username> ←ユーザー名
<port>3306</port> ←MySQLが動いているポート(標準では3306)
<password>xxxxx</password> ←パスワード(無記入の場合空白もしくは行削除)
</storage>
<protocolInfo extend="yes"/> ←PS3対応の場合要(早戻しなどの機能が使えるようになる)
</server>
<import hidden-files="no">
<filesystem-charset>EUC-JP</filesystem-charset> ←Linuxのファイルシステムの文字コード
<metadata-charset>CP932</metadata-charset> ←id3タグの文字コード
<virtual-layout type="disabled"></virtual-layout> ←PC Directoryのみ使用
<autoscan>
<directory location="xxx" mode="timed" interval="86400" level="full" recursive="yes" hidden-files="no"/>
<directory location="xxx" mode="timed" interval="86400" level="full" recursive="yes" hidden-files="no"/>
</autoscan>
<mappings>
<extension-mimetype ignore-unknown="no">
<map from="jpg" to="image/jpeg"/>
<map from="jpeg" to="image/jpeg"/>
<map from="gif" to="image/gif"/>
<map from="png" to="image/png"/>
<map from="mp3" to="audio/mpeg"/>
<map from="m4v" to="video/mp4"/>
<map from="mp4" to="video/mp4"/>
<map from="mpg" to="video/mpeg"/>
<map from="mpeg" to="video/mpeg"/>
<map from="ogg" to="application/ogg"/>
<map from="asf" to="video/x-ms-asf"/>
<map from="asx" to="video/x-ms-asf"/>
<map from="wma" to="audio/x-ms-wma"/>
<map from="wax" to="audio/x-ms-wax"/>
<map from="wmv" to="video/x-ms-wmv"/>
<map from="wvx" to="video/x-ms-wvx"/>
<map from="wm" to="video/x-ms-wm"/>
<map from="wmx" to="video/x-ms-wmx"/>
<map from="m3u" to="audio/x-mpegurl"/>
<map from="pls" to="audio/x-scpls"/>
</extension-mimetype>
<mimetype-contenttype>
<treat mimetype="audio/mpeg" as="mp3"/>
<treat mimetype="application/ogg" as="ogg"/>
<treat mimetype="audio/x-flac" as="flac"/>
<treat mimetype="image/jpeg" as="jpg"/>
<treat mimetype="audio/x-mpegurl" as="playlist"/>
<treat mimetype="audio/x-scpls" as="playlist"/>
</mimetype-contenttype>
</mappings>
</import>
</config>
これでMediaTombを起動
# service mediatomb start
その他詳細については、MediaTombサイトのDocumentを読んで設定してください。
≪ 続きを隠す
クリックしてくれると更新の励みになります==>>