OpenBlocksS R

※このページは自分が構築する際にエラーが出たときに苦労したので
 エラーが起きた状況もそのまま掲載しています。
 従って、これを見て構築する場合は最後まで読んでから構築しないと
 とんでもない目に遭いますw

【SSD/Linux】


OpenBlocks Sを購入してから、 色々やりすぎてもう何をインストールしたかなんて
ぜんぜん分からないし、色々インストールしすぎてごちゃごちゃしているので、なんとか
インストールし直したかったw

OpenBlocksS発売から3年ほどたったので、Yahooオークションで安く売り出されるので
取り合えず購入^^

で、ぷらっとフォームのホームページに言ってみると、SSD/Linuxのコーナーができていた
SSD/Linuxとは非常にコンパクトなLinuxでOpenBlocksはこのSSD/Linuxをplathomeがカスタマイズして
リリースしていたのです。

プラットフォーム自身は新機種を売らなければならないので、OSのメンテはkernel-2.4.10でストップしてしまっています。
しかし、SSD/Linuxの方で最新カーネルに対応し、OpenBlocksSにも対応してくれています。

OpenBlocksSは通称「OpenBlocks200」とされ、266との区別をつけているようですので、以下OpenBlocks200又はobbs200と呼称します。

非常にありがたいです^^

上へ トップページへ

ファームウェアアップデート -20050826版-

早速カーネル(ファームウェア)をアップデートしましょう。

2005年8月26日にリリースされたファームウェアにアップデートします。

スペックは以下です。
* i386、OpenBlockS266、200対応
* kernel 2.4.26 + usagi-stable-release 5
* glibc 2.3.3
* gcc 3.3.5
* OpenBlockSシリーズ用クロス・コンパイラ
* OpenBlockSシリーズのbinary setに、クロス・コンパイルできないPerlは含まれていません

ぷらっとフォームのホームページから関係ファイルをダウンロードしてきます。

zImage.initrd.treeboot <- ファームウェア

Telnetサーバは標準で搭載されているのだが、FTPサーバは搭載されてないので
クライアント側でFTPサーバを用意してあげる必要がある。

Tiny FTP Daemonをインストールします。

適当にユーザを作成します。
ID:User1
PASS:User1
ホームディレクトリ:ファームウェアをダウンロードしたフォルダ

購入したOpenBlocks200Rに2.5インチハードディスクを取り付け、initボタンを押しながら
電源を投入します。

その後、インジケーターがウロウロしたら、ボタンを離すと準備完了。

オープンブロックスのEther1ポートが192.168.253.254 Ether2ポートが192.168.254.254に
なっているはずなので、同じHUB上に繋がっているPCのIPアドレスを192.168.253.20に設定します。

Windows系標準のTelnetクライアントソフトはしょぼいので、Tera Term Proをインストール

Ether1にLANケーブルを接続し、Tera Term Pro で 192.168.253.254に接続

LinuxServer-Kernel 2.4 version 1.50 (1 Nov. 2001)

LinuxServer.localdomain.co.jp login: user1
Password:User1
Welcome to Linux Server!

No mail.
[user1@LinuxServer user1]$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:80:6D:51:42:E9
inet addr:192.168.253.254 Bcast:192.168.253.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:90 errors:0 dropped:0 overruns:0 frame:0
TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
Interrupt:9 Base address:0xffe0

eth1 Link encap:Ethernet HWaddr 00:80:6D:51:42:EA
inet addr:192.168.254.254 Bcast:192.168.254.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
Interrupt:28 Base address:0x6000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0

[user1@LinuxServer user1]$ su
[user1@LinuxServer user1]$ root

[root@LinuxServer user1]# ftp 192.168.253.20
Connected to 192.168.253.20.
220-************************************************
220- Welcome to Tiny FTP Daemon /95
220- Version 0.5
220 ************************************************
Name (192.168.253.20:user1): user1
331 Give me your password
Password:
230--------------------------------------------------------------
230- Welcome!
230--------------------------------------------------------------
230 Logged in.
Remote system type is .

ftp> binary
200 Binary mode ready
ftp> get zImage.initrd.treeboot
local: zImage.initrd.treeboot remote: zImage.initrd.treeboot
200 Data port connected.
150 BINARY file D:/downloads/OpenBlocksS/ssdlinux20050826/zImage.initrd.treeboot ready to send (7182
368bytes)
226 Transfer finished successfully.
7182368 bytes received in 15.2 secs (4.6e+02 Kbytes/sec)
ftp> quit
221 ************* Thank you! ******************

[root@LinuxServer user1]# flashcfg f zImage.initrd.treeboot check
Erasing flash...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Erasing complete
Writing flash ...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Writing complete
flashcfg: done

[root@LinuxServer user1]# flashcfg s /dev/null
[root@LinuxServer user1]# shutdown -r now

Linux 2.4.26 (ssd-linux) (ttyp0)
ssd-linux login:root
Password:root


接続できない!!・・・・・あっそうだ、Telnetからrootでログインできないんだった;;
デフォルトでユーザあったら良いのに、シリアル接続でログインしないと無理みたいです。

