Ubuntu 7.04 に Plagger、Ruby on Rails 等をインストールしました。
まっさらなUbuntu 7.04にPlagger、Ruby on Rails、Vim、SVKなどの愛用ツールを一通りインストールしましたので手順を残しておきます。
なお、Ubuntu 6.10 Edgy インストール Thinkpad X60 - ひげぽん OSとか作っちゃうかMona-と、
ubuntu server に Plaggerを入れてみるメモを参考にさせていただきました。ありがとうございました。
ホームに setup_ubuntu ディレクトリを作成し、シェルスクリプトを用意して一気に作業します。
initial_setup.sh
#!/bin/sh cd mkdir .vim mkdir tmp mkdir bin cd ~/setup_ubuntu chmod 700 *.sh # CPUとメモリは正しく認識されている? cat /proc/meminfo cat /proc/cpuinfo # 不要サービスの停止 sudo update-rc.d -f cupsys remove sudo update-rc.d -f hplip remove sudo apt-get remove apt-index-watcher # あらかじめ用意しておいたソースリストで上書き sudo cp sources-feisty.list /etc/apt/sources.list sudo apt-get update # sshとかコンパイラとかシェルとかキーバインドとか sudo aptitude install openssh-server ssh sudo aptitude install gcc g++ g77 sudo aptitude install tar zip gzip unzip bzip2 sudo aptitude install build-essential sudo aptitude install zsh sudo aptitude install screen cp .zshrc .. cp .screenrc .. cp .xmodmaprc .. # 右クリックでターミナルを開く sudo aptitude install nautilus-open-terminal # ライブラリ等 sudo aptitude install ntp sudo aptitude install uim uim-anthy uim-el sudo aptitude install migemo sudo aptitude install gnuserv sudo aptitude install xfonts-mplus sudo aptitude install xfonts-shinonome sudo aptitude install mingw32 mingw32-binutils mingw32-runtime sudo aptitude install libxml2 libxml2-dev sudo aptitude install expat libexpat-dev sudo aptitude install libssl-dev libio-socket-ssl-perl libnet-ssleay-perl sudo aptitude install libcompress-zlib-perl libhtml-parser-perl \ libmime-perl libtemplate-perl libwww-perl libxml-libxml-perl \ libxml-libxml-common-perl libxml-parser-perl libyaml-perl \ libdate-manip-perl libnet-perl libtemplate-perl-doc sudo aptitude install ncftp sudo aptitude install lynx sudo aptitude install nasm sudo aptitude install gauche sudo aptitude install qemu sudo aptitude install apt-file sudo aptitude install apt-spy sudo aptitude install keychain sudo aptitude install locales # SubversionとSVK sudo aptitude install subversion sudo aptitude install svk # Adobe Flash Player sudo aptitude install swf-player # メールクライアント sudo aptitude install mozilla-thunderbird # Samba sudo aptitude install samba smbfs smbclient swat sudo cp smb.conf /etc/samba/smb.conf # マニュアルページ sudo aptitude install manpages-ja sudo aptitude install manpages-ja-dev sudo aptitude install xmanpages-ja # データベース sudo aptitude install sqlite sqlite3 sudo aptitude install postgresql-8.2 sudo aptitude install mysql-server mysql-client # MySQLの文字コードをUTF-8に設定 cd ~/setup_ubuntu ./mysql-utf8_initialize.sh # 最新のRuby cd ~/setup_ubuntu ./install_ruby.sh # RubyGems cd ~/setup_ubuntu ./install_rubygems.sh sudo aptitude install libopenssl-ruby # テキストエディタ sudo aptitude install emacs sudo aptitude install vim-gnome vim-gui-common vim-runtime colordiff cp .emacs .. cp .gvimrc .. # コンソール版のVimを最新に cd ~/setup_ubuntu ./install_ncurses55.sh ./install_vim71.sh cp .vimrc .. # Samba sudo aptitude install samba smbfs smbclient swat sudo cp smb.conf /etc/samba/smb.conf # Apache sudo aptitude install apache2 sudo aptitude install apache2-mpm-prefork sudo aptitude install apache-perl # TurboGearsとDjango cd ~/setup_ubuntu ./install_turbogears.sh sudo aptitude install python-django # Java sudo aptitude install java sudo aptitude install eclipse # PHP sudo aptitude install php sudo aptitude install php-sqlite3 # 2ch Browserなど sudo aptitude install ochusha sudo aptitude install comix # P2P sudo aptitude install skype # Wireshark sudo aptitude install wireshark # アンチウイルスとファイアウォール sudo aptitude install firestarter sudo aptitude install clamav avscan
他にもおすすめのパッケージがありましたらぜひ教えてください。
この記事を参考にする場合はあらかじめ設定ファイルを用意するのを忘れないように気をつけてください。また細かい点は自分好みにカスタマイズしてください。
ここからrootで作業。Ruby on RailsとPlaggerをインストールします。
事前にCPANの設定でPolicy on building prerequisitesをfollowにしておきます。
sudo su - passwd cd /home/ubuntu/setup_ubuntu ./install_gem_batch.sh ./install_plagger.sh exit
シェルスクリプトの内容。
install_gem_batch.sh
#!/bin/sh export RUBYOPT=rubygems gem install rails --include-dependencies -y gem install mongrel --include-dependencies -y gem install mongrel_cluster --include-dependencies -y gem install mechanize --include-dependencies -y gem install Selenium --include-dependencies -y gem install vim-ruby --include-dependencies -y gem install postgres-pr --include-dependencies -y gem install BlueCloth --include-dependencies -y gem install RedCloth --include-dependencies -y gem install net-ssh --include-dependencies -y gem install net-sftp --include-dependencies -y gem install coverage --include-dependencies -y gem install zentest --include-dependencies -y gem install capistrano --include-dependencies -y gem install magic_multi_connections --include-dependencies -y gem install redgreen --include-dependencies -y
install_plagger.sh
#!/bin/sh cpan install Bundle::Cpan cpan install App::Ack cpan install YAML cpan install Error cpan install DateTime-Format-Strptime cpan install Crypt-SSLeay cpan install IO-Socket-SSL cpan install Net-SMTP-TLS cpan install Template-Toolkit cpan install Template-Provider-Encoding cpan install Class-Accessor cpan install MIME-Types cpan install UNIVERSAL-require cpan install XML-Path cpan install XML-Atom cpan install XML-RSS cpan install XML-RSS-Libxml cpan install XML-Feed cpan install File-Find-Rule cpan install WebService::Bloglines cpan force install Plagger cp -a ~/.cpan/build/Plagger-0.7.17/assets /usr/local/share/perl/5.8.8/Plagger/
これでとりあえず一通りの環境が用意できました。
追記
8/3 一部のパッケージを追加・修正しました。シェルスクリプト等を一部省略しました。
必要最低限のカスタマイズでキーボードを使う
会社に所属してエンジニアをやっていると、たとえば顧客の環境など、どうしてもキーボードのカスタマイズができない場面に遭遇します。
しかしキーボードをNo Hackで使用するのは効率が悪いですし、特にCtrlキーは左手小指ですぐに押せる位置に無いとzshもEmacsもVimも使っていられないですよね。
そんなわけで、最小の変更で必須のキーボードカスタマイズをおこなうにはどうしたらいいか、を追求した末、自分なりにたどりついたキーバインドを公開します。
1. Windows Server 2003 Resource Kit Toolsをインストールする
Linuxを使えるならxmodmapで済むのですが、悲しいことに仕事場ではWindowsを使わざるを得ない。そんな場合は窓使いの憂鬱でも良いですが、Windows Server 2003 Resource Kit Toolsをインストールするのが手っ取り早いです。
自由にソフトウェアをインストールできないような環境でも、運用管理のためにMicrosoftのオフィシャルなツールを導入するなどとそれらしい適当な理由で申請すれば、インストールが許可されそうですね。
このツールをインストールするとremapkeyというコマンドが付いてきます。これでキーボードのカスタマイズができます。
2. 7ヶ所の必須キーを入れ替える
これが自分なりに絞り込んだ最低限のカスタマイズです。
CtrlキーはCapsLockと入れ替えてAの横に。
IMEの切り替えは、PC-9800のXFERを意識した位置に。
Ctrl、Tab、ESCキーはいずれも非常に使用頻度が高いキーなので、それぞれ遠くない位置に。
この程度のカスタマイズなら、万一デフォルトのキーボードで操作しなければならない場面でも、さほど苦にならずに打つことができます。
理想と現実の折り合いをつけるとこの程度、というところでしょうか。
Plaggerなどのスクレイピングツールで、ブログやニュースを取得することのメリットとデメリットを考える
メリット
- 本文すべて取得しGmailに送信することで、あとから全文検索ができる。
- ローカルのメーラーで読むのは、環境次第ではとても速い。
- MySQLなどのDBに放り込んで、自分でつくったソフトで読むのもいいね。というかそれもやっている。
- ある時間軸にそってフィードを読むことができる。
- たとえば「今日の15時の時点」でのフィードを読む、といったふうに。
- 時間軸ごとの優先付けが出来る。
- たとえば「今日の10時以前の分は後回しにしてそれ以降のフィードから先に読む」など。
- ブログやニュースの元の記事が消えても、手元に記事が残る。
- アーカイブして永久保管。記憶の補助、ナレッジベース、思い出作り、証拠作りといった目的に使える。
- すでに消えたはずの記事の内容も全文検索の対象になる。
- ソーシャルブックマークやWeb魚拓が消えても手元には記事が残る。
Vimでバイナリエディット
xxd.exeを用意します。
次にvimrcに以下のように定義します。
" vim -b : edit binary using xxd-format! augroup Binary au! au BufReadPre *.bin let &bin=1 au BufReadPost *.bin if &bin | silent %!xxd -g 1 au BufReadPost *.bin set ft=xxd | endif au BufWritePre *.bin if &bin | %!xxd -r au BufWritePre *.bin endif au BufWritePost *.bin if &bin | silent %!xxd -g 1 au BufWritePost *.bin set nomod | endif augroup END
こうすると拡張子.binのファイルを開くときと保存するときにxxdで自動変換されます。
Vim使いであれば、いつもの操作感でバイナリエディットができるので便利です。
WWW-Mixi-0.49にパッチを適用しmixiの足あとを取得する
Plaggerで定期巡回しているmixiですが、足あとがいつの間にか取得できなくなっていました。
最新のWWW-Mixi-0.49に以下の通りパッチを適用すると、今まで通り足あとを取得できます。
1365c1365 < my $content_from = qq(\Q<ul class="log new_log" style="margin: 0; padding: 0;">\E); --- > my $content_from = qq(\Q<ul class="log new_log" style="margin:0px;padding:0px;\E);
調べてみると、mixiのコミュニティに書き込みがあったのですが、こちらにも転載します。
TurboGears 1.0.2.2のセットアップをする
Python 2.5.1に正式に対応していますが、Python 2.4.4を推奨するメッセージが表示されます。
TurboGears Installer The recommended Python for TurboGears is Python 2.4.4. You can download it here: http://www.python.org/ftp/python/2.4.4/python-2.4.4.msi Would you like to continue with a Python 2.5 install?yes/no[y] (y|n, default y)y Beginning setuptools/EasyInstall installation and TurboGears download Downloading http://cheeseshop.python.org/packages/2.5/s/setuptools/setuptools-0. 6c5-py2.5.egg Processing setuptools-0.6c5-py2.5.egg Copying setuptools-0.6c5-py2.5.egg to c:\python25\lib\site-packages Adding setuptools 0.6c5 to easy-install.pth file Installing easy_install-script.py script to C:\Python25\Scripts Installing easy_install.exe script to C:\Python25\Scripts Installing easy_install-2.5-script.py script to C:\Python25\Scripts Installing easy_install-2.5.exe script to C:\Python25\Scripts Installed c:\python25\lib\site-packages\setuptools-0.6c5-py2.5.egg Processing dependencies for setuptools==0.6c5 Searching for TurboGears[standard]>=1.0.2.2 Reading http://www.turbogears.org/download/ Reading http://cheeseshop.python.org/pypi/TurboGears/ Reading http://www.turbogears.org Reading http://www.turbogears.org/download/filelist.html Reading http://cheeseshop.python.org/pypi/TurboGears/1.0.2.2 Reading http://cheeseshop.python.org/pypi/TurboGears/"<a Best match: TurboGears 1.0.2.2 Downloading http://files.turbogears.org/eggs/TurboGears-1.0.2.2-py2.5.egg Processing TurboGears-1.0.2.2-py2.5.egg creating c:\python25\lib\site-packages\TurboGears-1.0.2.2-py2.5.egg Extracting TurboGears-1.0.2.2-py2.5.egg to c:\python25\lib\site-packages Adding TurboGears 1.0.2.2 to easy-install.pth file Installing tg-admin-script.py script to C:\Python25\Scripts Installing tg-admin.exe script to C:\Python25\Scripts Installed c:\python25\lib\site-packages\turbogears-1.0.2.2-py2.5.egg Reading http://files.turbogears.org/eggs/ Processing dependencies for TurboGears[standard]>=1.0.2.2 〜略〜
TurboGearsをインストールするとEasyInstallも自動的に導入されるので便利です。
あわせて必要なモジュールをどんどんインストールすると良いでしょう。
例として、Mechanizeをインストールしてみます。
# easy_install mechanize Searching for mechanize Reading http://cheeseshop.python.org/pypi/mechanize/ Reading http://wwwsearch.sourceforge.net/mechanize/ Reading http://cheeseshop.python.org/pypi/mechanize/0.1.6b Best match: mechanize 0.1.6b Downloading http://wwwsearch.sourceforge.net/mechanize/src/mechanize-0.1.6b.zip Processing mechanize-0.1.6b.zip Running mechanize-0.1.6b\setup.py -q bdist_egg --dist-dir c:\docume~1\superv~1\l ocals~1\temp\easy_install-xreuzy\mechanize-0.1.6b\egg-dist-tmp-9x7tze warning: no files found matching '0.1.0-changes.txt' no previously-included directories found matching 'docs-in-progress' Adding mechanize 0.1.6b to easy-install.pth file Installed c:\python25\lib\site-packages\mechanize-0.1.6b-py2.5.egg Processing dependencies for mechanize Searching for ClientForm==dev,>=0.2.6 〜略〜
インストール後はバージョンの確認をします。
class PythonModuleVersion: def python_version(self): try: import sys return 'Python', sys.version_info except ImportError: return 'Python ImportError' def turbogears_version(self): try: import turbogears return 'TurboGears', turbogears.__version__ except ImportError: return 'TurboGears ImportError' def mechanize_version(self): try: import mechanize return 'mechanize', mechanize.__version__ except ImportError: return 'mechanize ImportError'
実行結果は以下の通り。
('Python', (2, 5, 1, 'final', 0)) ('TurboGears', '1.0.2.2') ('mechanize', (0, 1, 6, 'b', None))
これに加えて、MySQLdbなどDBとのアダプタもインストールすれば、アプリケーション開発に取り掛かることができます。