メールサーバの移行

イメージ
 自前のメールサーバを停止 これまで、自ドメインのメールサーバはVPS上に構築していた。 ・Ubuntu Server ・Postfix ・Dovecot ・spamAssassinと、BlackListの利用 Spam対策を行ってきたし、サーバ上でメールをトリガーにして各種プログラムを動かしたりしてきた。 メールサーバのメンテナンスは結構面倒くさくて、  ・Disk容量のチェック  ・不正アクセスのチェック  ・各種セキュリティパッチの適用 など、手間がかかる。 そこで、外部のサーバを利用することに…。 結構安くて使い勝手の良さそうなのが、「さくらのメールボックス」 3年契約で、3070円とな…。  メールアドレスは自分のだけなので、20GBまで利用可能!  (Gmailより大きいねぇ) ということで、早速契約。 アカウント設定を行って、既存のDNSを書き換える。WHOISも書き換えて完了。 SMTPとIMAPが利用できればOK。 ちょうど、GoogleがSPF設定していないと受信しないし、DKIMおよびDMARCに対応していないメールを弾くようになったので、対応しているのを確認。 さくらサーバ自体は、これまでお客さんのサーバとして何件も利用しているので、利用方法も難しくはない。  Webメールにも対応しているので、いざという場合にもありがたい。 ということで、各メールソフトの設定を変更。  PC(常時使用する3台)とタブレット、スマートフォンと台数は多いがそれ程手間はかからない。 問題は、旧サーバで送受信したメールの履歴だけれど、これはThunderbrdを使ってローカルに保存することで回避。  本当は、サーバtoサーバでMailboxに残そうとも考えたんだけど、古いメールはそれ程必要ないし、ローカルにバックアップしてあれば凌げるので、良しとする。 移行時にDNSの反映で若干時間がかかったものの、問題なく送受信できるのを確認して、作業完了。  これでメンテナンスの手間が減るので、安いもんです。

久しぶりで、使い方を忘れてた…(Perl)

Perlでプログラムをガシガシと

昨年納品したプログラムの、追加機能の要求が上がったので、見直しを行っていた。

今回は、DBを使うほど件数が増えそうにもない。
履歴を見て登録されているユーザか、そうでないかを判別するだけなので、ハッシュをファイルに紐付けて、簡易のDBとして使うことにする。

 昔なら、メモリがパンクするんじゃ?とかディスク遅いっすとか思ったりして躊躇するんだろうけど、今どきはドンドンメモリ使っちゃおう!ファイル使っちゃおう!なんて思ったりもする。

さて、前回利用したモジュールは
Jcode;
MIME::Parser;
MIME::WordDecoder;
File::Basename;
File::Path;
Fcntl;
File::Temp;
書き出してみるとこんなにもあった。

でもって、今回新たに Storable;

当然、稼働しているプログラムなので、直接いじるわけにはいかない。
とりあえず、ローカルでテストをする。

ソースを取り出して、修正内容を細かく分割。
それぞれテストして、組み立て…。

と、最初のテストで躓いた。

ローカルの環境が、この春に14.04で準備したNewマシンなので、モジュールが入っていない!

モジュールのインストール

そもそも、最初のuse Jcode;でエラー吐いているし…

ということで、インストールしようとしたが、コマンドを全く思い出せない。
あれれ? どうやら老化と共にやってくるアレか?
# perl -MCPAN -e shell
これが思い出せずに、仕方なくググりました。
いやぁ、外部記憶に入れておいて良かったゎ(泣) というか、内部記憶から消去されている模様。

忘れないように、自分を戒めるために記録しておく。

作業自体は、コマンド入力して完了するのに1分もかからないというのに、思い出そうとした時間の方が長いとは…。

root@X200:~# perl -MCPAN -e shell

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes] 

Autoconfigured everything but 'urllist'.

Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.

Would you like me to autoroot@X200:~# perl -MCPAN -e shell

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes] 

Autoconfigured everything but 'urllist'.

Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.

Would you like me to automatically choose some CPAN mirror
sites for you? (This means connecting to the Internet) [yes] 
Trying to fetch a mirror list from the Internet
Fetching with LWP:
http://www.perl.org/CPAN/MIRRORED.BY

Looking for CPAN mirrors near you (please be patient)
.......................... done!

New urllist
  http://cpan.develooper.com/
  http://mirrors.gossamer-threads.com/CPAN/
  http://mirror.team-cymru.org/CPAN/

Autoconfiguration complete.

commit: wrote '/home/satoshi/.cpan/CPAN/MyConfig.pm'

You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v2.00)
Enter 'h' for help.

cpan[1]> install Jcode
Fetching with LWP:
http://cpan.develooper.com/authors/01mailrc.txt.gz
Reading '/home/satoshi/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
http://cpan.develooper.com/modules/02packages.details.txt.gz
Reading '/home/satoshi/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Tue, 09 Sep 2014 13:53:17 GMT
..............
  New CPAN.pm version (v2.05) available.
  [Currently running version is v2.00]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.


..............................................................DONE
Fetching with LWP:
http://cpan.develooper.com/modules/03modlist.data.gz
Reading '/home/satoshi/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /home/satoshi/.cpan/Metadata
Running install for module 'Jcode'
Running make for D/DA/DANKOGAI/Jcode-2.07.tar.gz
Fetching with LWP:
http://cpan.develooper.com/authors/id/D/DA/DANKOGAI/Jcode-2.07.tar.gz
Fetching with LWP:
http://cpan.develooper.com/authors/id/D/DA/DANKOGAI/CHECKSUMS
Checksum for /home/satoshi/.cpan/sources/authors/id/D/DA/DANKOGAI/Jcode-2.07.tar.gz ok
Scanning cache /home/satoshi/.cpan/build for sizes
DONE

  CPAN.pm: Building D/DA/DANKOGAI/Jcode-2.07.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Jcode