改めてRJ-45とRS-232Cの変換機を使い、obbs200Rに接続しTera Term Proで接続。

ssd-linux login: root
Password:
SSD/Linux 0.3-20050826/2.4.26 #2 Fri Aug 26 04:10:10 JST 2005

No mail.


無事ログイン完了^^

上へ トップページへ

SSD/Linuxイメージインストール -20050909版-

ぷらっとフォームのサポートページにログイン後以下で、
ハードディスクからの起動をフラッシュメモリに保存するように書いていますが

flashcfg -s /etc/flashcfg
flashcfg: Unknown command
 usage: flashcfg -- default - restore files from flash
 flashcfg s file -- save directory or files to flash
 flashcfg r -- restore files from flash
 flashcfg d -- delete contents of flash
 flashcfg c [param] -- change root file system [initrd | harddisk]
 flashcfg f file [param] -- download file image to flash [check | nocheck]
 flashcfg m [param] -- change to download mode [check | nocheck]


^^;オプションの取り方間違えてますw

flashcfg s /etc/flashcfg



Saving file filesystembackup.tgz, length 23622Writing flash ...
>
>
Writing complete
flashcfg: done

ハードディスクのパーティションを切ります。

fdisk /dev/hda

まずルートパーティション「/」を作成

Command (m for help): n       新しいパーティションを作成
Command action
 e extended
 p primary partition (1-4)
p                  
プライマリパーティションとして作成
Partition number (1-4): 1      
1つ目

First cylinder (1-77520, default 1):  
そのままエンターを押し頭から
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-77520, default 77520): 30000  
半分ちょい少な目(自分の環境に合わせて適切に)

このパーティションを起動用にアクティブとしてマーク

Command (m for help): a
Partition number (1-4): 1

次にホームパーティション「/home」を作成

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (30001-77520, default 30001):
Using default value 30001
Last cylinder or +size or +sizeM or +sizeK (30001-77520, default 77520): 60000

スワップパーティションを作成

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (60001-77520, default 60001):
Using default value 60001
Last cylinder or +size or +sizeM or +sizeK (60001-77520, default 77520):
Using default value 77520


ファイルシステムをLinux swapに変更

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 82
Changed system type of partition 3 to 82 (Linux swap / Solaris)

Command (m for help): t
Partition number (1-4): 1


状態表示

Command (m for help): p

Device Boot Start End Blocks Id System
/dev/hda1 * 1 30000 15119968+ 83 Linux          
←*(アスタリスク)が付いていることを確認
/dev/hda2 30001 60000 15120000 83 Linux
/dev/hda3 60001 77520 8830080 83 Linux swap / Solaris  
←Linux swapになっていることを確認

Command (m for help): w    設定を書き込んで終了

さていよいよ、インストール作業なのですが、「sysinst」を使用するので
途中FTPでインターネットに接続します。

そのためにインターフェース設定をします。

ifconfig eth0 inet 192.168.11.254 netmask 255.255.255.0 broadcast 192.168.11.255
route add default gw 192.168.11.1 netmask 0.0.0.0 metric 1
echo "nameserver 192.168.11.1" > /etc/resolv.conf


↑自分の環境に合わせてください。

sysinst


SSD/Linux 0.3-20050826/2.4.26 Installer

Why do you choose Linux ?
We recommend you to use NetBSD, FreeBSD, or OpenBSD instead.

Are you sure to install [y/N] ? y
Really [y/N] ? y

It isn't smart ...

Setup Filesystem

Use Boot Device MB FStype BSize fsck Mount Point
--- ---- ---------- ------ ------- ----- ----- -----------
0. * * /dev/hda1 15749 ext2 4096 no /
1. /dev/hda2 15749 ext2 4096 no
2. * /dev/hda3 6653 swap no swap

x. Exit this menu.

Enter number [0-2 or x] : 1     ←ホームフォルダを作るパーティションを指定します。


Setup /dev/hda2

Use Boot Device MB FStype BSize fsck Mount Point
--- ---- ---------- ------ ------- ----- ----- -----------
0. * * /dev/hda1 15749 ext2 4096 no /
> 1. /dev/hda2 15749 ext2 4096 no
2. * /dev/hda3 6653 swap no swap

a. Toggle use this partition. c. Toggle mke2fs/mkswap with fsck.
f. Toggle fs type ext2/ext3. m. Enter/Change mount point.
b. Change block size.
x. Exit this menu.

Enter command [a, c, f, m, b or x] : m
Enter mount point : /home


Setup /dev/hda2

Use Boot Device MB FStype BSize fsck Mount Point
--- ---- ---------- ------ ------- ----- ----- -----------
0. * * /dev/hda1 15749 ext2 4096 no /
> 1. * /dev/hda2 15749 ext2 4096 no /home
2. * /dev/hda3 6653 swap no swap

a. Toggle use this partition. c. Toggle mke2fs/mkswap with fsck.
f. Toggle fs type ext2/ext3. m. Enter/Change mount point.
b. Change block size.
x. Exit this menu.

Enter command [a, c, f, m, b or x] : x


