WindowsからCygwin経由でCentOSにファイルを転送する

概要

TODO

とりあえずメモ程度。動くかどうかはまだ確かめていない。

ファイルなど

コマンドプロンプト

C:\>type D:\somewhere\filelist.txt | D:\somewhere\foo.cmd "hoge"

D:\somewhere\filelist.txt

Shift_JIS を想定している。日本語を含むパスは NG と想定している。

C:\Program Files (x86)\...\file1.txt
D:\新しいフォルダ\file2.txt

D:\somewhere\foo.cmd

@echo off

set BASH=C:\cygwin\bin\bash.exe
set DIR_PATH=~%dp0
set SCRIPT_FILE=./foo.sh
set DEST_DIR=%1

"%BASH%" --login -i -c "cat /dev/stdin | dos2unix | cygpath -f - | (cd '%DIR_PATH%'; bash '%SCRIPT_FILE%' '%DEST_DIR%')"

D:\somewhere\foo.sh

秘密鍵パスフレーズは無し。

#!/bin/bash

HOST=desthost
USER=ayweak
PRIVATE_KEY_FILE_PATH=$(dirname $0)/id_rsa.fuga

if [ $# -eq 0 ]; then
  exit 1
fi

DEST_DIR=$1

cat /dev/stdin | \
while read line
do
  if [ -f $line ]; then
    echo "$line"
  fi
done | tar -zcf - -T - | ssh -i "$PRIVATE_KEY_FILE_PATH" $USER@$HOST "$DEST_DIR"

desthost:~/.ssh/authorized_keys

from="srchost",command="/home/ayweak/bin/bar.sh" ssh-rsa ...

desthost:~/bin/bar.sh

#!/bin/bash

DEST_ROOT_DIR_PATH=/path/to/dest

if ! $(echo "$SSH_ORIGINAL_COMMAND" | grep -q '^[a-zA-Z_][a-zA-Z0-9_]*$'); then
  exit 1
fi

DEST_DIR=$SSH_ORIGINAL_COMMAND

if [ ! -e "$DEST_ROOT_DIR_PATH/$DEST_DIR" ]; then
  mkdir "$DEST_ROOT_DIR_PATH/$DEST_DIR"
fi

TEMP_DIR_PATH=$(mktemp -d)

tar -zxf - -C $TEMP_DIR_PATH
find $TEMP_DIR_PATH -type f -print0 | xargs -0 chmod 644
find $TEMP_DIR_PATH -type f -print0 | xargs -0 mv -t "$DEST_ROOT_DIR_PATH/$DEST_DIR"

rm -rf $TEMP_DIR_PATH

Xubuntu 13.10でBluetoothヘッドセットを使う

Xubuntu 13.04から13.10にアップデートしたらBluetoothヘッドセットから音が出なくなってしまいました。
Pulseaudioが認識?してくれないようです。

Bluetoothヘッドセットの設定は以下のようにしています。
Xubuntu 12.04でBluetoothヘッドセットを使う - ayweekend's blog

ググったところ、以下のページを見つけました。
sound - Pulseaudio not detecting bluetooth headset automatically - Ask Ubuntu

以下のように確認して、こちらの環境でもmodule-bluetooth-discoverがロードされていないことが分かりました。

$ pactl list | grep -i module-bluetooth-discover

上記のページには、以下のようにロードすればOKとありますが、こちらの環境ではエラーが出てしまいました。権限が無いといったエラーでした。

$ sudo pactl load-module module-bluetooth-discover

sudoを付けずに実行したらOKでした。

$ pactl load-module module-bluetooth-discover
$ pactl list | grep -i module-bluetooth-discover
        名前: module-bluetooth-discover

ということで、現在はログイン後に以下の一連のコマンドを実行するようにしています。問題とコマンドの実行内容との関係をきちんと理解できていませんが、とりあえず音が出るようになりました。

$ pulseaudio -k
$ pactl load-module module-bluetooth-discover
$ sudo service bluetooth restart

ejabberdにJWChatでアクセス

以下の要領でVirtualBoxCentOS 5.5にインストールしたejabberdに、JWChatでアクセスしてみます。
CentOS 5.5にejabberdをインストール - ayweekend's blog

以下のページに手順が記載されているので、参考にしながら進めます。
http://www.ejabberd.im/jwchat-localserver

ejabberdの設定

/opt/ejabberd-2.1.10/conf/ejabberd.cfgを編集します。

まずlistenの中の5280番ポートのところです。request_handlersのところがコメントアウトしてあるので、コメントを外して有効にします。

{listen,
 [
  ...
  {5280, ejabberd_http, [
                         {request_handlers, [
                                {["web"], mod_http_fileserver}
                         ]},
                         captcha,
                         http_bind,
                         http_poll,
                         web_admin
                        ]}

 ]}.

次にmoduleの中のmod_http_fileserverのところです。ここもコメントアウトしてあるので、コメントを外して有効にします。

{modules,
 [
  ...
  {mod_http_fileserver, [
    {docroot, "/opt/ejabberd-2.1.10/www"},
    {accesslog, "/opt/ejabberd-2.1.10/www/webaccess.log"},
    {content_types, [{".htm", "text/html"}]},
    {directory_indices, ["index.html", "index.htm"]}
  ]},
  ...
 ]}.

設定の有効化のため、ejabberdを再起動します。

~# /etc/init.d/ejabberd restart

5280番ポートを開けます。なお、SELinuxはすでに無効にしています。

~# system-config-securitylevel-tui -q -p 5280:tcp

JWChatのダウンロード

以下のサイトからjwchat-1.0.tar.gzをダウンロードします。
http://blog.jwchat.org/jwchat/

JWChatのインストール

解凍、ファイルのコピーや削除、設定の変更を行います。

~# tar zxf jwchat-1.0.tar.gz 
~# cp -r jwchat-1.0 jwchat
~# cd jwchat
jwchat# for a in $(ls *.en); do b=${a%.en}; cp $a $b; done
jwchat# rm -f *.html.* *.js.*
jwchat# vi config.js
jwchat# diff ../jwchat-1.0/config.js config.js 
29c29
< var SITENAME = "localhost";
---
> var SITENAME = "localhost.localdomain";

JWChatをejabberdのディレクトリへ移動します。

~# mkdir /opt/ejabberd-2.1.10/www
~# mv jwchat /opt/ejabberd-2.1.10/www/.
~# chown -R ejabberd:ejabberd /opt/ejabberd-2.1.10/www

JWChatからアクセス

CentOSはVirtualBoxのゲストOSでNAT接続です。そのためホストOSを経由してアクセスします。

VirtualBoxの仮想マシン設定から、CentOSのポートフォワーディングに「プロトコルTCP、ホストポート35280、ゲストポート5280」の設定を追加しておきます。

Firefoxでhttp://localhost.localdomain:35280/web/jwchat/index.htmlにアクセスしてみます。ログインページが表示されるのでログインしてみます。

f:id:ayweekend:20120516001614p:plain

ログイン出来ました。

f:id:ayweekend:20120516001615p:plain

ejabberdにPsiでアクセス

以下の要領でVirtualBoxCentOS 5.5にインストールしたejabberdに、Psiでアクセスしてみます。
CentOS 5.5にejabberdをインストール - ayweekend's blog

ejabberdの設定

/opt/ejabberd-2.1.10/conf/ejabberd.cfgに最初から以下のように設定があります。

{listen,
 [
  {5222, ejabberd_c2s, [
                        {certfile, "/opt/ejabberd-2.1.10/conf/server.pem"}, starttls,
                        {access, c2s},
                        {shaper, c2s_shaper},
                        {max_stanza_size, 65536}
                       ]},
...

5222番ポートを開けます。なお、SELinuxはすでに無効にしています。

~# system-config-securitylevel-tui -q -p 5222:tcp

Psiのインストール

PsiはVirtaulBoxのXubuntu 12.04にインストールします。

~$ sudo apt-get install psi

Psiからアクセス

CentOSとXubuntuはVirtualBoxのゲストOSでNAT接続です。そのためホストOSを経由してアクセスします。

VirtualBoxの仮想マシン設定からCentOSのポートフォワーディングを設定しておきます。

f:id:ayweekend:20120515003507p:plain

PsiでJIDとパスワード、接続先のホストとポート番号を指定します。

f:id:ayweekend:20120515003511p:plain

f:id:ayweekend:20120515003510p:plain

設定の後、オンラインにしようとするとエラーが出ます。

f:id:ayweekend:20120515003509p:plain

一方、CentOS/opt/ejabberd-2.1.10/logs/ejabberd.logを見てみると、以下のエラーが残っていました。

=ERROR REPORT==== 2012-05-15 00:25:54 ===
** State machine <0.531.0> terminating 
** Last event in was {xmlstreamelement,
                         {xmlelement,"starttls",
                             [{"xmlns","urn:ietf:params:xml:ns:xmpp-tls"}],
                             []}}
** When State == wait_for_feature_request
**      Data  == {state,{socket_state,gen_tcp,#Port<0.475>,<0.530.0>},
                        ejabberd_socket,#Ref<0.0.0.11085>,false,"3203444177",
                        {sasl_state,"jabber","localhost.localdomain",[],
                                    #Fun<ejabberd_c2s.1.52538782>,
                                    #Fun<ejabberd_c2s.2.77839348>,
                                    #Fun<ejabberd_c2s.3.97921512>,undefined,
                                    undefined},
                        c2s,c2s_shaper,false,true,false,false,
                        [verify_none,
                         {certfile,"/opt/ejabberd-2.1.10/conf/server.pem"}],
                        false,undefined,[],"localhost.localdomain",[],
                        undefined,
                        {pres_t,0},
                        {pres_f,0},
                        {pres_a,0},
                        {pres_i,0},
                        undefined,undefined,undefined,false,
                        {userlist,none,[],false},
                        unknown,unknown,
                        {{10,0,2,2},56954},
                        [],"en"}
** Reason for termination = 
** {{case_clause,{error,{open_error,-10}}},
    [{tls,tcp_to_tls,2},
     {ejabberd_socket,starttls,3},
     {ejabberd_c2s,wait_for_feature_request,2},
     {p1_fsm,handle_msg,10},
     {proc_lib,init_p,5}]}

ググッてみて以下のページが見つかりました。
http://stackoverflow.com/questions/4546076/ejabberd-tls-driver-error

libssl.so.0.9.8とlibcrypto.so.0.9.8がないからというようなことだそうです。記載されている通り確認してみます。

~# ldd /opt/ejabberd-2.1.10/lib/ejabberd-2.1.10/priv/linux-x86/lib/tls_drv.so 
	linux-gate.so.1 =>  (0x005cd000)
	libssl.so.0.9.8 => not found
	libcrypto.so.0.9.8 => not found
	libc.so.6 => /lib/libc.so.6 (0x00e49000)
	/lib/ld-linux.so.2 (0x001eb000)

ありませんでした。シンボリックリンクを作成します。

~# cd /lib/
lib# ln -s libssl.so.0.9.8e libssl.so.0.9.8
lib# ln -s libcrypto.so.0.9.8e libcrypto.so.0.9.8
lib# ls libssl.so.* libcrypto.so.*
libcrypto.so.0.9.8   libcrypto.so.6   libssl.so.0.9.8e
libcrypto.so.0.9.8e  libssl.so.0.9.8  libssl.so.6

もう一度確認してみます。今度は大丈夫なようです。

~# cd /opt/ejabberd-2.1.10/lib/ejabberd-2.1.10/priv/linux-x86/lib/
lib# ldd tls_drv.so 
./tls_drv.so: /lib/libcrypto.so.0.9.8: no version information available (required by ./tls_drv.so)
./tls_drv.so: /lib/libssl.so.0.9.8: no version information available (required by ./tls_drv.so)
	linux-gate.so.1 =>  (0x00598000)
	libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00ba2000)
	libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00651000)
	libc.so.6 => /lib/libc.so.6 (0x00110000)
	libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x00a2b000)
	libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x007fd000)
	libcom_err.so.2 => /lib/libcom_err.so.2 (0x00938000)
	libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x005df000)
	libresolv.so.2 => /lib/libresolv.so.2 (0x00e72000)
	libdl.so.2 => /lib/libdl.so.2 (0x003e4000)
	libz.so.1 => /usr/lib/libz.so.1 (0x00ed1000)
	/lib/ld-linux.so.2 (0x00e50000)
	libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x00a5e000)
	libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x00256000)
	libselinux.so.1 => /lib/libselinux.so.1 (0x00e0e000)
	libsepol.so.1 => /lib/libsepol.so.1 (0x00259000)

