Debian GNU/Linux Lenny覚え書き

インストール直後_

/etc/network/interfaceの編集_

DHCPを使う場合はそのまま。固定IPを使う場合は、/etc/network/interfaceを編集する。

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address x.x.x.x
        netmask x.x.x.x
        network x.x.x.x
        broadcast x.x.x.x
        gateway x.x.x.x
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers x.x.x.x
        dns-search domain.hoge.jp

/etc/apt/source.listの編集_

最寄りのdebianサーバーを選ぶこと。

deb http://ftp.jp.debian.org/debian/ testing main contrib non-free
deb http://ftp.jp.debian.org/debian/ testing-proposed-updates main contrib non-free

deb http://security.debian.org/ testing/updates main contrib non-free

# Uncomment if you want the apt-get source function to work
deb-src http://ftp.jp.debian.org/debian/ testing main contrib non-free

終了時にrsyncでバックアップ_

Debianのhalt時に自動でバックアップをとる方法

まず、rsyncをインストール

# aptitude install rsync

次に、まずバックアップする先を決める。 BUFFALO HD-W1.0T2/R1をUSB接続で外付けHDDとしてつけているのでそれにバックアップする。Gnomeを使っているからなのか、自動的に/media/usb1にマウントしてくれるので、そこにBackupHomeというディレクトリを作り保存することにする。

rsyncは前回と変更があったものだけを転送してくれるそうなので、/home/hogehoge以下のファイルをまずバックアップすることにする

# mkdir /media/usb1/BackupHome
# rsync -a /home/hogehoge/ /media/usb1/BackupHome/

次に/etc/init.d/に終了時にバックアップを行うスクリプト backup_home.sh を用意する。 /etc/init.d/halt を参考に以下のように作った。

#! /bin/sh

case "$1" in
  start)
        # No-op
        ;;
  restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
  stop)
        /usr/bin/rsync -a /home/hogehoge/ /media/usb1/BackupHome/
        ;;
  *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

実際にこれでrsyncが動くかを試す。

# /etc/init.d/backup_home.sh stop

終了時にこれを実行したいので、 /etc/rc0.d/ にシンボリックリンクを張る。

# ln -s /etc/init.d/backup_home.sh /etc/rc0.d/K17backup_home

これで、毎回 halt するたびにホームディレクトリのバックアップをとることができる。

Apache2 + SSL + WebDav_

httpsを起動_

まず、httpsを走らせるところまで。

# aptitude install apache2
# cd /etc/apache2/sites-available
# gunzip -c /usr/share/doc/apache2.2-common/examples/apache2/extra/httpd-ssl.conf.gz > httpd-ssl.conf
# cp -p httpd-ssl.conf ssl
# cp -p default default.org
# a2enmod ssl
# a2ensite ssl

次に証明書を作成以下のURLを参考に。

/etc/ssl/openssl.cnfの編集

# cd /etc/ssl
# cp -p openssl.cnf openssl.cnf.org
# vi openssl.cnf

以下のとおりに編集

# diff openssl.cnf.org openssl.cnf
172c172
< # nsCertType                  = server
---
>  nsCertType                   = server
241c241
< # nsCertType = sslCA, emailCA
---
>  nsCertType = sslCA, emailCA

続いて、自前証明書の作成。

# cd /usr/lib/ssl/misc/
# # ./CA.sh -newca

上記コマンドを実行して、どうやるかは以下のサイトを参照

次に証明書を所定の位置に設置。

# cd demoCA
# mkdir /etc/apache2/ssl
# cp ./cacert.crt /etc/apache2/ssl
# cd private/
# mkdir /etc/apache2/ssl/private
# cp ./cakey.pem /etc/apache2/ssl/private/
# cd /etc/apache2/sites-available

次にdefaultとsslを編集する。

% diff httpd-ssl.conf ssl
> NameVirtualHost *:443
77,79c77,79
< DocumentRoot "/usr/share/apache2/default-site/htdocs"
< ServerName www.example.com:443
< ServerAdmin you@example.com
---
> DocumentRoot "/var/www/"
> #ServerName localhost:443
> ServerAdmin gotoh@aise.ics.saitama-u.ac.jp
99c99
< SSLCertificateFile /etc/apache2/server.crt
---
> SSLCertificateFile /etc/apache2/ssl/cacert.crt
107c107
< SSLCertificateKeyFile /etc/apache2/server.key
---
> SSLCertificateKeyFile /etc/apache2/ssl/private/cakey.pem