Setup Filesystem

Use Boot Device MB FStype BSize fsck Mount Point
--- ---- ---------- ------ ------- ----- ----- -----------
0. * * /dev/hda1 15749 ext2 4096 no /
1. * /dev/hda2 15749 ext2 4096 no /home
2. * /dev/hda3 6653 swap no swap

x. Exit this menu.

Enter number [0-2 or x] : x


Taking mkswap and mke2fs.
Are you sure [y/N] ? y

Setting up swapspace version 1, size = 6977613 kB
no label, UUID=328410ee-6189-485b-933b-1a7cb39dc72c
mke2fs 1.38 (30-Jun-2005)
/dev/hda1 is mounted; will not make a filesystem here!
mke2fs 1.38 (30-Jun-2005)
/dev/hda2 is mounted; will not make a filesystem here!
mount: /dev/hda1 already mounted or /mnt busy
mount: according to mtab, /dev/hda1 is already mounted on /mnt
/bin/mkdir: cannot create directory `/mnt/tmp': File exists
mount: /dev/hda2 already mounted or /mnt//home busy
mount: according to mtab, /dev/hda2 is mounted on /mnt/home


Select Distributions

0. Generic Kernel : yes
1. Base : yes
2. System (/etc) : yes
3. Compiler : yes
4. Manuals : yes
5. Contributions : no
6. Source : no       ←ソースとかも入れたかったのですが、この時点で何回か失敗しており眠いので、飛ばす

x. Exit this menu.

Enter number [0-6 or x] : x


Select install media

* Network : eth0

x. Exit this menu.

Enter command [x] : x


Setup for FTP download

0. FTP server : ftp.plathome.co.jp
1. Remote pathname : /pub/ssdlinux/0.3-20050826/powerpc-obs200/binary
2. Local pathname : /usr/INST
3. FTP proxy :
4. Login name : ftp
5. Login Password : Your_Mail_Address

x. Exit this menu.

ファームウェアをインストールした時期と、イメージをインストールした時期が
ずれていたので、現在公開されている場所に変更

Enter number [0-5 or x] : 1
Enter Remote pathnmae : /pub/ssdlinux/0.3-20050909/powerpc-obs200/binary


Setup for FTP download

0. FTP server : ftp.plathome.co.jp
1. Remote pathname : /pub/ssdlinux/0.3-20050909/powerpc-obs200/binary
2. Local pathname : /usr/INST
3. FTP proxy :
4. Login name : ftp
5. Login Password : hogehoge@hoge.com

x. Exit this menu.

Enter number [0-5 or x] : x


Start fetch binaries and extract.
Are you sure [y/N] ? y

さていよいよ開始されるのですが、プラットフォームのFTPサーバが遅いのなんのってw

Fetch kern.tgz ...
Fetch base.tgz ...
Fetch etc.tgz ...
Fetch comp.tgz ...
Fetch man.tgz ...
Extract kern.tgz ...
./System.map
./System.map.2426
Extract base.tgz ...
./bin/
./bin/bash
./bin/bashbug
./bin/sh






Make device files...


Write /etc/fstab.


Modify /etc/rc.conf.


Remove /mnt/usr/INST
Are you sure [y/N] ? y

Set root passwd
Changing password for root
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
New password:
Re-enter new password:

Password changed.


Installation Completed.

Good luck...

インストールできました。
再起動します。

shutdown -r now

ホスト名を設定
echo "ebis" > /etc/myname
インターフェースを設定
echo "inet 192.168.11.254 netmask 255.255.255.0 broadcast 192.168.11.255" > /etc/ifconfig.eth0
デフォルトゲートウェイを設定
echo "192.168.11.1" > /etc/mygate
DNSサーバを設定
echo "nameserver 192.168.11.1" > /etc/resolv.conf

上へ トップページへ

ファイルシステム -ext3-

不慮な事故にあったときに復旧率の高い、ジャーナルファイルシステムに変更します。
ファイルシステムをext2からext3に変更

ルートパーティション
tune2fs -j /dev/hda1
tune2fs 1.38 (30-Jun-2005)
Creating journal inode: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.


ホームパーティション
tune2fs -j /dev/hda2
tune2fs 1.38 (30-Jun-2005)
Creating journal inode: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

/etc/fstabを必ず変更してください
/dev/hda1 / ext3 defaults 0 0
/dev/hda2 /home ext3 defaults 1 1
/dev/hda3 swap swap defaults 0 0
none /proc proc defaults 0 0
none /dev/pts devpts gid=4,mode=620 0 0


上へ トップページへ

Telnet -ログインする-

さてTelnetでアクセスできるようにしないと、不便で仕方ありません。

inetd.confでは初期状態でコメントアウトされているので、#をはずします。
vi /etc/inetd.conf
# Washington University FTP Daemon:
#ftp stream tcp6 nowait root /usr/libexec/ftpd ftpd
telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd


inetdのPIDを確認して
ps ax
PID TTY STAT TIME COMMAND
1 ? S 0:04 init [2]
2 ? S 0:00 [keventd]
3 ? SN 0:00 [ksoftirqd_CPU0]
4 ? S 0:00 [kswapd]
5 ? S 0:00 [bdflush]
6 ? S 0:00 [kupdated]
9 ? S 0:00 [khubd]
166 ? S 0:00 /usr/sbin/pshd
169 ? Ss 0:00 /usr/sbin/syslogd -l localhost
171 ? Ss 0:00 portmap
189 ? Ss 0:00 cron
191 ? Ss 0:00 inetd -l
194 ? S 0:00 /usr/sbin/runled
198 ttyS0 Ss 0:00 -bash
199 ttyS1 Ss+ 0:00 /sbin/agetty 9600 ttyS1 vt100
211 ttyS0 S 0:00 su -
212 ttyS0 S 0:00 -su
256 ? Ss 0:00 /usr/sbin/inetd -l
264 ttyS0 R+ 0:00 ps ax

再起動
kill -HUP 256


Telnetはrootから接続できないのでユーザ作成

ディレクトリ作成
mkdir /home/yoshiwo
ユーザ作成
useradd -d /home/yoshiwo yoshiwo
パスワード設定
passwd takuma
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully


で、telnetで接続・・・・・・・できません;;

デフォルトでは「wheel」と言うグループしか接続は許可されていないようです。
グループ変更
usermod -g wheel yoshiwo

接続できる、ネットワークを設定
vi /etc/hosts.allow
ALL :192.168.11.


もう一度telnetで接続・・・・・OK!
よしよし、suでrootに・・・・・・・・・・・・NoooooooOOOOOOOO!!

ログを見てみると
ebis su[292]: pam_authenticate: Authentication failure

取り合えず、やってはいけない禁断のrootログインを許可します(ここはまねしないでくださいw)

vi /etc/pam.conf
「pam_securetty.so」が書かれている行をコメント

telnetで接続・・・・rootログインOK!!・・・・・・むなしい;;

だれか知ってる人おしえてね^^;

上へ トップページへ

DDNS登録 -nsupdate-

このobbs200RはDHCP割り当てプロバイダー上に設置するので、DDNSサーバにホストを登録
したいと思います。

【親サーバ】
vi /etc/named.conf

アクセス許可アドレスを定義する。
acl ddnsaccept {
  59.xxx.xxx.211;
};


ホスト受け入れゾーンにallow-updateを書く
zone "machtype.com" {
 type master;
 file "machtype.com";
 allow-update {
  ddnsaccept;
 };
};


namedを再起動

【子サーバ】
nsupdate -d

> server 219.111.5.60
> update add ebis.machtype.com. 3600 IN A 59.158.162.211
> update add 59.158.162.211 IN PTR ebis.machtype.com.

ttl 'IN' is not legal

あれっ?なんでINがダメなんだろ?、まぁ逆引きはプロバイダ側でやってるので良しとします。

> send
Reply from SOA query:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 34740
;; flags: qr aa rd ra ; QUESTION: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;ebis.machtype.com. IN SOA

;; AUTHORITY SECTION:
machtype.com. 0 IN SOA ns1.machtype.com.machtype.com. info.machtype.com.mac
htype.com. 25081301 28800 7200 604800 86400


Found zone name: machtype.com
The master is: ns1.machtype.com.machtype.com

Reply from update query:
;; ->>HEADER<<- opcode: UPDATE, status: NOERROR, id: 17370
;; flags: qr ra ; ZONE: 0, PREREQ: 0, UPDATE: 0, ADDITIONAL: 0


成功したのか確認。

nslookup
> server ns1.machtype.com
Default server: ns1.machtype.com
Address: 219.111.5.60#53
> ebis.machtype.com
Server: ns1.machtype.com
Address: 219.111.5.60#53

Name: ebis.machtype.com
Address: 59.158.162.211


成功しているみたいです。

【親サーバ】
DDNSサーバに「*.jnl」と言うファイルが出来ています。
中身をのぞいてみると

vi /var/named/machtype.com.jnl

~@^@^AQ~@^@^@^@!^Debis^Hmachtype^Ccom^@^@^A^@^A^@^@^N^P^@^D;


バイナリで記述されている中に「ebis」と言う文字発見!!
成功なのだろうw

さてと、まずは色々ダウンロードする為にwgetをインストールしなければ。

上へ トップページへ

DDNS登録 -DICE-

関連サイト:
http://www.hi-ho.ne.jp/yoshihiro_e/dice/

DDNS登録は、DHCP割り当て(動的IP)の際に必要なので↑の章では
テストができただけで、実際の運用には向きません。

ここでは、サーバが設置している場所にはwindowsクライアント端末が
設置してある前提で進めます。

まず、上の関連サイトからDICEをダウンロードし、インストールします。

DICEはDDNSサーバをプラグインファイルで定義し、設定するようなので
まず、DICEがインストールされた先に「plug-in」フォルダができているので
そこの中に自分のサーバ情報をプラグインします。

リファレンスみたいなものが見つからなかったので、取り敢ず既存のファイルを
変更して作ります。

【machtype.com.plg】プラグインファイルの中身

[DiCE]
Version=3.0                   
←そのまま

[ServiceInfo]
Name=Dynamic Machtype DNS           
←自分のサーバの名前
URL=http://machtype.com/            ←自分のサーバのアドレス(HOME) [Updater]
Method=GET
Script=http://machtype.com/~flesh_gogo/cgi-bin/nsupdate.cgi?domain=<H>.machtype.com&password=<P>&ip=<i>

DDNSを更新するためにアクセスするURL、DICEはCGIにアクセスし必要情報を渡しDDNS更新をします。
<H>にDICEで設定する自ホスト名
<P>にDICEで設定するサーバ名
<i>にDICEが↓で取得するIPアドレス名

IPCheck=http://machtype.com/~flesh_gogo/cgi-bin/remote_addr.cgi    ←現在のIPアドレスを取得
Encode=EUC             
  ↑使用する文字コード(たぶんこの文字コードでこのファイルを保存した方がよい)

[Domains]
machtype.com                  ←登録するドメイン

[Response]
1=Successful Update               ←CGIが出力する文字にIDをつける(成功したとき)
21=Invalid or inactive login          ←(ログイン失敗したとき)

[Messages]
1=IPアドレスを更新しました。          ←[Response]で定義したIDと一致した場合表示するメッセージ
21=パスワードが違います。

[Help]
ユーザー名の入力は不要です。

これでDICEのサービスのリストボックスに「machtype.com」が出てきますので
ホスト名とパスワードを登録すればOK

おっと、肝心な更新用CGIを公開します。

Perlで作る際、DNSモジュールを使うとかあったんですが、動作をシンプルにするために
設定ファイルを作り、nsupdateに放り込む事にしました。

【nsupdate.cgi】
#!/usr/bin/perl
use KCatch qw( mode=plain ); #エラー取得

####モジュール宣言##############
use CGI qw(:standard);
####モジュール宣言##############

####変数宣言###################
use vars qw( $strBasePath ); #基本となるパス
use vars qw( $strDataPath ); #設定ファイルが保存されるディレクトリ
use vars qw( $strDataFileName ); #設定ファイル名
####変数宣言###################

####初期設定####################
$strBasePath = "/home/flesh_gogo/public_html/cgi-bin/";
$strDataPath = "temp/";
$strDataFileName = "update.txt";
####初期設定####################

print "Content-type: text/html;\n\n";

if(param('password') eq "boobee")
{

  ###アップデート内容をテキストファイル化
  open txtOUT, "> " . $strBasePath . $strDataPath . $strDataFileName;
    flock(txtOUT, 2);

    print txtOUT "update delete " . param('domain') . ". IN A\n";
    print txtOUT "update add " . param('domain') . ". 3600 IN A " . param('ip') . "\n";
    print txtOUT "\n";
  close(txtOUT);

  `nsupdate $strBasePath$strDataPath$strDataFileName`;
  print "Successful Update";
}
else
{
  print "Invalid or inactive login";
}

###unlink($strBasePath . $strDataPath . $strDataFileName);

【remote_addr.cgi】
#!/usr/bin/perl
print "Content-type: text/html;\n\n";

print $ENV{'REMOTE_ADDR'};

Update 2005/11/23

上へ トップページへ

環境編 -wget-

サーバを構築するに当たって便利なwgetをインストールしておきます。

関連サイト:http://www.gnu.org/software/wget/wget.html

###ソースをダウンロード###

ftp ftp://ftp.gnu.org/pub/gnu/wget/
binary
get wget-1.9.1.tar.gz
bye


###展開###

tar zxfv wget-1.9.1.tar.gz

###移動###
cd wget-1.9.1

###環境設定###
./configure

###コンパイル###
make

意外と時間かかるなぁ・・・。

###インストール###
make install



上へ トップページへ

Perl編 -perl-

関連サイト:http://www.cpan.org/
     :http://www.research.att.com/sw/tools/sfio/

Apacheのミラーにしたいのとshよりperlの方が知っているのでPerlをインストール。

###ソースをダウンロード###
wget http://ftp.funet.fi/pub/CPAN/src/perl-5.9.2.tar.gz

###展開###
tar zxfv perl-5.9.2.tar.gz

###移動###
cd perl-5.9.2

ん?ダウンロードする先によってファイルが違うのかな?
INSTALLに書いてある↓のファイル2つがない!?
rm -f config.sh Policy.sh

まぁいっかw

mkdir /usr/local/perl-5.9.2
sh Configure -Dprefix=/usr/local/perl-5.9.2


Do you really want to continue? [n]
Build Perl for SOCKS? [n] y

Perl can be built to take advantage of long doubles which
(if available) may give more accuracy and range for floating point numbers.

If this doesn't make any sense to you, just accept the default 'n'.
Try to use long doubles if available? [n] y
(Your platform does not have any specific hints for long doubles.)

Checking for optional libraries...
No -lsfio.
No -lsocket.
No -linet.
Found -lnsl (shared).
No -lnm.
No -lndbm.
No -lgdbm.
No -ldbm.
Found -ldb (shared).
No -lmalloc.
Found -ldl (shared).
No -ldld.
No -lld.
No -lsun.
Found -lm (shared).
Found -lcrypt (shared).
No -lsec.
Found -lutil (shared).
Found -lc (shared).
No -lcposix.
No -lposix.
No -lucb.
No -lBSD.
No -lsocks5.
No -lsocks5_sh.

In order to compile perl5 on your machine, a number of libraries
are usually needed. Include any other special libraries here as well.
Say "none" for none. The default list is almost always right.

おっと、あまりにも「No」が多いのでCtrl+Cで一時中断!!

sfioをインストールしてみよう。
sfioとは「A Safe/Fast I/O Library」という事らしいです。
ん?、「Common Public License」ってなんじゃろ?、名前とメールアドレスと国を入力しないと
ダウンロードページに進めない (´・_・`)
いまどき珍しいなぁ・・・。

