インストールスクリプト

読んでみる事に。
対象は bind9 のナニ。apt-get -d でオトした deb ファイルを ar でバラして control.tar.gz を解凍。postinst の中身をチェキ。

#!/bin/sh

set -e
  • /bin/sh はでびあんなら dash な模様?
  • set -e って bash の man によれば_単純なコマンドが 0 じゃない戻りで終わったら即座に終了_との事。これはなかなかにいさぎ良い

次、おおまかなブロックでナニすると以下

if [ "$1" = configure ]; then

# 今はここは略

fi


# Automatically added by dh_installinit
if [ -x "/etc/init.d/bind9" ]; then
        update-rc.d bind9 defaults 15 85 >/dev/null
        if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
                invoke-rc.d bind9 start || exit $?
        else
                /etc/init.d/bind9 start || exit $?
        fi
fi
# End automatically added section

ケツのソレは dh_installinit で自動追加とコメントにもあります。以降で略した部分についてチェキ。

    lastversion="$2";

    # lets give them a bind user/group in all cases.
    getent group bind >/dev/null 2>&1 || addgroup --system bind
    getent passwd bind >/dev/null 2>&1 ||
        adduser --system --home /var/cache/bind --no-create-home \
                --disabled-password --ingroup bind bind

最初の代入文的に気になるのは $2 を代入しているトコでしょうか。入門でびあんパケジ本によれば

<postinst> configure <古いバージョン>

との事にて確かにその通りですな。次は getent というナニ。とりあえず man 以外に適当な材料が探せないのでアレですが

    getent group bind >/dev/null 2>&1 || addgroup --system bind

だと /etc/group に bind というグループが無ければ addgroup する、という意味か。次の adduser も色々微妙なオプションが付いてます。
とりあえず、ここまでのポイントとしては

  • postinst configure の場合は第二引数で指定されるバージョンは取っておく
  • group と user の登録 (未登録の場合のみ)

以降

なんか黒魔術っぽいナニが続く。/etc/default/ 配下のナニはでびあん的、なの??
因みに、と言いつつ色々確認していると
/etc/default/nfs-common で以下になってて

# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".

# Options for rpc.statd.
#   Should rpc.statd listen on a specific port? This is especially useful
#   when you have a port-based firewall. To use a fixed port, set this
#   this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
#   For more information, see rpc.statd(8) or http://wiki.debian.org/?SecuringNFS
STATDOPTS=

# Some kernels need a separate lockd daemon; most don't. Set this if you
# want to force an explicit choice for some reason.
NEED_LOCKD=

# Do you want to start the idmapd daemon? It is only needed for NFSv4.
NEED_IDMAPD=

# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD=

/etc/init.d/nfs-common で以下な記述あり

# Read config
DEFAULTFILE=/etc/default/nfs-common
PREFIX=
NEED_LOCKD=
NEED_IDMAPD=
NEED_GSSD=
PIPEFS_MOUNTPOINT=/var/lib/nfs/rpc_pipefs
RPCGSSDOPTS=
if [ -f $DEFAULTFILE ]; then
    . $DEFAULTFILE
fi

これはこれは。今の環境では bind9 は導入されてないので unstable なソレで入れてみる。インストールのケツのあたりで以下の出力を確認。

Setting up bind9 (1:9.5.0.dfsg.P2-4) ...
Adding group `bind' (GID 105) ...
Done.
Adding system user `bind' (UID 105) ...
Adding new user `bind' (UID 105) with group `bind' ...
Not creating home directory `/var/cache/bind'.
wrote key file "/etc/bind/rndc.key"
#
Starting domain name service...: bind9.

bind9 なサービスも起動しているみたい。/etc/default/bind9 は以下な模様

# cat /etc/default/bind9 
# run resolvconf?
RESOLVCONF=yes

# startup options for the server
OPTIONS="-u bind"
#

これはこれは。
# ってか、微妙に違うな。当たり前か。なんかバージョンがとっちらかってます。

これをどうやって unbound にナニするのかは微妙だな。
あと、bind はサービス起動してますが、その根拠が微妙。