ポイントはdefaultとsslのそれぞれにNameVirtualHost *:80とNameVirtualHost *:443を置くこと。

起動して確認する。

/etc/init.d/apache2 stop
/etc/init.d/apache2 start

webdavを設定_

# cd /etc/apache2/sites-available
# cp -p /usr/share/doc/apache2.2-common/examples/apache2/extra/httpd-dav.conf .
# cp -p httpd-dav.conf webdav
# mkdir /home/webdav
# chown -R www-data:www-data /home/webdav
# a2enmod dav
# a2enmod auth_digest
# a2ensite webdav

webdavの設定ファイルを以下のように編集

# diff httpd-dav.conf webdav
15c15
< DavLockDB "/var/DavLock"
---
> DavLockDB "/tmp/DavLock"
17c17
< Alias /uploads "/uploads"
---
> Alias /webdav "/home/webdav"
19c19
< <Directory "/uploads">
---
> <Directory "/home/webdav">
22,23c22,24
<     Order Allow,Deny
<     Allow from all
---
>     Order Deny,Allow
>     Deny from all
>     Allow from xxx.xxx.xxx.xxx localhost
26c27
<     AuthName DAV-upload
---
>     AuthName DAV
29c30
<     AuthUserFile "/user.passwd"
---
>     AuthUserFile "/etc/apache2/webdav.passwd"
33,34c34,35
<     <LimitExcept GET OPTIONS>
<         require user admin
---
>     <LimitExcept OPTIONS>
>         require valid-user

apacheを再起動する。

# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start

CUPS経由でBrother HL5270DNを使う_

お手頃価格のモノクロレーザープリンターHL-5270DNをネットワークプリンタとして、Debian GNU/Linux Lenny経由で使用する。

まずは、プリンタドライバをダウンロードする

上記のページからLPR用ドライバとCUP Wrapperをダウンロードする。その後、インストール。

% dpkg -i brhl5270dnlpr_2.0.0-2_i386.deb
% dpkg -i cupswrapperHL5270DN-2.0.1-1.i386.deb

このままだと、USB接続の設定になってしまう。そこで、設定を書き換える。2007年10月18日時点では、私の環境ではWeb経由(http://localhost:631/)やGNOMEの「システム」ー>「システム管理」ー>「Printing」経由だと設定途中でcupsdが落ちてしまうため、/etc/cups/printers.conf を直接編集した。

ちなみに2007年10月18日時点での環境は以下のとおり

pi:/media/disk# dpkg -l | grep cups
ii  cupswrapperhl5270dn                  2.0.1-2                          Brother HL5270DN CUPS wrapper driver
ii  cupsys                               1.2.12-1                         Common UNIX Printing System(tm) - server
ii  cupsys-bsd                           1.3.2-1                          Common UNIX Printing System(tm) - BSD comman
ii  cupsys-client                        1.3.2-1                          Common UNIX Printing System(tm) - client pro
ii  cupsys-common                        1.3.2-1                          Common UNIX Printing System(tm) - common fil
ii  cupsys-driver-gutenprint             5.0.1-3                          printer drivers for CUPS
ii  gnome-cups-manager                   0.31-3                           CUPS printer admin tool for GNOME
ii  libcupsimage2                        1.3.0-3                          Common UNIX Printing System(tm) - image libs
ii  libcupsys2                           1.3.0-3                          Common UNIX Printing System(tm) - libs
ii  libgnomecups1.0-1                    0.2.2-5                          GNOME library for CUPS interaction
ii  libgnomecupsui1.0-1c2a               0.31-3                           UI extensions to libgnomecups

プリンタが192.168.1.100にある場合、/etc/cups/printers.conf のDeviceURIという項目を以下のように書き換える。

DeviceURI lpd://192.168.1.100/Binary_P1

ポイントは、プロトコルは「LPD」、URIは「192.168.1.100」、そして、キューは「Binary_P1」ということ。このキューはWindowsでプリンターを設定した場合のキューを参考にした(参考ページによれば、Brother製品の多くのもので同じキューが使われているみたい)

その後、cupsdを再起動する。

# /etc/init.d/cupsys stop
# /etc/init.d/cupsys start

戻る_