<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Real Beat &#187; gentoo</title>
	<atom:link href="http://nobu666.com/category/gentoo/feed" rel="self" type="application/rss+xml" />
	<link>http://nobu666.com</link>
	<description>Keep drinking, Keep listening to music, Go fuck yourself</description>
	<lastBuildDate>Mon, 10 May 2010 14:42:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iTunesサーバーをたてて、LANで曲を共有するようにした</title>
		<link>http://nobu666.com/2008/09/24/637.html</link>
		<comments>http://nobu666.com/2008/09/24/637.html#comments</comments>
		<pubDate>Tue, 23 Sep 2008 16:02:22 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[diary]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>music</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/?p=637</guid>
		<description><![CDATA[前から使ってたけど今はあまり使ってないデスクトップ、最近主力のMacBook、たまに使うLet&#8217;s NoteとうちにはPCが3台ある。あとGentooサーバー。全部の環境からmp3を共有したかったので、Gen [...]]]></description>
			<content:encoded><![CDATA[<p>前から使ってたけど今はあまり使ってないデスクトップ、最近主力のMacBook、たまに使うLet&#8217;s NoteとうちにはPCが3台ある。あとGentooサーバー。全部の環境からmp3を共有したかったので、GentooでiTunesサーバーをたてて共有することにした。</p>
<p>まずはデスクトップからごっそり外付けHDDにmp3をコピー。1万曲超、60GBくらいあった。これをGentooにぶっさして、とりあえず放置。Gentooで環境構築。</p>
<p><code>
<pre>
$ wget http://www.porchdogsoft.com/download/howl-1.0.0.tar.gz
$ tar zxf howl-1.0.0.tar.gz
$ cd howl-1.0.0
$ ./configure &#038;&#038; make &#038;&#038; sudo make install &#038;&#038; cd
$ sudo emerge libogg
$ sudo emerge libvorbis
$ sudo emerge mt-daapd
$ sudo cp /etc/mt-daapd.conf.example /etc/mt-daapd.conf
</pre>
<p></code></p>
<p>confは適当にmp3の入った外付けHDDのmount先を指定したりweb_rootのパスワード指定したりする程度。これであっさり行くと思ったら、まずこのままではmt-daapdが起動しない。なぜか知らないが/etc/init.d/mt-daapdで、depend()部分が間違ってるのが原因。mDNSResponderをmDNSResponderPosixに修正、mDNSResponderPosixを起動してから再度動かすと動いた。</p>
<p>これでとりあえず動いたものの、MacのiTunes上からは文字化けの嵐。WindowsのiTunesでは問題ない。つまり文字コードの問題だな。ここは先人の知恵を借り、ググってみるとwindows上で変換しるとよいことが判明。HDDを一旦デスクトップにつないで、iTunesで曲を全部選択して「ID3タグを変換」→「Unicodeを元に戻す」。何故かうまく行かないで化けちゃうのがあるので、個々に探して同様に変換したら直った。とりあえずこれでタグは問題なくUnicodeになったので、再度Gentooにつないでmountしてmt-daapdのキャッシュをクリアしたらok。ちなみにmountするときには、mount -o noauto,users,umask=000,iocharset=utf8とか言ってやらないと正しくGentoo上で日本語が読めない。</p>
<p>これでokかと思いきや、やっぱり文字化けは解消せず。色々調べてみたら、<a href="http://www.kzsoft.to/~kazu/mt-daapd/">パッチ</a>を当てれば解決することが判明。</p>
<p><code>
<pre>
$ sudo emerge -C mt-daapd
$ wget http://nchc.dl.sourceforge.net/sourceforge/mt-daapd/mt-daapd-0.2.4.2.tar.gz
$ tar zxf mt-daapd-0.2.4.2.tar.gz
$ cd mt-daapd-0.2.4.2
$ wget http://www.kzsoft.to/~kazu/mt-daapd/patch/mt-daapd-0.2.4-cp932.patch
$ patch < mt-daapd-0.2.4.2.tar.gz
</pre>
<p></code></p>
<p>parser.cのパッチでこけるので、手動でパッチした。とりあえずdiffを残しておく。</p>
<p><code>
<pre>
--- src/parser.c.orig   2008-04-20 04:44:54.000000000 +0900
+++ src/parser.c        2008-09-23 17:16:15.000000000 +0900
@@ -132,8 +132,18 @@
 #define AGO 287
 #define INTERVAL 288

+#define USE_CP932

-
+#ifdef USE_CP932
+  #define UNKNOWN_STR    "UNKNOWN"
+  #ifndef FILESYSTEM_CES
+    #define FILESYSTEM_CES "CP932"
+  /*
+    #define FILESYSTEM_CES "UTF-8"
+    #define FILESYSTEM_CES "EUC-JP"
+  */
+  #endif
+#endif

 /* Copy the first part of user declarations.  */
 #line 1 "parser.y"
@@ -167,6 +177,11 @@
 #include <string.h>
 #include "playlist.h"

+#ifdef USE_CP932
+ #include <iconv.h>
+ #include <errno.h>
+#endif
+
 #define YYERROR_VERBOSE 1

 extern int yyerror(char *msg);
@@ -1828,6 +1843,43 @@

 #line 174 "parser.y"
+#ifdef USE_CP932
+#define MAX_ICONV_BUF 1024
+
+typedef enum {
+  ICONV_OK,
+  ICONV_TRYNEXT,
+  ICONV_FATAL
+} iconv_result;
+
+static iconv_result do_convert(const char* to_ces, const char* from_ces,
+                              char *inbuf,  size_t inbytesleft,
+                              char *outbuf_orig, size_t outbytesleft_orig) {
+  size_t rc;
+  iconv_result ret = ICONV_OK;
+
+  size_t outbytesleft = outbytesleft_orig - 1;
+  char* outbuf = outbuf_orig;
+
+  iconv_t cd  = iconv_open(to_ces, from_ces);
+  if (cd == (iconv_t)-1) {
+    return ICONV_FATAL;
+  }
+  rc = iconv(cd, &#038;inbuf, &#038;inbytesleft, &#038;outbuf, &#038;outbytesleft);
+  if (rc == (size_t)-1) {
+    if (errno == E2BIG) {
+      ret = ICONV_FATAL;
+    } else {
+      ret = ICONV_TRYNEXT;
+      memset(outbuf_orig, '\0', outbytesleft_orig);
+    }
+  }
+  iconv_close(cd);
+
+  return ret;
+}
+#endif
+

 PL_NODE *pl_newintpredicate(int tag, int op, int value) {
     PL_NODE *pnew;
@@ -1867,7 +1919,25 @@
     pnew->op=op;
     pnew->type=T_STR;
     pnew->arg1.ival=tag;
+#ifdef USE_CP932
+    if (!strcasecmp(FILESYSTEM_CES, "UTF-8")) {
     pnew->arg2.cval=value;
+      } else {
+       char* iconv_buf = (char*)calloc(MAX_ICONV_BUF, sizeof(char));
+       if (iconv_buf) {
+         iconv_result rc = do_convert("UTF-8", FILESYSTEM_CES, value, strlen(value),
+                                      iconv_buf, MAX_ICONV_BUF);
+         if(rc == ICONV_OK) {
+           pnew->arg2.cval = iconv_buf;
+         } else {
+           pnew->arg2.cval = strdup(UNKNOWN_STR);
+           free(iconv_buf);
+         }
+       }
+      } // if utf-8
+#else
+    pnew->arg2.cval=value;
+#endif
     return pnew;
 }
</pre>
<p></code></p>
<p>こけるのは#ifdef USE_CP932から#endifまでなので、まぁ手動で当てても特別問題はないだろう。あとは普通にconfigureしてmake &#038;&#038; make installなんだが。このままだと/etc/init.d/mt-daapdが使えないので、適当に以下のように編集する。</p>
<p><code>
<pre>
PIDFILE="/var/run/mt-daapd.pid"
CONFFILE="/etc/mt-daapd.conf"

depend() {
    need net
    need mDNSResponderPosix
}

start() {
    ebegin "Starting mt-daapd DAAP server"
    /usr/sbin/mt-daapd -c ${CONFFILE} &#038;
    eend $?
}

stop() {
    ebegin "Stopping mt-daapd DAAP server"
    kill `cat ${PIDFILE}`
    eend $?

    rm -f ${PIDFILE}
}
</pre>
<p></code></p>
<p>とりあえず今あるものを共有する、という意味ではこれで万事よいのだが、俺の環境ではまだ問題があった。実は外付けHDDは元々Windowsで使っていたものなので、当然フォーマットはNTFS。でもmountしてるのはGentooなわけなので、普通にmountしたのではどうがんばってもリードオンリーになってしまう。これでは新しく曲を追加したり出来ない訳で、これは困る。メインはMacBookなので、samba経由で書き込めないと困ってしまう訳だ。色々試行錯誤したんだけど、ntfs-3gとかいうのを使ったらすげーあっさりと書き込みできるようになった。</p>
<p><code>
<pre>
$ sudo emerge ntfs3g
$ sudo update-modules
$ sudo su -
# echo "/dev/sdb5   /mnt/usbhdd ntfs-3g    noauto,users,umask=000,iocharset=utf8 0 0" >> /etc/fstab
# logout
$ sudo mount  /dev/sdb5 /mnt/usbhdd
</pre>
<p></code></p>
<p>あとは/etc/mt-daapd.confで、rescan_intervalを適当な値に設定しておいてやればok。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2008/09/24/637.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mixiとblogをそのまま同期させると、del.icio.usのdaily postがmixiでは役立たずになってウザそうだからどうにかする</title>
		<link>http://nobu666.com/2008/04/03/609.html</link>
		<comments>http://nobu666.com/2008/04/03/609.html#comments</comments>
		<pubDate>Thu, 03 Apr 2008 09:27:59 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[mhp]]></category>
		<category><![CDATA[plagger]]></category>
		<category><![CDATA[program]]></category>
<category>mixi</category><category>plagger</category>
		<guid isPermaLink="false">http://nobu666.com/2008/04/03/609.html</guid>
		<description><![CDATA[mixiにそのまま投稿しちゃうと、本来リンクじゃないと困るものが、ただのテキストになってしまうわけで。どっちみち携帯から見てる人には無用なエントリになっちゃうし、いっそのことmixiには投稿しないようにしようと。一番てっ [...]]]></description>
			<content:encoded><![CDATA[<p>mixiにそのまま投稿しちゃうと、本来リンクじゃないと困るものが、ただのテキストになってしまうわけで。どっちみち携帯から見てる人には無用なエントリになっちゃうし、いっそのことmixiには投稿しないようにしようと。一番てっとり早いのはP::P::MixiDiary.pm内で、単純にif文でほげほげすることなんだけど。ちょっと気が向いたのでplugin初挑戦してみた。</p>
<p><code>
<pre>
package Plagger::Plugin::Filter::StripDeliciousDailyPost;
use strict;
use base qw( Plagger::Plugin );

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'update.entry.fixup' =&gt; \&amp;filter,
    );
}

sub filter {
    my($self, $context, $args) = @_;

    my $title = $args-&gt;{entry}-&gt;title;
    for my $entry ($args-&gt;{feed}-&gt;entries) {
        if ($entry->title =~ /^links for \d{4}-\d{2}-\d{2}$/i) {
            $context-&gt;log(info =&gt; "Delete Delicious daily post entry " . $entry-&gt;link);
            $args-&gt;{feed}-&gt;delete_entry($entry);
        }
    }
}

1;
__END__
</pre>
<p></code></p>
<p>やはりperlは書き慣れんな。yamlを以下のようにして動作確認。</p>
<p><code>
<pre>
plugins:
  - module: Subscription::Config
    config:
      feed:
        - url: http://nobu666.com/rss?feed=rss2
  - module: Filter::Rule
    rule:
      module: Deduped
      path: /tmp/blog2mixi.tmp
      compare_body: 1
  - module: Filter::Reverse
  - module: Filter::FindEnclosures
  - module: Filter::FetchEnclosure
    config:
      dir: /tmp/fetch-image
  - module: Filter::FormatText
  - module: Filter::EntryFullText
  - module: Filter::StripDeliciousDailyPost
  - module: Publish::MixiDiary
    config:
      username: メールアドレス
      password: パスワード
      interval: 10
      originally_link: 1
</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2008/04/03/609.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NICが認識しない件、解決</title>
		<link>http://nobu666.com/2008/02/20/557.html</link>
		<comments>http://nobu666.com/2008/02/20/557.html#comments</comments>
		<pubDate>Wed, 20 Feb 2008 06:35:31 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[diary]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>network</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2008/02/20/000557.html</guid>
		<description><![CDATA[dmesg&#124;grep eth してみたら、eth0からeth1にrenameしたよとか書いてあったorz ので、単純に
ln -sf /etc/init.d/net.lo /etc/init.d/net.eth1
sed [...]]]></description>
			<content:encoded><![CDATA[<p>dmesg|grep eth してみたら、eth0からeth1にrenameしたよとか書いてあったorz ので、単純に</p>
<p><code>ln -sf /etc/init.d/net.lo /etc/init.d/net.eth1<br />
sed -i 's/eth0/eth1/g' /etc/conf.d/net<br />
/etc/init.d/net.eth1 start</code></p>
<p>これだけでした。あとはルータ側でポート開けたり、スタティックルーティングしたりして、EM-ONE使って外から繋がることを確認。が、今度はメールが送れなくてしばし嵌った。プロバイダが変わったから、単純に/etc/postfix/main.cfのrelayhostを書き換えて、smtp_sasl_password_mapsで指定したファイルにSMTPホスト名とユーザ名とパスワード書いて、そいつをpostmapして/etc/init.d/postfix restartで終了だと思っていたのだが。</p>
<p>色々見直してmain.cfのrelayhostと、postmapするファイルの書き方を example.com:587 やら、[example.com]:587 やら試すもダメ。master.cf見直したりしても結局わからず。しかたないのでmain.cfの smtp* を全部虱潰しに調べるも特に以上は見あたらず。半ば諦めつつWebを検索してたら<a href="http://aerith.mydns.jp/regrets/2006/07/vine32postfixsmtp.html">Vine3.2のPostfixでSMTP認証</a>ってエントリで</p>
<blockquote><p>→main.cf へ smtp_sasl の設定を追加。 smtpd_sasl じゃないので、要注意。</p></blockquote>
<p>……もしやと思って見てみたら、smtpd_sasl_auth_enable = yes という記述はあったけども、 smtp_sasl_auth_enable = yes がなかったのが原因でしたとさ…。疲れたわ。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2008/02/20/557.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] 異なるアーキテクチャ間でクロスコンパイル</title>
		<link>http://nobu666.com/2006/11/19/449.html</link>
		<comments>http://nobu666.com/2006/11/19/449.html#comments</comments>
		<pubDate>Sun, 19 Nov 2006 14:27:30 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/11/19/000449.html</guid>
		<description><![CDATA[前提条件
基本的にはGentoo distcc ドキュメント・DistCC クロスコンパイルガイド、この2つのドキュメントの通り行う。気をつけなきゃいけないのは、「資源を借りる側」と「資源を貸す側」で若干設定が異なる点。 [...]]]></description>
			<content:encoded><![CDATA[<h4>前提条件</h4>
<p>基本的には<a href="http://www.gentoo.org/doc/ja/distcc.xml" target="_blank">Gentoo distcc ドキュメント</a>・<a href="http://www.gentoo.org/doc/ja/cross-compiling-distcc.xml" target="_blank">DistCC クロスコンパイルガイド</a>、この2つのドキュメントの通り行う。気をつけなきゃいけないのは、「資源を借りる側」と「資源を貸す側」で若干設定が異なる点。ここでは借りる側はi686(192.168.0.4)、貸す側はamd64(192.168.0.3)とする。</p>
<p>貸す側と借りる側で、gccのバージョンは同じであること。3.3.x同時はOKだが、3.3.xと3.2.xは混ぜないこと。</p>
<p>また、資源を借りる側は一方的に借りるだけで、相互に助け合わない設定とした。これは、貸す側はサーバなので24時間稼働しているが、借りる側はノートなのでそうした。</p>
<h4>資源を貸す側の設定</h4>
<p><code># emerge distcc crossdev<br />
# vi /etc/make.conf<br />
MAKEOPTS="-j8" #(CPUの数+1)*2 ここは全体じゃなくてサーバ単体で計算すべきなのかも。詳細不明…もしかしたら-j6が当たりなのかも?<br />
FEATURES="distcc"<br />
DISTCC_DIR="/var/tmp/.distcc"<br />
PORTDIR_OVERLAY="/usr/local/portage"<br />
# distcc-config --set-hosts "localhost 192.168.0.4"<br />
# vi /etc/conf.d/distccd<br />
DISTCCD_OPTS="${DISTCCD_OPTS} --allow localhost --allow 192.168.0.4" #--allow 192.168.0.0/24でも可<br />
# /etc/init.d/distcc start<br />
# rc-update add distcc default<br />
# crossdev -t i686<br />
</code></p>
<h4>資源を借りる側の設定</h4>
<p><code># emerge distcc<br />
# vi /etc/make.conf<br />
MAKEOPTS="-j8" #(CPUの数+1)*2<br />
FEATURES="distcc"<br />
DISTCC_DIR="/var/tmp/.distcc"<br />
# vi /etc/conf.d/distccd<br />
DISTCCD_OPTS="${DISTCCD_OPTS} --allow localhost" #相互に助け合いたい場合は--allow 192.168.0.3を足すか--allow 192.168.0.0/24にする<br />
# cd /usr/lib/distcc/bin<br />
# rm c++ g++ gcc cc<br />
# echo '#!/bin/bash' &gt; i686-pc-linux-gnu-wrapper<br />
# echo 'exec /usr/lib/distcc/bin/sparc-unknown-linux-gnu-${0##*/} "$@"' &gt;&gt; i686-pc-linux-gnu-wrapper<br />
# chmod a+x i686-pc-linux-gnu-wrapper<br />
# ln -s i686-pc-linux-gnu-wrapper cc<br />
# ln -s i686-pc-linux-gnu-wrapper gcc<br />
# ln -s i686-pc-linux-gnu-wrapper g++<br />
# ln -s i686-pc-linux-gnu-wrapper c++<br />
# /etc/init.d/distcc start<br />
# rc-update add distcc default<br />
# export CC="i686-pc-linux-gnu-gcc"<br />
</code></p>
<h4>実際に試す</h4>
<p>借りる側から何か(それなりに時間のかかりそうなものを)emergeし、貸す側でtopコマンドで見てみる。distccというUSERでdistccやcc1というプロセスが見えれば成功している。当たり前だがコンパイルは速くなるが、configureやアーカイブのunpackは速くならないのであしからず。また、貸す側ではデフォルトでnice -15で実行されている。これは /etc/conf.d/distccdのDISTCCD_NICEで設定されているので、貸す側が暇なマシンなら変更してもいい。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/11/19/449.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo][Gentoo] SNMP+RRDtool+cactiでサーバ監視</title>
		<link>http://nobu666.com/2006/11/12/442.html</link>
		<comments>http://nobu666.com/2006/11/12/442.html#comments</comments>
		<pubDate>Sun, 12 Nov 2006 03:03:34 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/11/12/000442.html</guid>
		<description><![CDATA[インストールまでは上手くいったけど設定に嵌って酷い目にあった。
必要なものをインストールする
以下のものが必要。

net-snmp
apache
php
mysql
rrdtool
cacti

さくっとemergeす [...]]]></description>
			<content:encoded><![CDATA[<p>インストールまでは上手くいったけど設定に嵌って酷い目にあった。</p>
<h4>必要なものをインストールする</h4>
<p>以下のものが必要。</p>
<ul>
<li>net-snmp</li>
<li>apache</li>
<li>php</li>
<li>mysql</li>
<li>rrdtool</li>
<li>cacti</li>
</ul>
<p>さくっとemergeするわけだが、USEフラグに注意。cactiにはapache2/snmp、phpにはapache2/snmp/sockets/mysqlあたりが必要(gdとかxmlも必須なのか?よくわらかんがこの辺は/etc/make.confでデフォルトで付けている)。</p>
<h4>初期設定</h4>
<p>cacti用のデータベースとユーザを作成し、付属のスクリプトでテーブルを作成する。</p>
<p><code># mysqladmin -u root create cacti -p<br />
# mysql cacti -u root -p &lt; /var/www/localhost/htdocs/cacti/cacti.sql<br />
# mysql -u root mysql -p -e"GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'p4ssw0rd'"<br />
# mysql -u root mysql -p -e"flush privileges"<br />
</code></p>
<p>次にphpのconfigファイルを、今設定したものに合わせて書き換える。</p>
<p><code># /var/www/localhost/htdocs/cacti/include/config.php<br />
$database_username = "cactiuser";<br />
$database_password = "p4ssw0rd";<br />
</code></p>
<h4>cron実行用のシステムアカウント作成とパーミッション変更</h4>
<p><code># useradd -g apache -d /dev/null -s /bin/false -c cacti cacti</code></p>
<p>ホームディレクトリを/dev/null、ログインシェルを/bin/falseにすることで、cactiというユーザでログインできないようにする。この辺は適当に手を抜いてrootでやったりすると怖いので忘れずに。次にcactiユーザでデータの読み書きするためにパーミションを変える。</p>
<p><code># chown -R cacti:apache /var/www/localhost/htdocs/cacti</code></p>
<p>全部変えちゃったけどrraとlogディレクトリだけでいいかも。未検証。</p>
<h4>cronの設定</h4>
<p>適当なタイミングでスクリプトをブン回す。とりあえず5分間隔に設定。</p>
<p><code># vi /etc/crontab<br />
*/5 * * * * cacti   /usr/bin/php /var/www/localhost/htdocs/cacti/cmd.php &gt; /dev/null 2&gt;&amp;1<br />
</code></p>
<h4>cactiの設定</h4>
<p>ブラウザから http://hostname/cacti/ にアクセス。デフォルトのユーザとパスワードはadmin/admin。ウィザードが始まるがNext押していけばいい。adminのパスワードは適当なものに変更する。</p>
<p>色々設定するところがあるが、一番下にある参考URLらへんを参照。</p>
<p>ここでrrdtoolからACCESS DENIEDと言われてグラフが上手く表示されなかった。よくわからんがcactiでadminじゃなくてcactiというユーザを作り、User Management→cacti→Graph PermissionsでDenyをAllowにお変更してSave。Graph Managementからなんかグラフを選んで、右上の*Turn On Graph Debug Mode.をクリックするとログが見えるようになるので押してみる。今度は&#8217;rra/localhost_load_1min_5.rrd&#8217;: No such file or directoryとか怒られる。</p>
<p>見てみると確かにrraの下が空っぽなのでダメらしい。/var/www/localhost/htdocs/cacti/cmd.phpを実行してもエラーらしきものは出ておらず。しばらくココで嵌ったが、/var/www/localhost/htdocs/cacti/poller.phpを実行すればOKだった。1回目は前のデータがないので怒られるが、もう1度やると問題なく実行された。そのあとcactiからはちゃんと見えるようになった。</p>
<h4>参考URL</h4>
<ul>
<li><a href="http://www.boreas.dti.ne.jp/~mishiro/" target="_blank">Net-SNMPの設定方法</a></li>
<li><a href="http://net-snmp.sourceforge.net/" target="_blank">net-snmp</a></li>
<li><a href="http://www.photonway.net/AboutRrdtool.html" target="_blank">About Rrdtool</a></li>
<li><a href="http://www.boreas.dti.ne.jp/~mishiro/rrdtool/" target="_blank">RRDtoolのすすめ</a></li>
<li><a href="http://cacti.net/" target="_blank">cacti</a></li>
<li><a href="http://cacti.loaded.jp/" target="_blank">グラフツールcactiとは?</a></li>
<li><a href="http://www.stackasterisk.jp/tech/systemManagement/snmp01_01.jsp" target="_blank">【連載 】SNMPによるネットワークシステムの監視</a></li>
<li><a href="http://www.aconus.com/~oyaji/suse9.3/cacti_linux1.htm" target="_blank">RRDTool+Cactiによるサーバ監視(Linux編)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/11/12/442.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] GentooにPlaggerをインストール</title>
		<link>http://nobu666.com/2006/11/11/439.html</link>
		<comments>http://nobu666.com/2006/11/11/439.html#comments</comments>
		<pubDate>Fri, 10 Nov 2006 16:29:02 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[plagger]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>plagger</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/11/11/000439.html</guid>
		<description><![CDATA[Gentooにはg-cpanという素晴らしいものがあるのだが、そこはあえて使わずにいく。というかなんか知らないけど上手くいかなかったので、仕方なく手動で入れたとも言う。とりあえず自宅サーバと言うことで、サックリrootに [...]]]></description>
			<content:encoded><![CDATA[<p>Gentooにはg-cpanという素晴らしいものがあるのだが、そこはあえて使わずにいく。というかなんか知らないけど上手くいかなかったので、仕方なく手動で入れたとも言う。とりあえず自宅サーバと言うことで、サックリrootになって入れることにする。そのほうが簡単。以前レンタルサーバで悩んだのがウソのようだ。ちゃんとログを取ってないので曖昧な記憶でメモ。</p>
<h4>準備</h4>
<p>別段何もない。</p>
<p><code># perl -MCPAN -e shell</code></p>
<p>基本全部デフォルトのままENTER押してりゃよし。Gentooの場合、cpanでガンガン入れる前にまず<br />
<code># emerge expat</code></p>
<p>これをやっておく。次にCPANのConfigを弄る。</p>
<p><code># vi /usr/lib/perl5/5.8.8/CPAN/Config.pm<br />
$CPAN::Config = {<br />
  'build_cache' =&gt; q[100],<br />
  'build_dir' =&gt; q[/root/.cpan/build],<br />
  'bzip2' =&gt; q[/bin/bzip2],<br />
  'cache_metadata' =&gt; q[1],<br />
  'check_sigs' =&gt; q[0],<br />
  'colorize_output' =&gt; q[0],<br />
  'commandnumber_in_prompt' =&gt; q[1],<br />
  'cpan_home' =&gt; q[/root/.cpan],<br />
  'curl' =&gt; q[/usr/bin/curl],<br />
  'ftp' =&gt; q[/usr/bin/ftp],<br />
  'ftp_passive' =&gt; q[1],<br />
  'ftp_proxy' =&gt; q[],<br />
  'getcwd' =&gt; q[cwd],<br />
  'gpg' =&gt; q[],<br />
  'gzip' =&gt; q[/bin/gzip],<br />
  'histfile' =&gt; q[/root/.cpan/histfile],<br />
  'histsize' =&gt; q[100],<br />
  'http_proxy' =&gt; q[],<br />
  'inactivity_timeout' =&gt; q[0],<br />
  'index_expire' =&gt; q[1],<br />
  'inhibit_startup_message' =&gt; q[0],<br />
  'keep_source_where' =&gt; q[/root/.cpan/sources],<br />
  'lynx' =&gt; q[],<br />
  'make' =&gt; q[/usr/bin/make],<br />
  'make_arg' =&gt; q[],<br />
  'make_install_arg' =&gt; q[],<br />
  'make_install_make_command' =&gt; q[/usr/bin/make],<br />
  'makepl_arg' =&gt; q[],<br />
  'mbuild_arg' =&gt; q[],<br />
  'mbuild_install_arg' =&gt; q[],<br />
  'mbuild_install_build_command' =&gt; q[./Build],<br />
  'mbuildpl_arg' =&gt; q[],<br />
  'ncftp' =&gt; q[],<br />
  'ncftpget' =&gt; q[],<br />
  'no_proxy' =&gt; q[],<br />
  'pager' =&gt; q[lv -Ou8 -c],<br />
  'prefer_installer' =&gt; q[EUMM],<br />
  'prerequisites_policy' =&gt; q[ask],<br />
  'scan_cache' =&gt; q[atstart],<br />
  'shell' =&gt; q[/bin/zsh],<br />
  'show_upload_date' =&gt; q[1],<br />
  'tar' =&gt; q[/usr/bin/tar],<br />
  'term_is_latin' =&gt; q[1],<br />
  'term_ornaments' =&gt; q[1],<br />
  'test_report' =&gt; q[0],<br />
  'unzip' =&gt; q[/usr/bin/unzip],<br />
  'urllist' =&gt; [q[ftp://ftp.kddilabs.jp/CPAN/]],<br />
  'wget' =&gt; q[/usr/bin/wget],<br />
};<br />
1;<br />
__END__</p>
<p># cpan -i Bundle::CPAN<br />
</code></p>
<h4>CPANモジュールのインストール</h4>
<p><a href="http://subtech.g.hatena.ne.jp/otsune/20060816/PlaggerCPAN" target="_blank">Bundle::CPANとPlaggerに依存するモジュール（メモ）</a>に従って進める。書いてあるとおり、TemplateとEncode::Detectはまともには入らないっぽいので諦めてforce installで。別段不都合はないので。</p>
<p>なんかRDF::Coreが上手く入らなくて困った記憶がある。emerge expatしてないせいだった、という記憶もあるが…ちょっと覚えてない。でもコマンドの履歴に以下のものが残っていた。</p>
<p><code># wget http://ftp.yz.yamagata-u.ac.jp/pub/lang/cpan/modules/by-module/RDF/DPOKORNY/RDF-Core-0.50.tar.gz<br />
# tar -zxvf RDF-Core-0.50.tar.gz<br />
# cd RDF-Core-0.50<br />
# perl Makefile.PL<br />
# make<br />
</code></p>
<p>手動で入れたっぽい。若年アルツで覚えてない。まぁとりあえず頑張って入れて、cpanシェルでtest Plaggerが通るまで頑張る。通ったらinstall Plagger。</p>
<h4>リポジトリから最新取得</h4>
<p>subversionを使ってリポジトリから最新版を持ってきてmakeする。</p>
<p><code># svn co http://svn.bulknews.net/repos/plagger/trunk/plagger<br />
# cd plagger<br />
# perl Makefile.PL<br />
# make<br />
</code></p>
<p>ここまで行ったら出来たも同然。Plagger3大罠の1つである、assetsのコピーを忘れないうちにやっておく。svnで最新版を入れたディレクトリのassets以下に、　.cpan/build/Plagger-x.x.xx/assets/plugins/Publish-Gmail/gmail_notify.tt をコピっておく。yamlのglobalでassets_pathを指定するのも忘れずに。ちなみにyamlのサンプルは .cpan/build/Plagger-x.x.xx/examples 以下に入っているので、適当な場所にコピって編集すべし。</p>
<p>まぁ何が言いたいかって言うとレン鯖だと非常に苦労したインストールも、自宅鯖なら超簡単だぜってことです。gmailのメール送信量制限も、自宅鯖なら無関係。cacheもレン鯖だと、HDDが1Gくらいしかないので気にしなきゃいけないけど自宅鯖にはほぼ無関係。足りなくなったら増やせばイイだけだし。Plagger自体それなりに負荷があるので、レン鯖の場合は30分単位くらいで回さないと怒られそうなのだが、それを気にしなくていいのが一番でかい。もう5分とかで回してる。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/11/11/439.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] rep2をSSL+Basic認証で使う</title>
		<link>http://nobu666.com/2006/11/04/429.html</link>
		<comments>http://nobu666.com/2006/11/04/429.html#comments</comments>
		<pubDate>Fri, 03 Nov 2006 17:24:07 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/11/04/000429.html</guid>
		<description><![CDATA[通勤時の電車の中では本を読んでいるか、暇つぶしに2ch見てるわけだが。どうせ携帯で見るなら自宅サーバのリソースも余ってることだし有効活用したい。そんなわけでrep2を使うことにした。
インストール
とりあえずダウンロード [...]]]></description>
			<content:encoded><![CDATA[<p>通勤時の電車の中では本を読んでいるか、暇つぶしに2ch見てるわけだが。どうせ携帯で見るなら自宅サーバのリソースも余ってることだし有効活用したい。そんなわけで<a href="http://akid.s17.xrea.com/" target="_blank">rep2</a>を使うことにした。</p>
<h4>インストール</h4>
<p>とりあえずダウンロードして、/var/www/localhost/rep2とかに置く。apacheは当然SSL有効でコンパイルしておくこと。phpはやたらに使用可能なフラグが多いのでメモっておく。</p>
<p><code># emerge -pv php</p>
<p>These are the packages that would be merged, in order:</p>
<p>Calculating dependencies... done!<br />
[ebuild   R   ] dev-lang/php-5.1.6-r6  USE="apache2 bzip2 cjk cli crypt curl curlwrappers gd iconv mysql ncurses nls pcre readline sasl session spell ssl threads unicode xml xmlrpc zlib (-adabas) -apache -bcmath -berkdb (-birdstep) -calendar -cdb -cgi -concurrentmodphp -ctype -db2 -dbase (-dbmaker) -debug -discard-path -doc (-empress) (-empress-bcs) (-esoob) -exif -fastbuild (-fdftk) (-filepro) (-firebird) -flatfile -force-cgi-redirect (-frontbase) -ftp -gd-external -gdbm -gmp -hardenedphp -hash -hyperwave-api -imap (-informix) -inifile -interbase -iodbc -ipv6 -java-external -kerberos -ldap -libedit -mcve -memlimit -mhash -ming -msql -mssql -mysqli -oci8 (-oci8-instant-client) -odbc -pcntl -pdo -pdo-external -pic -posix -postgres -qdbm -recode -reflection -sapdb -sharedext -sharedmem -simplexml -snmp -soap -sockets (-solid) -spl -sqlite (-sybase) (-sybase-ct) -sysvipc -tidy -tokenizer -truetype -vm-goto -vm-switch -wddx -xmlreader -xmlwriter -xpm -xsl -yaz -zip" 0 kB<br />
</code></p>
<p>rep2はPEARモジュールのいくつかが必須なので、PEARもと必須モジュールを入れる。eixで見つからなかったものはpearコマンドで入れ、見つかったものはemergeで入れた。</p>
<p><code># emerge PEAR-PEAR<br />
# pear install Net_UserAgent_Mobile-beta<br />
# pear install PHP_Compat<br />
# emerge PEAR-HTTP_Request<br />
# emerge PEAR-Pager<br />
# emerge PEAR-File<br />
</code></p>
<h4>phpの設定</h4>
<p>/etc/php/apache2-php5/php.iniの次のコメントアウトを外す。</p>
<p><code>[mbstring]<br />
mbstring.internal_encoding = EUC-JP<br />
mbstring.http_input = auto<br />
mbstring.http_output = EUC-JP<br />
mbstring.detect_order = auto<br />
mbstring.substitute_character = none;<br />
</code></p>
<h4>apacheの設定</h4>
<p>SSLを使うため、認証局と証明書が必要。<a href="http://nobu666.com/2006/10/29/000423.html">[修正版][memo] postfix + dovecotでSMTP AUTH &#038; IMAPなメールサーバを立ち上げる</a>で作成したものがあるのでそれを流用する。</p>
<p><code># cp -p /etc/ssl/postfix/server.crt /etc/apache2/ssl/<br />
# cp -p /etc/ssl/postfix/server.key /etc/apache2/ssl/<br />
</code></p>
<p>次にBasic認証に使う.htaccessをフォルダで上書きできるようにしておくため、/etc/apache2/modules.d/41_mod_ssl.default-vhost.confと/etc/apache2/vhosts.d/00_default_vhost.confの&lt;directory &#8220;/var/www/localhost/htdocs&#8221;&gt;部分を以下のように設定する。</p>
<p><code>&lt;directory "/var/www/localhost/htdocs"&gt;<br />
    Options FollowSymLinks<br />
    AllowOverride AuthConfig<br />
&lt;/directory&gt;<br />
</code></p>
<h4>.htaccessの設定</h4>
<p>/var/www/localhost/htdocs/rep2に.htaccessを作成(サイト全体に認証をかけたいならhtdocsの下でも可)。</p>
<p><code># vi /var/www/localhost/htdocs/rep2/.htaccess<br />
AuthName "User Authentication Required"<br />
AuthType Basic<br />
Require valid-user<br />
AuthUserFile /etc/apache2/.htpasswd<br />
# htpasswd2 -c /etc/apache2/.htpasswd ユーザ名<br />
</code></p>
<h4>apacheの起動パラメータ</h4>
<p>gentooのapacheは、有効にしたいモジュールを明示しないといけないので、/etc/conf.d/apache2を修正。</p>
<p><code># vi /etc/conf.d/apache2<br />
APACHE2_OPTS="-D SSL -D PHP5 -D DEFAULT_VHOST -D SSL_DEFAULT_VHOST"<br />
# /etc/init.d/apache2 restart<br />
</code></p>
<p>これで　https://ホスト名:443/rep2/　に行けばユーザ名とパスワードが聞かれるはず。念のため携帯からもアクセスして問題なく認証できれば万事OK。ただ携帯でパスワードを入力するのは面倒なので、どうにか携帯の固有IDでパスできないか調べ中。auだとHTTP_X_UP_SUBNOで取れるみたいなんだが…</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/11/04/429.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] GentooでUPS(APC ES 500)を使う</title>
		<link>http://nobu666.com/2006/10/30/424.html</link>
		<comments>http://nobu666.com/2006/10/30/424.html#comments</comments>
		<pubDate>Sun, 29 Oct 2006 16:29:11 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/30/000424.html</guid>
		<description><![CDATA[
Amazonで\7,000ちょっとという値段だったので、購入したのが届いた。流石に24時間稼働だとUPSがないと怖い。今年の雷で瞬断も多くあったので。付属のPowerCuteはWindowsとMacOS Xと商用Lin [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.co.jp/exec/obidos/ASIN/B0000AG7HB/realbeat-22/ref=nosim/" name="amazletlink" target="_blank"><img src="http://images-jp.amazon.com/images/P/B0000AG7HB.09.MZZZZZZZ.jpg" alt="APC ES 500" /></a></p>
<p>Amazonで\7,000ちょっとという値段だったので、購入したのが届いた。流石に24時間稼働だとUPSがないと怖い。今年の雷で瞬断も多くあったので。付属のPowerCuteはWindowsとMacOS Xと商用Linuxにしか対応していないので自力でどうにかする方法をメモ。</p>
<h4>準備と接続、認識確認</h4>
<p><code># emerge apcupsd</code></p>
<p>なにはなくともコレがないと始まらない。とりあえずインストールしたら一旦シャットダウンしてコンセントをUPSにつなぎ変え、付属のUSB通信ケーブルでUPSとサーバを接続して再起動。再起動したらdmesgを見てサーバがES500を認識しているか確認。</p>
<p><code>usbcore: registered new driver hiddev<br />
hiddev0: USB HID v1.10 Device [APC APC ES 500 FW:803.p6.A USB FW:p6] on usb-0000:00:10.2-2<br />
</code></p>
<p>上記のようなメッセージがあれば問題ない。が、</p>
<p><code>es500 hid device not claimed</code></p>
<p>とか出てたら認識していない。俺の場合は思い切り認識していなかった。要するにまたカーネル再構築。だがもう手慣れたモンなのでサクサクと再構築する。こういうときはマシンパワーがあると非常に楽だ。お約束の以下の呪文を唱える。</p>
<p><code># cd /usr/src/linux<br />
# make menuconfig<br />
</code></p>
<p>そして今の設定をLOADして、以下のところにチェックを付けて保存。</p>
<p><code>Device Drivers ---&gt;<br />
    USB Support ---&gt;<br />
        /dev/hiddev raw HID device support<br />
</code></p>
<p>またお約束の呪文。</p>
<p><code># make &amp;&amp; make modules_install<br />
# cp arch/x86_64/boot/bzImage /boot/なんか適当な名前<br />
</code></p>
<p>そしたら/boot/grub/grub.confを編集して再起動すればいい。今度はちゃんと認識されているはず。念のためapcaccess statusとやってエラーが出ないことを確認する。</p>
<h4>設定と動作確認</h4>
<p>次はapcupsdの設定を行う。</p>
<p><code># vi /etc/apcupsd/apcupsd.conf<br />
UPSCABLE usb<br />
UPSTYPE usb<br />
DEVICE<br />
LOCKFILE /var/lock<br />
ONBATTERYDELAY 6<br />
BATTERYLEVEL 5<br />
MINUTES 3<br />
TIMEOUT 10<br />
ANNOY 300<br />
ANNOYDELAY 60<br />
NOLOGON disable<br />
KILLDELAY 0<br />
NETSERVER on<br />
NISIP 0.0.0.0<br />
NISPORT 3551<br />
EVENTSFILE /var/log/apcupsd.events<br />
EVENTSFILEMAX 10<br />
UPSCLASS standalone<br />
UPSMODE disable<br />
STATTIME 0<br />
STATFILE /var/log/apcupsd.status<br />
LOGSTATS off<br />
DATATIME 0<br />
</code></p>
<p>殆どデフォルト。TIMEOUTに関しては動作確認のため10にした。これは10だと電源断から10秒でシャットダウンするということ。実際にapcupsdを動かして試してみる。</p>
<p><code># /etc/init.d/apcupsd start<br />
# rc-update add apcupsd default<br />
</code></p>
<p>思い切ってUPSのコンセントをぶっこ抜いてみる。ピーピーピーと警告音が鳴り、10秒後にシャットダウン処理が走れば成功。忘れないようにTIMEOUTは0にしておくこと。ここを0にしておくとUPS側のバッテリーで頑張ってくれるようになる。どのくらい頑張るかはBATTERYLEVELとMINUTESで決まる。BATTERYLEVELはバッテリ残量が残り何%になったらシャットダウンするかで、MINUTESは残り時間何分でシャットダウンするか。どちらかの条件を満たすとシャットダウンされる。お好みで変える。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/30/424.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[修正版][memo] postfix + dovecotでSMTP AUTH &amp; IMAPなメールサーバを立ち上げる</title>
		<link>http://nobu666.com/2006/10/29/423.html</link>
		<comments>http://nobu666.com/2006/10/29/423.html#comments</comments>
		<pubDate>Sun, 29 Oct 2006 08:42:48 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>mail</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/29/000423.html</guid>
		<description><![CDATA[[memo] postfix + dovecotでSMTP AUTH &#38; IMAPなメールサーバを立ち上げるがあまり正しくないので修正版。
ssmtpの削除
Gentooではいきなりpostfixを入れようとして [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nobu666.com/2006/10/25/000420.html">[memo] postfix + dovecotでSMTP AUTH &amp; IMAPなメールサーバを立ち上げる</a>があまり正しくないので修正版。</p>
<h4>ssmtpの削除</h4>
<p>Gentooではいきなりpostfixを入れようとしても、デフォルトでssmtpが入っていてblockされるのでssmtpを消すのが先決。</p>
<p><code># emerge -C ssmtp<br />
</code></p>
<h4>postfixとdovecotのインストール</h4>
<p>Gentooの基本だけど、emergeするときはemerge -pvでどんなフラグが有効になるか必ず確認。必要ないならpackage.useで外す。あとsaslが必要なのでこれは付けておく。あとなんでかわからないけどpostfixにsaslを付けるとついてくるcyrus-saslで、gdbmやcryptをUSEするとコンパイルに失敗したので外した。</p>
<p><code># emerge -pv postfix dovecot<br />
# echo "mmail-mta/postfix -mysql sasl" &gt;&gt; /etc/portage/package.use<br />
# echo "dev-libs/cyrus-sasl -mysql -java -gdbm -crypt" &gt;&gt; /etc/portage/package.use<br />
# emerge postfix dovecot<br />
</code></p>
<h4>オレオレ認証局の作成</h4>
<p>Gentooでの方法なので他のディストリではパスが違うようなので注意。</p>
<p><code># mkdir /etc/certs<br />
# chmod 700 /etc/certs<br />
# cd /etc/certs<br />
# cp /etc/ssl/misc/CA.pl .<br />
# perl ./CA.pl -newca<br />
CA certificate filename (or enter to create)<br />
(ENTER)<br />
Making CA certificate ...<br />
Generating a 1024 bit RSA private key<br />
..................................++++++<br />
.......................++++++<br />
writing new private key to './demoCA/private/cakey.pem'<br />
Enter PEM pass phrase:(パスフレーズを入力)<br />
Verifying - Enter PEM pass phrase:(同じパスフレーズをもう一度入力)<br />
-----<br />
You are about to be asked to enter information that will be incorporated<br />
into your certificate request.<br />
What you are about to enter is what is called a Distinguished Name or a DN.<br />
There are quite a few fields but you can leave some blank<br />
For some fields there will be a default value,<br />
If you enter '.', the field will be left blank.<br />
-----<br />
Country Name (2 letter code) [AU]:JP<br />
State or Province Name (full name) [Some-State]:Kanagawa<br />
Locality Name (eg, city) []:Yokohama<br />
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Private<br />
Organizational Unit Name (eg, section) []:Private<br />
Common Name (eg, YOUR name) []:nobu666.fam.cx<br />
Email Address []:root@nobu666.fam.cx</p>
<p>Please enter the following 'extra' attributes<br />
to be sent with your certificate request<br />
A challenge password []:(ENTER)<br />
An optional company name []:(ENTER)<br />
Using configuration from /etc/ssl/openssl.cnf<br />
Enter pass phrase for ./demoCA/private/cakey.pem:<br />
Check that the request matches the signature<br />
Signature ok<br />
Certificate Details:<br />
 (略)<br />
Certificate is to be certified until Oct 28 06:15:58 2009 GMT (1095 days)</p>
<p>Write out database with 1 new entries<br />
Data Base Updated<br />
</code></p>
<h4>クライアント用CA証明書とサーバ用CA証明書を作成</h4>
<p><code># cd /etc/certs/demoCA<br />
# openssl x509 -inform pem -in cacert.pem -outform der -out cacert.der<br />
# openssl x509 -in ./cacert.pem -out ./cacert.crt<br />
</code></p>
<h4>デジタル証明書のリクエストファイルを作成</h4>
<p><code># cd /etc/certs<br />
# perl ./CA.pl -newreq-nodes<br />
Generating a 1024 bit RSA private key<br />
...++++++<br />
...............................................................................................................++++++<br />
writing new private key to 'newkey.pem'<br />
-----<br />
You are about to be asked to enter information that will be incorporated<br />
into your certificate request.<br />
What you are about to enter is what is called a Distinguished Name or a DN.<br />
There are quite a few fields but you can leave some blank<br />
For some fields there will be a default value,<br />
If you enter '.', the field will be left blank.<br />
-----<br />
Country Name (2 letter code) [AU]:JP<br />
State or Province Name (full name) [Some-State]:Kanagawa<br />
Locality Name (eg, city) []:Yokohama<br />
Organization Name (eg, company) [Internet Widgits Pty Ltd]:nobu666.fam.cx<br />
Organizational Unit Name (eg, section) []:Admin<br />
Common Name (eg, YOUR name) []:nobu666.fam.cx<br />
Email Address []:root@nobu666.fam.cx</p>
<p>Please enter the following 'extra' attributes<br />
to be sent with your certificate request<br />
A challenge password []:(ENTER)<br />
An optional company name []:(ENTER)<br />
Request is in newreq.pem, private key is in newkey.pem<br />
</code></p>
<h4>リクエストファイルからX.509サーバ証明書の作成と署名</h4>
<p><code># perl ./CA.pl -sign<br />
Using configuration from /etc/ssl/openssl.cnf<br />
Enter pass phrase for ./demoCA/private/cakey.pem:<br />
Check that the request matches the signature<br />
Signature ok<br />
Certificate Details:<br />
        Serial Number:<br />
            ce:db:05:2a:6a:dc:75:17<br />
        Validity<br />
            Not Before: Oct 29 06:51:11 2006 GMT<br />
            Not After : Oct 29 06:51:11 2007 GMT<br />
        Subject:<br />
            countryName               = JP<br />
            stateOrProvinceName       = Kanagawa<br />
            localityName              = Yokohama<br />
            organizationName          = nobu666.fam.cx<br />
            organizationalUnitName    = Admin<br />
            commonName                = nobu666.fam.cx<br />
            emailAddress              = root@nobu666.fam.cx<br />
        X509v3 extensions:<br />
            X509v3 Basic Constraints:<br />
                CA:FALSE<br />
            Netscape Comment:<br />
                OpenSSL Generated Certificate<br />
            X509v3 Subject Key Identifier:<br />
                7B:0E:46:62:02:FB:B6:A6:05:DC:DE:75:2E:2D:5A:29:5D:31:79:F8<br />
            X509v3 Authority Key Identifier:<br />
                keyid:A7:51:EC:0A:BD:B6:70:68:A5:01:ED:8E:76:1F:FE:0C:4D:B2:A0:19</p>
<p>Certificate is to be certified until Oct 29 06:51:11 2007 GMT (365 days)<br />
Sign the certificate? [y/n]:y</p>
<p>1 out of 1 certificate requests certified, commit? [y/n]y<br />
Write out database with 1 new entries<br />
Data Base Updated<br />
Signed certificate is in newcert.pem<br />
# openssl x509 -in newcert.pem -out server.crt<br />
</code></p>
<h4>postfix用にシンボリックリンクを張る</h4>
<p><code># ln -sf /etc/certs/server.crt /etc/ssl/postfix/server.crt<br />
# ln -sf /etc/certs/newkey.pem /etc/ssl/postfix/server.key<br />
</code></p>
<h4>postfixの設定</h4>
<p><code># vi /etc/postfix/main.cf<br />
queue_directory = /var/spool/postfix<br />
command_directory = /usr/sbin<br />
daemon_directory = /usr/lib/postfix<br />
mail_owner = postfix<br />
myhostname = nobu666.fam.cx<br />
mydomain = nobu666.fam.cx<br />
myorigin = $mydomain<br />
inet_interfaces = all<br />
mydestination = $myhostname, localhost.$mydomain, $mydomain, mail.$mydomain, localhost<br />
unknown_local_recipient_reject_code = 550<br />
mynetworks_style = subnet<br />
mynetworks = 192.168.0.0/24, 127.0.0.0/8<br />
relay_domains = $mydestination<br />
alias_maps = hash:/etc/mail/aliases<br />
alias_database = hash:/etc/mail/aliases<br />
home_mailbox = .Maildir/</p>
<p>header_checks = regexp:/etc/postfix/header_checks<br />
smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)<br />
mydestination = $myhostname, localhost.$mydomain, $myhostname.$mydomain, mail.$mydomain, localhost<br />
debug_peer_level = 2<br />
debugger_command =<br />
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin<br />
         xxgdb $daemon_directory/$process_name $process_id &amp; sleep 5<br />
sendmail_path = /usr/sbin/sendmail<br />
mailq_path = /usr/bin/mailq<br />
setgid_group = postdrop<br />
html_directory = /usr/share/doc/postfix-2.2.10/html<br />
manpage_directory = /usr/share/man<br />
sample_directory = /etc/postfix<br />
readme_directory = /usr/share/doc/postfix-2.2.10/readme<br />
smtpd_use_tls = yes<br />
smtpd_tls_loglevel = 1<br />
smtpd_tls_cert_file = /etc/ssl/postfix/server.crt<br />
smtpd_tls_key_file = /etc/ssl/postfix/server.key<br />
smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache<br />
smtpd_sasl_auth_enable = yes<br />
smtpd_sasl_security_options = noanonymous<br />
smtp_sasl_security_options = noanonymous<br />
allow_mail_to_commands = alias,forward,include<br />
message_size_limit = 1024000<br />
smtpd_client_restrictions =<br />
            permit_mynetworks,<br />
            permit_sasl_authenticated,<br />
            permit_auth_destination,<br />
            reject<br />
# vi /etc/postfix/master.cf<br />
&lt; コメントアウトを外す &gt;<br />
submission inet n      -       n       -       -       smtpd<br />
        -o smtpd_etrn_restrictions=reject<br />
        -o smtpd_client_restrictions=permit_sasl_authenticated,reject<br />
</code></p>
<h4>saslの設定</h4>
<p><code># vi /etc/sasl2/smtpd.conf<br />
pwcheck_method: saslauthd<br />
# mkdir /var/state/saslauthd<br />
# chmod 700 /var/state/saslauthd<br />
# chown postfix /var/state/saslauthd<br />
</code></p>
<h4>dovecotの設定</h4>
<p><code>vi /etc/dovecot.conf<br />
protocols = pop3 imap<br />
ssl_disable = no<br />
ssl_cert_file = /etc/ssl/postfix/server.crt<br />
ssl_key_file = /etc/ssl/postfix/server.key<br />
default_mail_env = maildir:%h/.Maildir<br />
# chmod 755 /var/run/dovecot<br />
# chmod 750 /var/run/dovecot/login<br />
</code><br />
あとはデフォルトのまま。</p>
<h4>クライアントの設定</h4>
<p>まずはオレオレ認証局の証明書をクライアントに入れる必要がある（やらなくてもいいが警告が出るので…）。別にどうやってクライアントに渡してもOK。FTPとかSCPとかで適当に。メーラによって操作が違うがThunderbirdの場合は、ツール→オプション→プライバシー→セキュリティ→証明書を表示→認証局証明書→インポートと進んで、cacert.derを選択すればOK。あとはIMAPでアカウントを作って、受信は143番ポートでTLSを使うようにし、送信は587番ポートで同じくTLSを使うように設定する。送信テストするとユーザ名とパスワードが聞かれるので「パスワード無しで送信できないこと」「間違ったパスワードを入れて送信できないこと」「正しいパスワードを入れて送信できること」の3つを確認して終了。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/29/423.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] iptablesが使えないのでkernel再構築 &amp; sshdへのアタックをどうにかする</title>
		<link>http://nobu666.com/2006/10/28/421.html</link>
		<comments>http://nobu666.com/2006/10/28/421.html#comments</comments>
		<pubDate>Fri, 27 Oct 2006 19:12:00 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>kernel</category><category>memo</category><category>server</category><category>ssh</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/28/000421.html</guid>
		<description><![CDATA[なんつーかね、某krからのsshdへのBrute force attacksが酷すぎる。auth.logを埋め尽くすほどのアタックを食らったので対策することに。だが普通にインストールするとiptablesが動いてくれない [...]]]></description>
			<content:encoded><![CDATA[<p>なんつーかね、某krからのsshdへのBrute force attacksが酷すぎる。auth.logを埋め尽くすほどのアタックを食らったので対策することに。だが普通にインストールするとiptablesが動いてくれないので、カーネル再構築に挑戦する。</p>
<p>別に今回はkernelのバージョンを上げたいわけではなく、単純にカーネルのオプションを変えたいだけなので、emerge gentoo-sourcesはやらない。以下、rootになって作業を行う。あとmenuconfigはscreenの中でやると表示が乱れて酷いことになるので、screenをデタッチするなり抜けるなりしてからやったほうがいい。</p>
<p><code># cd /usr/src/linux<br />
# make menuconfig<br />
</code></p>
<p>Confgurationが立ち上がったら、まずLoad an Alternate Configuration Fileを選ぶ。&#8221;.config&#8221;が入力されているはずなので、そのままOKすると現在の設定が読み込まれる。そしたら</p>
<p><code>Networking  ---&gt;<br />
  Networking options  ---&gt;<br />
    Network packet filtering (replaces ipchains)  ---&gt;<br />
      Core Netfilter Configuration  ---&gt;<br />
         Netfilter Xtables support (required for ip_tables)<br />
</code></p>
<p>を選択。その下に色々あるが、よくわからないならMにしといてあとでModuleとして読めるようにしておくと吉。必要なのに何もチェックしないでおくと、再度カーネル再構築が必要になって面倒なので。チェックしたら1つ戻ってIP: Netfilter Configurationの中に入る。とりあえず必須なのはIP tables support (required for filtering/masq/NAT)と、IP range match support、Packet filtering、REJECT target support、address type match support、Full NAT、MASQUERADE target supportとかそのへん。終わったらTOPまで戻って、念のため設定ファイルをなんか名前付けて保存しておいたほうがいい。</p>
<p>あとはその辺のサイトに書いてあるとおり、お約束でOK。</p>
<p><code># make &amp;&amp; make modules_install<br />
# cp arch/x86_64/boot/bzImage /boot/なんか適当な名前<br />
# vi /boot/grub/grub.conf<br />
</code></p>
<p>grub.confの設定では、元々書いてあるものを絶対に消さないこと。消しちゃうと万が一再構築したカーネルで起動できなかったときに面倒。</p>
<p><code>title=Gentoo Linux 2.6.17-r8<br />
root (hd0,0)<br />
kernel /さっきbootの下にcpしたファイル名 root=/dev/sda3 vga=ask<br />
</code></p>
<p>とかで問題なし。vga=askの部分はまぁお好みで。/usr/src/linux/Documentation/fb/vesafb.txtとかを参考に。基本的にはこれでrebootして、上のtitleでつけた名前を選択して起動してやればとりあえずOKなはずだ。失敗したら残しておいた方で起動して修正すべし。消してしまったお馬鹿さんはinstall cdから起動して/dev/sda1とかをmountして編集すれば戻せる。あとvgaとかvideoのオプションは、間違うと画面に何も表示されなくなるので注意。まぁリモート操作がメインならそれでもいいのかも知れないけど、何かあったときにアレなんで…心配ならaskにしておいて選択するのが間違いない。</p>
<p>そこまで出来たらDebian GNU/Linux 3.1(sarge)運用ノートの<a href="http://www.musicae.ath.cx/diary/?200506c&amp;to=200506272#200506272" target="_blank">SSH Brute force attacks</a>の通りに設定してから</p>
<p><code># /etc/init.d/iptables save<br />
# /etc/init.d/iptables start<br />
# rc-update add iptables default<br />
</code></p>
<p>以上で終了。エラーが出てiptablesが動かない場合は必要なモジュールが選択漏れでコンパイルされていないとか、Mを選択したのにmodprobeなりinsmodしてない。てか俺もこの手順にたどり着くまで5回くらい再構築してこんな時間に…もう寝る!</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/28/421.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] postfix + dovecotでSMTP AUTH &amp; IMAPなメールサーバを立ち上げる</title>
		<link>http://nobu666.com/2006/10/25/420.html</link>
		<comments>http://nobu666.com/2006/10/25/420.html#comments</comments>
		<pubDate>Wed, 25 Oct 2006 14:59:30 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>mail</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/25/000420.html</guid>
		<description><![CDATA[2006/10/29追記: 以下の内容はイマイチ不正確なので[修正版][memo] postfix + dovecotでSMTP AUTH &#38; IMAPなメールサーバを立ち上げるで書き直しています。
Gentoo [...]]]></description>
			<content:encoded><![CDATA[<p>2006/10/29追記: 以下の内容はイマイチ不正確なので<a href="http://nobu666.com/2006/10/29/000423.html">[修正版][memo] postfix + dovecotでSMTP AUTH &amp; IMAPなメールサーバを立ち上げる</a>で書き直しています。</p>
<p>Gentooではいきなりpostfixを入れようとしても、デフォルトでssmtpが入っていてblockされるのでssmtpを消すのが先決。</p>
<p><code># emerge -C ssmtp<br />
</code></p>
<p>んでGentooの基本だけど、emergeするときはemerge -pvでどんなフラグが有効になるか必ず確認。postfixにmysqlがついちゃうので、必要ないならpackage.useで外す。あとsaslが必要なのでこれは付けておく。あとなんでかわからないけどpostfixにsaslを付けるとついてくるcyrus-saslで、gdbmやcryptをUSEするとコンパイルに失敗したので外した。</p>
<p><code># echo "mmail-mta/postfix -mysql sasl" &gt;&gt; /etc/portage/package.use<br />
# echo "dev-libs/cyrus-sasl -mysql -java -gdbm -crypt" &gt;&gt; /etc/portage/package.use<br />
# emerge -v postfix<br />
</code></p>
<p>postfixの設定は /etc/postfix/main.cf で行う。以下のように設定した。</p>
<p><code>soft_bounce = no<br />
myhostname = 普通はmyhostnameから最初の要素を取ったもの<br />
mydomain = gethostname()から得られるFQDN<br />
myorigin = $mydomain<br />
inet_interfaces = all<br />
mydestination = $myhostname, localhost.$mydomain, $mydomain, mail.$mydomain, localhost<br />
mynetworks_style = subnet<br />
mynetworks = 192.168.0.0/24, 127.0.0.0/8<br />
relay_domains = $mydestination<br />
alias_maps = hash:/etc/mail/aliases<br />
alias_database = hash:/etc/mail/aliases<br />
home_mailbox = .Maildir/<br />
header_checks = regexp:/etc/postfix/header_checks<br />
smtpd_banner = mail.$mydomain ESMTP $mail_name ($mail_version)<br />
smtpd_helo_required = yes<br />
disable_vrfy_command = yes<br />
strict_rfc821_envelopes = yes<br />
allow_percent_hack = yes<br />
swap_bangpath = yes<br />
allow_untrusted_routing = no<br />
message_size_limit = 1024000<br />
smtpd_recipient_restrictions = permit_sasl_authenticated,<br />
                               permit_mynetworks,<br />
                               reject_unauth_destination<br />
smtpd_sender_restrictions = reject_unknown_sender_domain<br />
smtpd_sasl_auth_enable = yes<br />
smtpd_sasl_local_domain =<br />
smtpd_sasl_security_options = noanonymous<br />
broken_sasl_auth_clients = no<br />
allow_mail_to_commands = alias,forward,include<br />
smtpd_client_restrictions = permit_mynetworks,<br />
                        reject_invalid_hostname,<br />
                        reject_non_fqdn_sender,<br />
                        reject_non_fqdn_recipient,<br />
                        reject_unknown_sender_domain,<br />
                        reject_unknown_recipient_domain,<br />
                        reject_rbl_client bl.spamcop.net,<br />
                        reject_rbl_client blackholes.mail-abuse.org,<br />
                        reject_rbl_client dynablock.wirehub.net,<br />
                        reject_rbl_client korea.services.net,<br />
                        reject_rbl_client opm.blitzed.org,<br />
                        reject_rbl_client relays.ordb.org,<br />
                        reject_rbl_client relays.visi.com,<br />
                        reject_rbl_client sbl.spamhaus.org,<br />
                        reject_rbl_client sbl-xbl.spamhaus.org,<br />
                        permit<br />
</code></p>
<p>hostnameとかdomainnameは適宜読み替えること。デフォルトから変えていないところは割愛した。<br />
次に/etc/postfix/master.cfの以下の部分のコメントアウトを外す。</p>
<p><code>submission inet n      -       n       -       -       smtpd<br />
        -o smtpd_etrn_restrictions=reject<br />
        -o smtpd_client_restrictions=permit_sasl_authenticated,reject<br />
</code></p>
<p>smtpd_client_restrictionsはmain.cfで書いてあるので消していいかも。あとデフォルトで有効になっているsmtpの行をコメントアウト。</p>
<p>次は/etc/sasl2/smtpd.confを以下のようにする。</p>
<p><code>pwcheck_method: saslauthd<br />
</code></p>
<p>ここまで出来たら送信は可能になったはずなので</p>
<p><code># /etc/init.d/postfix start<br />
# /etc/init.d/saslauthd start<br />
# rc-update add postfix default<br />
# rc-update add saslauthdd default<br />
</code></p>
<p>として、クライアントのメーラなどで、今使ってるメールアドレスに送信テストしてみるのを忘れずに。上手く行かないときはmyhostnameとかmydomainの設定がおかしいか、ルータでフィルタされてるか、587番か143番が該当サーバにIPマスカレードされていない。メーラではIMAPでアカウント作って、TLSを使うようにすればOKなはず。</p>
<p>次にdovecotだが、こっちは設定簡単。まずお約束でemerge -pv dovecotして、フラグを確認。何のフラグかわからないときはeuse -i フラグ名で調べること。付けるフラグがデフォルトと違うなら、postfixのときと同じように/etc/portage/package.useに書いて、emerge -av dovecot。とりあえずpamとsslだけでいいと思われる。設定ファイルは/etc/dovecot.confにあるのでそれを編集。</p>
<p><code>protocols = pop3 imap<br />
default_mail_env = maildir:%h/.Maildir<br />
</code></p>
<p>設定したらルータで110番を開けて、以下のお約束を行う。</p>
<p><code># /etc/init.d/dovecot start<br />
# rc-update add dovecot default<br />
</code></p>
<p>俺の場合dovecot startしたら&#8221;dovecot: Warning: Fixing permissions of /var/run/dovecot to be world-readable&#8221;とwarnがでたので以下のようにして回避した。バグっぽい。</p>
<p><code># chmod 755 /var/run/dovecot<br />
# chmod 750 /var/run/dovecot/login<br />
</code></p>
<p>メーラで受信しようとするとパスワードを聞かれるはずなので、入れないと弾かれることと、入れて受信できることの両方を確認して終了。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/25/420.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] サーバのCPU動作周波数を動的に変える</title>
		<link>http://nobu666.com/2006/10/24/418.html</link>
		<comments>http://nobu666.com/2006/10/24/418.html#comments</comments>
		<pubDate>Tue, 24 Oct 2006 06:50:23 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>cpu</category><category>gentoo</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/24/000418.html</guid>
		<description><![CDATA[[memo] サーバのCPU動作周波数を下げるの続き。
やってみないとわからんので、cpufreq_ondemandを試してみる。
# modprobe cpufreq_ondemand
# echo ondemand  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nobu666.com/2006/10/23/000415.html">[memo] サーバのCPU動作周波数を下げる</a>の続き。</p>
<p>やってみないとわからんので、cpufreq_ondemandを試してみる。</p>
<p><code># modprobe cpufreq_ondemand<br />
# echo ondemand &gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor<br />
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</p>
<p># cd /sys/devices/system/cpu/cpu0/cpufreq/ondemand/<br />
# ls<br />
ignore_nice_load  sampling_down_factor  sampling_rate  sampling_rate_max  sampling_rate_min  up_threshold<br />
# cat ignore_nice_load<br />
0<br />
# cat sampling_down_factor<br />
1<br />
# cat sampling_rate<br />
1040000<br />
# cat sampling_rate_max<br />
520000000<br />
# cat sampling_rate_min<br />
520000<br />
# cat up_threshold<br />
80<br />
</code></p>
<p>詳細は<a href="http://mowamowa.p.utmc.or.jp/~amedama/cgi-bin/wiki/wiki.cgi?page=Kernel+%A5%E1%A5%E2+ondemand" target="_blank">Kernel メモ ondemand</a>参照。とりあえずignore_nice_loadは1に設定しておいた。急がないけど負荷になりそうな作業なんかはniceすること。</p>
<p>実際にemerge &#8211;syncとかして/proc/cpuinfoを見てたら、普段1GHzで動作しているのが2GHz→1.8GHzとなって1GHzに戻った。上手く動いているっぽい。試しにnice revdep-rebuildとかすると1GHzから変わらないことも確認。とりあえずこのまま運用してみる。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/24/418.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[memo] TortoiseSVNからsvn+sshを使う</title>
		<link>http://nobu666.com/2006/10/24/417.html</link>
		<comments>http://nobu666.com/2006/10/24/417.html#comments</comments>
		<pubDate>Tue, 24 Oct 2006 06:36:27 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>server</category><category>ssh</category><category>subversion</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/24/000417.html</guid>
		<description><![CDATA[普通にsshで繋がるようになったらsvn+sshを使いたくなる。サーバー側はemerge subversionするぐらいで設定は特にない。svnadmin create /var/svn/hoge とか svn impo [...]]]></description>
			<content:encoded><![CDATA[<p>普通にsshで繋がるようになったらsvn+sshを使いたくなる。サーバー側はemerge subversionするぐらいで設定は特にない。svnadmin create /var/svn/hoge とか svn import ~/moge file:///var/svn/hogeとかしておくだけ。svnserveを立ち上げる必要はない。svn+sshで接続するときは、sshで認証した後svnserve -tを勝手にしてくれ、接続を切るとsvnserveプロセスもなくなってくれる。よってルータで3690番のポートを開けておくとかいう作業は必要ない。22番だけ開いていればいい。</p>
<p>クライアント側は、Poderosaで作った鍵(例えばファイル名をid_rsaとする)しかない場合はPuTTY用の鍵を作る。puttygenを起動して、秘密鍵を読み込んでパスフレーズを入力すれば変換される。変換された秘密鍵をid_rsa.ppkとして保存。とりあえずPuTTYを起動して接続-データで自動ログインのユーザ名と、接続-SSH-認証で認証のためのプライベートキーファイルでさっきの.ppkファイルを設定。接続してみてパスフレーズ入力してログイン出来ればOK。</p>
<p>次にputty.exeと同じフォルダにあるpageant.exeを起動する。タスクトレイに常駐するので右クリックして鍵の追加を選んで、.ppkを選択する。パスフレーズを入力すれば作業終わり。以降、PuTTYでもTortoiseSVNでもパスフレーズは入力しないでもいい。ただ、これはWindowsにログインしなおすと消えてしまうので、ログイン毎に鍵の追加→パスフレーズの入力を行う必要がある。ランチャーに登録するかスタートアップに入れておく。</p>
<p>後はTortoiseSVNの設定で、ネットワークにあるSSHクライアントにTortoisePlink.exeを設定。これでTortoiseSVNからリボジトリブラウザを開いて、URL欄に svn+ssh://ユーザ名@ホスト名/var/svn/hoge と入力してエラーが出なければ終了。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/24/417.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] USEフラグをいい感じに管理する</title>
		<link>http://nobu666.com/2006/10/24/416.html</link>
		<comments>http://nobu666.com/2006/10/24/416.html#comments</comments>
		<pubDate>Mon, 23 Oct 2006 17:40:03 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/24/000416.html</guid>
		<description><![CDATA[俺のようにしょっちゅうemergeしたい人はUSEフラグの管理が大変だ。知らないうちに勝手にgtk2フラグが有効になっててXがインストールされたりして大変ウザイ。そんなわけでGentoo使いの先輩に教えて貰ったeixとe [...]]]></description>
			<content:encoded><![CDATA[<p>俺のようにしょっちゅうemergeしたい人はUSEフラグの管理が大変だ。知らないうちに勝手にgtk2フラグが有効になっててXがインストールされたりして大変ウザイ。そんなわけでGentoo使いの先輩に教えて貰ったeixとeuseを使ってみる。</p>
<p><code>% sudo emerge eix<br />
% sudo eix-sync<br />
</code></p>
<p>euseはgentoolkitに入っている。eixはemerge &#8211;searchと似たようなモンだがこっちのほうが速いし使いやすい。んで、本題のeuseだが、使い方自体は&#8211;helpすりゃわかるんだが。フラグの説明見たり、どれが使われてるか見れたり、フラグを有効にしたり無効にしたりできる。つーか詳細はman euseで（ｗ euse使うとmake.confのUSEフラグの部分が整形されて見やすくなるのも嬉しい。まぁ説明見るだけなら /usr/portage/profiles/use.desc<br />
 見ればいいんだが。</p>
<p>同じくgentoolkitに含まれているequeryも激しく便利。こいつで<br />
<code>% equery depends mysql<br />
</code><br />
とかやってやればmysqlフラグに依存しているパッケージを調べることが出来るし、dependsをdepgraphに変えてやると依存関係をツリーで見れる。超便利。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/24/416.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] サーバのCPU動作周波数を下げる</title>
		<link>http://nobu666.com/2006/10/23/415.html</link>
		<comments>http://nobu666.com/2006/10/23/415.html#comments</comments>
		<pubDate>Mon, 23 Oct 2006 14:59:04 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>cpu</category><category>gentoo</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/23/000415.html</guid>
		<description><![CDATA[CPUに関する情報は/sys/devices/system/cpu/cpu0/cpufreq/で次のファイルをcatする。まぁファイル名のまんまだが。

affected_cpus : 影響する他のCPU。俺の場合はデュ [...]]]></description>
			<content:encoded><![CDATA[<p>CPUに関する情報は/sys/devices/system/cpu/cpu0/cpufreq/で次のファイルをcatする。まぁファイル名のまんまだが。</p>
<ul>
<li>affected_cpus : 影響する他のCPU。俺の場合はデュアルコアなので当然0と1</li>
<li>cpuinfo_cur_freq : 現在の動作周波数</li>
<li>cpuinfo_max_freq : 最大周波数。AMD64X2 3800+の場合は2000000</li>
<li>cpuinfo_min_freq : 最低周波数。AMD64X2 3800+の場合は1000000</li>
<li>scaling_available_freqyencies : 設定可能な周波数。AMD64X2 3800+の場合は2000000/1800000/1000000しかない。intelだともっと多いらしい</li>
<li>scaling_available_governors : 設定可能な動作モード。Gentooのデフォルトではperformanceのみ</li>
<li>scaling_cur_freq : 現在の動作周波数</li>
<li>scaling_driver : 周波数コントロールのための仕組みの名前</li>
<li>scaling_governor : 動作モード。scaling_available_governorsのどれか</li>
<li>scaling_max_freq : cpuinfo_max_freqと何が違うのかわからん</li>
<li>scaling_min_freq : cpuinfo_min_freqと何が違うのかわからん</li>
</ul>
<p>普段は高周波数で動いてくれなくていいというか、その方が電気代が安くなって地球に優しいためいい感じ。そんなわけで以下の手順を踏んで周波数を下げてみた。</p>
<p><code>(今の周波数を確認)<br />
% cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq</p>
<p>(どんなdriverがあるか探す)<br />
% find /lib/modules/2.6.17-gentoo-r7/ -name '*.ko'|grep cpu</p>
<p>(明らかにそれっぽい奴を見つけたので読み込む)<br />
% sudo modprobe cpufreq_powersave</p>
<p>(動作モードが増えたことを確認)<br />
% cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors</p>
<p>(動作モードを上で確認したやつに変更)<br />
# su - ; echo "powersave" &gt; /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor<br />
# exit</p>
<p>(周波数が下がったことを確認)<br />
% cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq<br />
</code></p>
<p>これだと確かに周波数は下がるが下がりっぱなしだ。Gentooだと最新を追っかけたい人はコンパイルをしょっちゅうするので、そういうときにいちいち戻すのが面倒だ。そこでcpufreq_ondeamndというdriverを使うと、なんかいい感じに自動化できそうな予感がする。が、もうちょっと調べて、しっかり設定しないと下がりっぱなしとか上がりっぱなしになりそうな予感がするのでとりあえずスルー。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/23/415.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[memo] Gentooインストールメモ</title>
		<link>http://nobu666.com/2006/10/22/413.html</link>
		<comments>http://nobu666.com/2006/10/22/413.html#comments</comments>
		<pubDate>Sun, 22 Oct 2006 11:04:41 +0000</pubDate>
		<dc:creator>nobu</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[memo]]></category>
		<category><![CDATA[server]]></category>
<category>gentoo</category><category>memo</category><category>server</category>
		<guid isPermaLink="false">http://nobu666.com/2006/10/22/000413.html</guid>
		<description><![CDATA[特に書くことないほどあっさり終了。LiveCDを焼いてそいつでブートし、デスクトップ画面が出てきたら&#8221;Gentoo Linux installer&#8221;をダブルクリックして指示に従っていくだけ。つかパ [...]]]></description>
			<content:encoded><![CDATA[<p>特に書くことないほどあっさり終了。<a href="http://mirror.gentoo.gr.jp/releases/amd64/current/livecd/livecd-amd64-installer-2006.1.iso">LiveCD</a>を焼いてそいつでブートし、デスクトップ画面が出てきたら&#8221;Gentoo Linux installer&#8221;をダブルクリックして指示に従っていくだけ。つか<a href="http://www9.ocn.ne.jp/~pcvolu/pcnet/gentopage122.htm" target="_blank">パソコンふぉあ障害者ず Gentoo Linux 2006.0(インストール-LiveCD-)</a>を参考に。変えたところはIPアドレスとかその辺のネットワーク設定周りと、ステージを3からにしたのと、CFLAGで-O3にしたぐらい。インストールが終わったら上部のメニューからrebootしてCD抜いて終わり。</p>
<p>pingして外に繋がることを確認したら<code>emerge --sync</code>してから、必要なものをガンガン入れるんだが、その前に<code>/etc/init.d/hdparm start</code>してDMAを有効にしておく。んでいい加減sshで繋いで作業したいので<code>nano -w /etc/ssh/sshd_config</code>で適切にsshを設定。<br />
<code>PermitRootLogin no<br />
RSAAuthentication yes<br />
PubkeyAuthentication yes<br />
AuthorizedKeysFile .ssh/authorized_keys<br />
PasswordAuthentication no<br />
PermitEmptyPasswords no<br />
ChallengeResponseAuthentication no<br />
</code><br />
とかそんな感じに。</p>
<p>クライアントで鍵セットを作って、USBメモリでサーバに公開鍵を置く。マウントするのは<br />
<code># mkdir /mnt/usbmemory<br />
# mount -t vfat /dev/sdb1 /mnt/usbmemory<br />
</code><br />
で、/mnt/usbmemoryが見えるようになる。後は公開鍵を置いてパーミッション変えればOK。<br />
<code>% mkdir ~/.ssh<br />
% cat /mnt/usbmemory/id_rsa >> ~/.ssh/authorized_keys<br />
% chmod 700 ~/.ssh<br />
% chmod 600 ~/.ssh/authorized_keys<br />
</code></p>
<p>クライアントからsshで繋いでrootになって、ひたすら<code>emerge -av パッケージ名</code>。入れたパッケージは以下の通り。</p>
<ul>
<li>管理系:gentoolkit/htop/traceroute/tcpdump</li>
<li>デーモン系:apache2/proftpd/mysql/subversion/trac/samba</li>
<li>ユーティリティ系:sudo/screen/ftp/zsh/w3m/svk/lv/nkf</li>
<li>言語:python/ruby/jdk/groovy</li>
</ul>
<p>keywordでmaskされてるとか怒られるやつは<br />
<code><br />
# ACCEPT_KEYWORDS="~amd64" emerge -av パッケージ名<br />
</code><br />
で入る。色々入れたり消したりしてるうちに依存関係がおかしくなったりしたときは、revdep-rebuildする。特定のライブラリに依存するもの、とかの指定もできる。</p>
<p>あとはapacheやらsambaやらの設定だな。</p>
]]></content:encoded>
			<wfw:commentRss>http://nobu666.com/2006/10/22/413.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