Writing MYMETA.yml and MYMETA.json
cp Jcode/Nihongo.pod blib/lib/Jcode/Nihongo.pod
cp Jcode.pm blib/lib/Jcode.pm
Manifying blib/man3/Jcode::Nihongo.3pm
Manifying blib/man3/Jcode.3pm
  DANKOGAI/Jcode-2.07.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/append.t ... ok     
t/convert.t .. ok     
t/getcode.t .. ok   
t/h2z.t ...... ok   
t/jfold.t .... ok   
t/length.t ... ok   
t/mime.t ..... ok     
t/new.t ...... ok     
t/perl581.t .. ok   
t/regex.t .... ok   
t/tr.t ....... ok     
All tests successful.
Files=11, Tests=244,  1 wallclock secs ( 0.08 usr  0.01 sys +  1.20 cusr  0.02 csys =  1.31 CPU)
Result: PASS
  DANKOGAI/Jcode-2.07.tar.gz
  /usr/bin/make test -- OK
Running make install
Manifying blib/man3/Jcode::Nihongo.3pm
Installing /usr/local/share/perl/5.18.2/Jcode.pm
Installing /usr/local/share/perl/5.18.2/Jcode/Nihongo.pod
Installing /usr/local/man/man3/Jcode::Nihongo.3pm
Installing /usr/local/man/man3/Jcode.3pm
Appending installation info to /usr/local/lib/perl/5.18.2/perllocal.pod
  DANKOGAI/Jcode-2.07.tar.gz
  /usr/bin/make install  -- OK

cpan[2]> Terminal does not support GetHistory.
Lockfile removed.
matically choose some CPAN mirror
sites for you? (This means connecting to the Internet) [yes] 
Trying to fetch a mirror list from the Internet
Fetching with LWP:
http://www.perl.org/CPAN/MIRRORED.BY

Looking for CPAN mirrors near you (please be patient)
.......................... done!

New urllist
  http://cpan.develooper.com/
  http://mirrors.gossamer-threads.com/CPAN/
  http://mirror.team-cymru.org/CPAN/

Autoconfiguration complete.

commit: wrote '/home/satoshi/.cpan/CPAN/MyConfig.pm'

You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v2.00)
Enter 'h' for help.

cpan[1]> install Jcode
Fetching with LWP:
http://cpan.develooper.com/authors/01mailrc.txt.gz
Reading '/home/satoshi/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
http://cpan.develooper.com/modules/02packages.details.txt.gz
Reading '/home/satoshi/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Tue, 09 Sep 2014 13:53:17 GMT
..............
  New CPAN.pm version (v2.05) available.
  [Currently running version is v2.00]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.


..............................................................DONE
Fetching with LWP:
http://cpan.develooper.com/modules/03modlist.data.gz
Reading '/home/satoshi/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /home/satoshi/.cpan/Metadata
Running install for module 'Jcode'
Running make for D/DA/DANKOGAI/Jcode-2.07.tar.gz
Fetching with LWP:
http://cpan.develooper.com/authors/id/D/DA/DANKOGAI/Jcode-2.07.tar.gz
Fetching with LWP:
http://cpan.develooper.com/authors/id/D/DA/DANKOGAI/CHECKSUMS
Checksum for /home/satoshi/.cpan/sources/authors/id/D/DA/DANKOGAI/Jcode-2.07.tar.gz ok
Scanning cache /home/satoshi/.cpan/build for sizes
DONE

  CPAN.pm: Building D/DA/DANKOGAI/Jcode-2.07.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Jcode
Writing MYMETA.yml and MYMETA.json
cp Jcode/Nihongo.pod blib/lib/Jcode/Nihongo.pod
cp Jcode.pm blib/lib/Jcode.pm
Manifying blib/man3/Jcode::Nihongo.3pm
Manifying blib/man3/Jcode.3pm
  DANKOGAI/Jcode-2.07.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/append.t ... ok     
t/convert.t .. ok     
t/getcode.t .. ok   
t/h2z.t ...... ok   
t/jfold.t .... ok   
t/length.t ... ok   
t/mime.t ..... ok     
t/new.t ...... ok     
t/perl581.t .. ok   
t/regex.t .... ok   
t/tr.t ....... ok     
All tests successful.
Files=11, Tests=244,  1 wallclock secs ( 0.08 usr  0.01 sys +  1.20 cusr  0.02 csys =  1.31 CPU)
Result: PASS
  DANKOGAI/Jcode-2.07.tar.gz
  /usr/bin/make test -- OK
Running make install
Manifying blib/man3/Jcode::Nihongo.3pm
Installing /usr/local/share/perl/5.18.2/Jcode.pm
Installing /usr/local/share/perl/5.18.2/Jcode/Nihongo.pod
Installing /usr/local/man/man3/Jcode::Nihongo.3pm
Installing /usr/local/man/man3/Jcode.3pm
Appending installation info to /usr/local/lib/perl/5.18.2/perllocal.pod
  DANKOGAI/Jcode-2.07.tar.gz
  /usr/bin/make install  -- OK

cpan[2]> Terminal does not support GetHistory.
Lockfile removed.

はい! 無事作業が終わって、コードは動きましたとさ。

しかし、ちょっと前まで、使っていたはずなのになぁ。
ボケてきたんだろうか?

コメント

このブログの人気の投稿

WPS Officeで日本語入力ができない

VirtualBoxでUSBから起動

Virtualboxとnvidiaドライバ