Debian Wheezy で GitHub が提供しているボット Hubot を動作させる方法をまとめます.
出来る限り, Debian 標準のパッケージを使って環境を整備します.
Node.js のインストール
Node.js のパッケージは Wheezy 標準ではインストールすることが出来ないため, Debian が公式に提供している Backports からインストールします.
/etc/apt/sources.list に以下を追加します.
deb http://ftp.jp.debian.org/debian/ wheezy-backports main
apt を更新して, wheezy-backports から Node.js をインストールします.
sudo aptitude update sudo aptitude upgrade sudo aptitude -t wheezy-backports install nodejs
nodejs が動作することを確認します.
$ nodejs
> console.log("Hello")
Hello
undefined
node という名前でも nodejs を起動出来るように, シンボリックリンクを作成しておきます.
cd /usr/bin sudo ln -s nodejs node
npm のインストール
npm は wheezy-backports でも提供されていないので, 直接インストールします. 以下を実行してインストールします.
–no-check-certificate は証明書関係のエラーが出たため付加しています.
wget http://www.npmjs.org/install.sh --no-check-certificate sudo sh install.sh
npm がインストールされたことを確認します.
$ npm
Usage: npm <command>
where <command> is one of:
add-user, adduser, apihelp, author, bin, bugs, c, cache,
completion, config, ddp, dedupe, deprecate, docs, edit,
explore, faq, find, find-dupes, get, help, help-search,
home, i, info, init, install, isntall, issues, la, link,
list, ll, ln, login, ls, outdated, owner, pack, prefix,
prune, publish, r, rb, rebuild, remove, repo, restart, rm,
root, run-script, s, se, search, set, show, shrinkwrap,
star, stars, start, stop, submodule, t, tag, test, tst, un,
uninstall, unlink, unpublish, unstar, up, update, v,
version, view, whoami
Redis のインストール
Hubot のデータを永続化したい場合は, Redis が必要になります.
sudo aptitude install redis-server
Hubot のインストール
npm を使って, Hubot をインストールします.
sudo npm install -g hubot coffee-script
Hubot の作成
Hubot を作成して, コマンドラインから動作することを確認します.
詳細は Hubot のドキュメントを参照してください.
$ hubot --create myhubot
$ cd myhubot
$ bin/hubot
Hubot> hubot help
Hubot> Events:
debug - {user: <user object to send message to>}
Hubot <user> doesn't have <role> role - Removes a role from a user
Hubot <user> has <role> role - Assigns a role to a user
Hubot <user> is a badass guitarist - assign a role to a user
Hubot <user> is not a badass guitarist - remove a role from a user