あらためてPsiでオンラインにすると、今度は成功しました。ただし、証明書のエラーが出ます。

f:id:ayweekend:20120515003512p:plain

また、/opt/ejabberd-2.1.10/logs/ejabberd.logを見てみると、接続のログが残っています。

=INFO REPORT==== 2012-05-15 00:52:50 ===
I(<0.443.0>:ejabberd_listener:281) : (#Port<0.477>) Accepted connection {{10,0,2,2},57284} -> {{10,0,2,15},5222}

コマンドラインでejabberdのユーザ登録

以下の要領でVirtualBoxCentOS 5.5にインストールしたejabberdに、ユーザを登録してみます。
CentOS 5.5にejabberdをインストール - ayweekend's blog

以下を参考にしました。
https://git.process-one.net/ejabberd/mainline/blobs/raw/v2.1.10/doc/guide.html#htoc74

まずejabberdctlのヘルプを見てみようとしましたが、エラーが出てしまいました。ejabberdユーザでejabberdを起動しているからでしょうか。

~# /opt/ejabberd-2.1.10/bin/ejabberdctl help
Failed RPC connection to the node ejabberd@localhost: nodedown

Commands to start an ejabberd node:
  start  Start an ejabberd node in server mode
  debug  Attach an interactive Erlang shell to a running ejabberd node
  live   Start an ejabberd node in live (interactive) mode

ejabberdユーザに切り替えてもう一度試してみます。

~# su - ejabberd
~$ /opt/ejabberd-2.1.10/bin/ejabberdctl help
Usage: ejabberdctl [--node nodename] [--auth user host password] command [options]

Available commands in this ejabberd node:

  backup file 
        Store the database to backup file 

  connected_users 
        List all established sessions 

  connected_users_number 
        Get the number of established sessions 

  delete_expired_messages 
        Delete expired offline messages from database 

  delete_old_messages days 
        Delete offline messages older than DAYS 

  dump file 
        Dump the database to text file 

  dump_table file table 
        Dump a table to text file 

  export_piefxis dir 
        Export data of all users in the server to PIEFXIS files (XEP-0227) 

  export_piefxis_host dir host 
        Export data of users in a host to PIEFXIS files (XEP-0227) 

  get_loglevel 
        Get the current loglevel 

  help [--tags [tag] | com?*] 
        Show help (try: ejabberdctl help help) 

  import_dir file 
        Import users data from jabberd14 spool dir 

  import_file file 
        Import user data from jabberd14 spool file 

  import_piefxis file 
        Import users data from a PIEFXIS file (XEP-0227) 

  incoming_s2s_number 
        Number of incoming s2s connections on the node 

  install_fallback file 
        Install the database from a fallback file 

  load file 
        Restore the database from text file 

  mnesia [info] 
        show information of Mnesia system 

  mnesia_change_nodename oldnodename newnodename oldbackup newbackup 
        Change the erlang node name in a backup file 

  outgoing_s2s_number 
        Number of outgoing s2s connections on the node 

  register user host password 
        Register a user 

  registered_users host 
        List all registered users in HOST 

  rename_default_nodeplugin 
        Update PubSub table from old ejabberd trunk SVN to 2.1.0 

  reopen_log 
        Reopen the log files 

  restart 
        Restart ejabberd 

  restore file 
        Restore the database from backup file 

  set_master nodename 
        Set master node of the clustered Mnesia tables 

  status 
        Get ejabberd status 

  stop 
        Stop ejabberd 

  stop_kindly delay announcement 
        Inform users and rooms, wait, and stop the server 

  unregister user host 
        Unregister a user 

  update module 
        Update the given module, or use the keyword: all 

  update_list 
        List modified modules that can be updated 

  user_resources user host 
        List user's connected resources 

Examples:
  ejabberdctl restart
  ejabberdctl --node ejabberd@host restart

Commands to start an ejabberd node:
  start  Start an ejabberd node in server mode
  debug  Attach an interactive Erlang shell to a running ejabberd node
  live   Start an ejabberd node in live (interactive) mode

registerで登録できるようです。試してみます。

~$ /opt/ejabberd-2.1.10/bin/ejabberdctl register ayweak localhost.localdomain foobar
User ayweak@localhost.localdomain successfully registered
~$ /opt/ejabberd-2.1.10/bin/ejabberdctl registered_users localhost.localdomain
admin
ayweak

CentOS 5.5にejabberdをインストール

VirtualBox (4.1.14 r77440)上にインストールしたCentOS 5.5で試しました。

インストールするejabberdのバージョンは2.1.10です。

ダウンロード

以下のページからLinux x86 32-bits Installer (ejabberd-2.1.10-linux-x86-installer.bin.gz)をダウンロードします。
http://www.process-one.net/en/ejabberd/downloads

インストール

以下にインストーラーの実行方法が記載されています。
https://git.process-one.net/ejabberd/mainline/blobs/raw/v2.1.10/doc/guide.html#htoc5

~# gzip -d ejabberd-2.1.10-linux-x86-installer.bin.gz
~# chmod +x ejabberd-2.1.10-linux-x86-installer.bin
~# ./ejabberd-2.1.10-linux-x86-installer.bin

最初に言語を選択します。日本語はないのでデフォルトの英語にします。

Language Selection

Please select the installation language
[1] Dutch - Nederlands
[2] English - English
[3] French - Français
[4] German - Deutsch
[5] Russian - Русский
[6] Simplified Chinese - 简体中文
[7] Spanish - Español
Please choose an option [2] :

ライセンス(GPLv2)が表示されます。同意します。

Welcome to the ejabberd Setup Wizard.

----------------------------------------------------------------------------
Please read the following License Agreement. You must accept the terms of this 
agreement before continuing with the installation.

Press [Enter] to continue :

... GPLv2 が表示されます ...

Do you accept this license? [y/n]: y

インストール先を指定します。デフォルトのままにします。

Please specify the directory where ejabberd will be installed.

Installation Directory [/opt/ejabberd-2.1.10]:

ドメインを指定します。デフォルトのままにします。

ejabberd server domain

Please enter the desired ejabberd domain name. The domain is the visible attribute that is added to the username to form the Jabber Identifier (for example: user@example.net). This computer must be known on the network with this address name.

ejabberd server domain [localhost.localdomain]:

管理者のユーザ名を指定します。デフォルトのままにします。

Administrator username

Please enter the administrator username for the current ejabberd installation. A Jabber account with this username will be created and granted administrative privileges. Don't use blankspaces in the username. 

Administrator username [admin]:

管理者のパスワードを指定します。

Administrator password

Please provide a password for the administrator user (at least 5 characters).

Administrator password :
Retype password :

クラスタリングについて聞かれます。デフォルトのままにします。

Cluster

Will this node be part of a cluster ? (Please note ejabberd clustering is intended for advanced users).

Cluster [y/N]:

インストールを開始して良いか聞かれます。そのまま進めます。

Setup is now ready to begin installing ejabberd on your computer.

Do you want to continue? [Y/n]:

----------------------------------------------------------------------------
Please wait while Setup installs ejabberd on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

インストール完了の表示と、Readmeファイルを見るか聞かれます。Readmeファイルは見ないことにして、これでインストール完了です。

Setup has finished installing ejabberd on your computer.

View Readme file? [Y/n]: n

ejabberdの起動

手動で起動

手動で起動する方法が、マニュアルに以下のように記載されています。

To start and stop ejabberd manually, use the desktop shortcuts created by the installer. If the machine doesn’t have a graphical system, use the scripts ’start’ and ’stop’ in the ’bin’ directory where ejabberd is installed.

https://git.process-one.net/ejabberd/mainline/blobs/raw/v2.1.10/doc/guide.html#htoc5

起動してみます。

~# /opt/ejabberd-2.1.10/bin/start
~# /opt/ejabberd-2.1.10/bin/status
The node ejabberd@localhost is started with status: started
ejabberd 2.1.10 is running in that node

続けて、停止してみます。

~# /opt/ejabberd-2.1.10/bin/stop 
Killed

CentOSの起動時に自動で起動

CentOSの起動時にejabberdが自動で起動される方法が、マニュアルに以下のように記載されています。

On a *nix system, if you want ejabberd to be started as daemon at boot time, copy ejabberd.init from the ’bin’ directory to something like /etc/init.d/ejabberd (depending on your distribution). Create a system user called ejabberd, give it write access to the directories database/ and logs/, and set that as home; the script will start the server with that user. Then you can call /etc/inid.d/ejabberd start as root to start the server.

https://git.process-one.net/ejabberd/mainline/blobs/raw/v2.1.10/doc/guide.html#htoc5
~# cp /opt/ejabberd-2.1.10/bin/ejabberd.init /etc/init.d/ejabberd
~# adduser ejabberd
~# chown -R ejabberd:ejabberd /opt/ejabberd-2.1.10/

/etc/init.dにコピーしたスクリプトで起動してみます。

~# /etc/init.d/ejabberd start
Starting ejabberd...
done.
~# ps ax | grep [e]jabberd
 1884 ?        S      0:00 /opt/ejabberd-2.1.10/bin/epmd -daemon
 1886 ?        Sl     0:00 /opt/ejabberd-2.1.10/bin/beam -K true -P 250000 -- -root /opt/ejabberd-2.1.10 -progname /opt/ejabberd-2.1.10/bin/erl -- -home /home/ejabberd -sname ejabberd@localhost -smp auto -noshell -noinput -noshell -noinput -mnesia dir "/opt/ejabberd-2.1.10/database/ejabberd@localhost" -s ejabberd -ejabberd config "/opt/ejabberd-2.1.10/conf/ejabberd.cfg" log_path "/opt/ejabberd-2.1.10/logs/ejabberd.log" -sasl sasl_error_logger {file,"/opt/ejabberd-2.1.10/logs/erlang.log"}

続けて、停止してみます。

~# /etc/init.d/ejabberd stop
Stopping ejabberd...
Killed
done.

CentOSを再起動してejabberdが自動で起動されるか確認してみます。起動していません。

~# ps ax | grep [e]jabberd
~#

ググッてみて以下のページが見つかりました。
https://support.process-one.net/browse/EJAB-1450

そういえばmysqldなどをchkconfigで自動で起動するかどうか設定した覚えがあります。

~# vi /etc/init.d/ejabberd
~# diff /opt/ejabberd-2.1.10/bin/ejabberd.init /etc/init.d/ejabberd 
1c1,10
< #! /bin/sh
---
> #! /bin/sh 
> #
> # ejabberd	Startup script for the ejabberd XMPP Server
> #
> # chkconfig: - 99 10
> # description:	ejabberd XMPP server
> 
> # Source function library. 
> . /etc/init.d/functions
>
~# chkconfig --add ejabberd
~# chkconfig --list ejabberd
ejabberd       	0:off	1:off	2:off	3:off	4:off	5:off	6:off
~# chkconfig ejabberd on
~# chkconfig --list ejabberd
ejabberd       	0:off	1:off	2:on	3:on	4:on	5:on	6:off

改めてCentOSを再起動してejabberdが自動で起動されるか確認してみます。起動しています。

~# ps ax | grep [e]jabberd
 1786 ?        S      0:00 /opt/ejabberd-2.1.10/bin/epmd -daemon
 1788 ?        Sl     0:00 /opt/ejabberd-2.1.10/bin/beam -K true -P 250000 -- -root /opt/ejabberd-2.1.10 -progname /opt/ejabberd-2.1.10/bin/erl -- -home /home/ejabberd -sname ejabberd@localhost -smp auto -noshell -noinput -noshell -noinput -mnesia dir "/opt/ejabberd-2.1.10/database/ejabberd@localhost" -s ejabberd -ejabberd config "/opt/ejabberd-2.1.10/conf/ejabberd.cfg" log_path "/opt/ejabberd-2.1.10/logs/ejabberd.log" -sasl sasl_error_logger {file,"/opt/ejabberd-2.1.10/logs/erlang.log"}

Xubuntu 12.04でBluetoothヘッドセットを使う

VirtualBox (4.1.14 r77440)上にインストールしたXubuntu 12.04で試しました。

ヘッドセットとアダプタは以下のものを使いました。2008年に購入したものです。

  • ヘッドセット:ソニーのDR-BT21G
  • Bluetooth USBアダプタ:プラネックスのBT-MicroEDR1

Bluetoothマネージャー

Xubuntuをインストールすると最初からBluetoothマネージャーのBluemanが動くようになっています。

f:id:ayweekend:20120509224628p:plain

VirtualBoxで動かしているので、Xubuntuのウィンドウのメニューバーの「デバイス」→「USBデバイス」からBluetooth USBアダプタを有効にします(「不明なデバイス」と出ていますが)。

f:id:ayweekend:20120509224901p:plain

Bluetooth USBアダプタを有効にするとパネルにアイコンが表示されます。

f:id:ayweekend:20120509225340p:plain

試していませんが、通常のPCであれば、たぶんBluetooth USBアダプタがUSBポートに挿入されていればアイコンが表示されると思います。

ペアリング

アイコンを右クリックして、表示されるメニューの"Setup New Device..."を選択します。

f:id:ayweekend:20120509225341p:plain

ヘッドセットをペアリングモードにしておいて、表示されるセットアップウィザードに従って進めます。

f:id:ayweekend:20120509225347p:plain

ヘッドセット"DR-BT21G"を選んで・・・

f:id:ayweekend:20120509225346p:plain

パスコードを要求されるので入力して・・・

f:id:ayweekend:20120509225345p:plain

接続には「ヘッドセットサービス」を選択して・・・

f:id:ayweekend:20120509225344p:plain

接続完了です。

f:id:ayweekend:20120509225343p:plain

セットアップしたあとアイコンをクリックすると、ウィンドウが開いてヘッドセットが接続されていることが確認できます。

f:id:ayweekend:20120509225342p:plain

出力先設定

ヘッドセットから音が出るか確かめるため、FirefoxYoutubeにアクセスして動画を再生してみましたが、出ませんでした。代わりに、他につないでいた普通のスピーカーから音が出てしまいました。出力先を変更しないといけないようです。

メニューから音の設定を探してみると、どうやらPulseAudioというのが管理していそうな感じです。

f:id:ayweekend:20120509232554p:plain

しかし、特にBluetoothヘッドセットの設定は見つかりませんでした。そこでググッてみると以下のページが見つかりました。

http://ubuntuforums.org/showthread.php?t=1320460

pulseaudio-module-bluetoothを入れれば良さそうです。

~$ sudo apt-get install pulseaudio-module-bluetooth

インストールしても特に変化がなかったので一旦ログアウト&ログインしてみます(ヘッドセットはログイン時に自動で接続されました)。

改めてPulseAudioの音量調整ウィンドウを開くと、「出力装置」のタブに"DR-BT21G"の設定が表示されました。

f:id:ayweekend:20120509232553p:plain

"DR-BT21G"のチェックマークボタンをクリックすると、ヘッドセットから音が出るようになりました。