cd ..

###ソースをダウンロード###
wget http://XXXXXXXX
多分ソースの場所を公開してはいけないので↑

激しく、パッケージの中身が広がりそうな予感なので^^;
mkdir sfio_20050201
mv sfio_20050201* sfio_20050201
cd sfio_20050201/
tar xfv sfio_20050201.src.unix_tar.tar
cd src/lib/sfio/


###コンパイル###
make -f Makefile install   ←マルチスレッドの時は「install_mt」に書き換えて

###インストール###
make install

ついでに「vthread」という物もインストールします。
###移動###
cd ../vthread/

###コンパイル###
make -f Makefile install

###インストール###
make install

さて、いけてるかな?
cd ../../../../perl-5.9.2
sh Configure -Dprefix=/usr/local/perl-5.9.2

#############
No -lsfio.
#############
・・・できてない。

find / | grep libsfio
/root/sfio_20050201/lib/libsfio.a
/root/sfio_20050201/src/lib/sfio/libsfio.a

(余談ですが、ext3にしたせいか、2回同じ条件でfindした時すぐに結果がでました^^)
取り合えず、コピッてみる。

cp /root/sfio_20050201/lib/* /usr/lib/
cp /root/sfio_20050201/include/* /usr/include/

もっかい。
sh Configure -Dprefix=/usr/local/perl-5.9.2


Use which C compiler? [cc]

Checking for GNU cc in disguise and/or its version number...
/tmp/ccAUSeAI.o(.text+0x28): In function `main':
: undefined reference to `_stdprintf'
/tmp/ccAUSeAI.o(.text+0x28): In function `main':
: relocation truncated to fit: R_PPC_REL24 _stdprintf
collect2: ld returned 1 exit status

*** WHOA THERE!!! ***
Your C compiler "cc" doesn't seem to be working!
You'd better start hunting for one and let me know about it.

cp /root/sfio_20050201/src/lib/sfio/*.o /usr/lib/

やばい^^;gcc壊してしまったかなw
闇雲にコピー・・・・

cp /root/sfio_20050201/src/lib/sfio/*.h /usr/include/
cp /root/sfio_20050201/src/lib/sfio/Stdio_b/*.o /usr/lib
cp /root/sfio_20050201/src/lib/sfio/Stdio_b/*.h /usr/include/
cp /root/sfio_20050201/src/lib/sfio/Stdio_s/*.o /usr/lib/
cp /root/sfio_20050201/src/lib/sfio/Stdio_b/*.o /usr/lib/

だめだ・・・・orz

元に戻そう。

cd ..
mkdir binary20050916
cd binary20050916/


wget ftp://ftp.plathome.co.jp/pub/ssdlinux/0.3-LATEST/powerpc-obs200/binary/base.tgz
--13:41:00-- ftp://ftp.plathome.co.jp/pub/ssdlinux/0.3-LATEST/powerpc-obs200/binary/base.tgz
=> `base.tgz'
Resolving ftp.plathome.co.jp... 202.32.197.50
Connecting to ftp.plathome.co.jp[202.32.197.50]:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/ssdlinux/0.3-LATEST/powerpc-obs200/binary ... done.
==> PORT ... done. ==> RETR base.tgz ... done.
Length: 46,306,909 (unauthoritative)

33% [==================> ] 15,442,432 24.95K/s ETA 25:43

それにしても、ぷらっとフォームのftpサーバの回線はおそいなぁ・・・。
ギガビットHUBを扱ってる会社にしては・・・。

tar zxfv base.tgz
cp -R usr/ /
cp -R lib/ /

再起動・・・ やべっ、LED6で止まったままだorz
仕方がない・・・やり直すかw

このページの上から順番にやり直し再チャレンジ・・・今度はふつうに^^;

今度ここは全部「yes」に。

Select Distributions

0. Generic Kernel : yes
1. Base : yes
2. System (/etc) : yes
3. Compiler : yes
4. Manuals : yes
5. Contributions : yes
6. Source : yes

そして、Perlのインストール。
今回はエンター押しまくり(デフォルト)で。



Directory /usr/local/perl-5.9.2/bin doesn't exist. Use that name anyway?

binがないと言われまくります・・・んで作ります。

mkdir /usr/local/perl-5.9.2/bin
sh Configure -Dprefix=/usr/local/perl-5.9.2

###コンパイル###
make

###テスト###
make test

もう2時間ぐらい動きっぱなしなので、いったん寝ます・・・ZZZZzzzzz

Failed 6 test scripts out of 891, 99.33% okay.
### Since not all tests were successful, you may want to run some of
### them individually and examine any diagnostic messages they produce.
### See the INSTALL document's section on "make test".
### You have a good chance to get more information by running
### ./perl harness
### in the 't' directory since most (>=80%) of the tests succeeded.
### You may have to set your dynamic library search path,
### LD_LIBRARY_PATH, to point to the build directory:
### setenv LD_LIBRARY_PATH `pwd`; cd t; ./perl harness
### LD_LIBRARY_PATH=`pwd`; export LD_LIBRARY_PATH; cd t; ./perl harness
### export LD_LIBRARY_PATH=`pwd`; cd t; ./perl harness
### for csh-style shells, like tcsh; or for traditional/modern
### Bourne-style shells, like bash, ksh, and zsh, respectively.
u=45.96 s=17.46 cu=3477.96 cs=1086.88 scripts=891 tests=104115
make[2]: *** [_test_tty] Error 1
make[2]: Leaving directory `/root/wget-1.9.1/perl-5.9.2'
make[1]: *** [_test] Error 2
make[1]: Leaving directory `/root/wget-1.9.1/perl-5.9.2'
make: *** [test] Error 2


う〜んエラーです。
「LD_LIBRARY_PATH」にカレントディレクトリを指定して「t」フォルダで
「./perl harness」をしてみたら?的なことがかかれていると勝手に思いこみ
やってみる。

LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
cd t
./perl harness


op/pack.....................................ok 167/14697# Failed at op/pack.t line 630
# Failed at op/pack.t line 630

なんかとにかく「fail;」です。
実はデベロッパー版なので、リリース版に変更してみます。

wget http://search.cpan.org/CPAN/authors/id/N/NW/NWCLARK/perl-5.8.7.tar.gz
tar zxfv perl-5.8.7.tar.gz
cd perl-5.8.7
rm -f config.sh Policy.sh

mkdir /usr/local/perl-5.8.7
mkdir /usr/local/perl-5.8.7/bin
sh Configure -de -Dprefix=/usr/local/perl-5.8.7

make
make test
make install


今度はできました。

上へ トップページへ

Perl編 -Jcode-

関連サイト:http://search.cpan.org/~dankogai/Jcode-2.03/

本サーバでよく使っているので、インストールしておきます。

###ソースをダウンロード###
wget http://search.cpan.org/CPAN/authors/id/D/DA/DANKOGAI/Jcode-2.03.tar.gz

###展開###
tar zxfv Jcode-2.03.tar.gz

###移動###
cd httpd-2.0.52

###makeファイル作成###
perl Makefile.PL

###コンパイル###
make

###テスト###
make test

###インストール###
make install

 


上へ トップページへ

WWWサーバ編 -apacheインストール-

関連サイト:http://httpd.apache.org/

ミラーサーバを構築するので、本サーバと同じバージョンをダウンロード

###ソースをダウンロード###
wget http://archive.apache.org/dist/httpd/httpd-2.0.52.tar.gz

###展開###
tar zxfv httpd-2.0.52.tar.gz

###移動###
cd httpd-2.0.52

###新しいバージョンを上書きして、起動しなくなるのを防ぐためになるべく「prefix」は変更する###
./configure --prefix=/usr/local/httpd-2.0.52

###コンパイル###
make

###インストール###
make install

###コンフィグ設定###
本サーバのhttpd.confをコピー

###起動###
/usr/local/httpd-2.0.52/bin/httpd -f /usr/local/httpd-2.0.52/conf/httpd.conf

上へ トップページへ

WWWサーバ編 -analog-

関連サイト:http://www.analog.cx/

WWWサーバを構築したら、管理者はそのログを閲覧し、アクセス状況(負荷)や不都合が起こっていないか
把握しないと行けません。
そんなこんなでanalogをインストール。

###ソースをダウンロード###
wget http://www.analog.cx/analog-6.0.tar.gz

###展開###
tar zxfv analog-6.0.tar.gz

###移動###
cd analog-6.0

###コンパイル###
make


###コンフィグ設定###
本サーバのanalog.cfgをコピー


上へ トップページへ

WWWサーバ編 -wgetミラー-

本来の目的のミラーサーバ化します。
wgetにはミラーオプションという物があり、簡単にミラーが作れます。

wget -m --directory-prefix=/home/flesh_gogo/ ftp://USERID:PASSWORD@machtype.com/public_html/

一度取得したファイルは、最新になるまで取得しないので経済的ですw
取得したらドメイン名のディレクトリの中に入っているので、所有者設定をし
本来の場所にシンボリックリンクを張ります。

chown flesh_gogo:nobody /home/flesh_gogo/machtype.com/public_html -R
ln -s /home/flesh_gogo/machtype.com/public_html /home/flesh_gogo


そして、cronで毎日1回本サーバから取得します。

crontab -e
0 5 * * * wget -m --directory-prefix=/home/flesh_gogo/ ftp://USERID:PASSWORD@machtype.com/public_html/
30 5 * * * chown flesh_gogo:nobody /home/flesh_gogo/machtype.com/public_html -R

これでOK!!

上へ トップページへ


NTPサーバ編 -ntp-

関連サイト:http://www.ntp.org/
     :http://www.jst.mfeed.ad.jp/


すでにNTPサーバは入っているようなので、設定だけ

【/etc/ntp.conf】を作成

driftfile /var/log/ntp.drift

server time.machtype.com
server ntp.jst.mfeed.ad.jp

空のntp.driftファイルを作成

touch /var/log/ntp.drift

実行してみます。

ntpd

動くのですが、少しすると終了してしまいます。
やっぱり自分でインストールします。

###ソースをダウンロード###
wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2.0.tar.gz
###展開###
tar zxfv ntp-4.2.0.tar.gz
###移動###
cd ntp-4.2.0
###新しいバージョンを上書きして、起動しなくなるのを防ぐためになるべく「prefix」は変更する###
./configure --prefix=/usr/local/ntp-4.2.0

###コンパイル###
make

###インストール###
make install

実行してみます。

/usr/local/ntp-4.2.0/bin/ntpd -c /etc/ntp.conf


確認してみます。

ntpq -p

再起動後、再び同期されるまではBIOSの時間をセットしてしまいますので
1日1回BIOSの時間を再設定します。

crontab -e

0 4 * * * clock -w


毎朝4時にBIOS時間を再設定。

管理編 -OpenSSH-

まず、zlibをインストール

###ソースをダウンロード###
wget http://www.zlib.net/zlib-1.2.3.tar.gz

###展開###
tar zxfv zlib-1.2.3.tar.gz

###移動###
cd zlib-1.2.3.tar.gz

###コンパイル###
make

###インストール###
make install


OpenSSHをインストール

###ソースをダウンロード###
wget http://www.openssl.org/source/openssl-0.9.8a.tar.gz

###展開###
tar zxfv openssl-0.9.8a.tar.gz

###移動###
cd openssl-0.9.8a

###コンパイル###
make

making all in crypto/objects...
make[2]: Entering directory `/root/openssl-0.9.8a/crypto/objects'
/usr/local/bin/perl obj_dat.pl obj_mac.h obj_dat.h
make[2]: /usr/local/bin/perl: Command not found
make[2]: *** [obj_dat.h] Error 127
make[2]: Leaving directory `/root/openssl-0.9.8a/crypto/objects'
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory `/root/openssl-0.9.8a/crypto'
make: *** [build_crypto] Error 1


Perlが見つからないようです。

ebis[113]# whereis perl
perl: /usr/src/mkdist/perl /usr/src/usr.bin/perl /usr/bin/perl


シンボリックリンクを張ってみます。
ln -s /usr/bin/perl /usr/local/bin/perl

###再度コンパイル###
make
make test

###インストール###
make install


OpenSSHをインストール

###ソースをダウンロード###
wget http://openssh.hostingzero.com/portable/openssh-4.2p1.tar.gz

###展開###
tar zxfv openssh-4.2p1.tar.gz

###移動###
cd openssh-4.2p1

###ユーザ追加###
useradd sshd

###インストール設定###
./configure

###コンパイル###
make

###インストール###
make install

設定ファイルを変更
vi /usr/local/openssh-4.2p1/etc/sshd_config

#Port 22
Port 29xxxx  <−xは適当な数字に置き換えてください。

デフォルトでは、公開鍵方式以外に通常のパスワード方式も有効になっていますので、無効に
#PasswordAuthentication yes
PasswordAuthentication no

ルートによるログインを禁止します、ルートの認証がネットワーク上に流れるのを防ぎます。
#PermitRootLogin yes
PermitRootLogin no

起動時に設定ファイルを読むように、変更します。
vi /etc/rc.local

if [ -f /usr/local/sbin/sshd ]; then
  echo "starting sshd..."
  #/usr/local/sbin/sshd
  /usr/local/sbin/sshd -f /usr/local/etc/sshd_config
fi

さて使ってみましょう。
まず、キーを作成したいユーザにログインします。
su hoge
ホームディレクトリに移動
cd ~
キー作成
ssh-keygen -t rsa1

Generating public/private rsa1 key pair.
Enter file in which to save the key (/home/hoge/.ssh/identity):

どこに保存する?(/home/hoge/.ssh/identity←ここで良い?):
このままでいいので、Enter

Enter passphrase (empty for no passphrase):

パスフレーズを入力します。

Enter same passphrase again:

もう一度パスフレーズを入力します。

Your identification has been saved in /home/hoge/.ssh/identity.
Your public key has been saved in /home/hoge/.ssh/identity.pub.

できました。

サーバ側のキーを使えるように名前を変更します。
cp -p .ssh/identity.pub .ssh/authorized_keys

ユーザ側のキーidentityは持ち歩きます(なくさないでね^^;)。

上の方で有効にした、telnetを止めます。

vi /etc/inetd.conf

#telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd