Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

rsync の SRPM から、問題を修正した RPM を作ってみる(~/rpm/SOURCES 編)

/etc/rc.d/init.d/rsync になるスクリプトを書く。 cpufreqd の SRPM を真似て *1 、 rc.rsync という名前にする。
内容については、 /etc/rc.d/init.d/rskkserv *2 と、 Debian sarge の /etc/init.d/rsync を参考にする。というかパクる。なお、 /etc/xinetd.d/rsync になるファイル (~/rpm/SOURCES/rsync.xinetd) はほとんど参考にならない。
rc.rsync の内容は次のようにした。 chkconfig: の行は適当。 see chkconfig(8) for more information.

#!/bin/sh
# chkconfig: - 90 12
# description:  The rsync server is a good addition to am ftp server, as it \
#       allows crc checksumming etc.

# Source function library.
. /etc/init.d/functions

RSYNC=/usr/bin/rsync
RSYNC_OPTS=''
RSYNC_CONFIG_FILE=/etc/rsyncd.conf
RSYNC_PID_FILE=/var/run/rsyncd.pid

[ -x $RSYNC ]  || exit 0

case "$1" in
    start)
        echo -n "Starting rsync: "
        if [ ! -s "$RSYNC_CONFIG_FILE" ]; then
            echo "missing or empty config file $RSYNC_CONFIG_FILE"
            exit 1
        fi
        $RSYNC --no-detach --daemon --config "$RSYNC_CONFIG_FILE" $RSYNC_OPTS
        echo
        ;;
    stop)
        echo -n "Shutting down rsync: "
        kill -9 `cat $RSYNC_PID_FILE`
        rm -f $RSYNC_PID_FILE
        echo
        ;;
    reload)
        echo "Reloading rsync daemon: not needed, as the daemon"
        echo "re-reads the config file whenever a client connects."
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: rsync {start|stop|reload}"
        exit 1
esac

exit 0

rc.rsync は ~/rpm/SOURCES に置く。 ~/rpm/SOURCES/rsync.xinetd は要らないので削除する。 rc.rsync には実行属性を付けておこう。

$ chmod 755 rc.rsync


rsyncdaemon として動かすには、設定ファイル rsyncd.conf が必要なんだけど、 Vine Linux のシステム上にも tarball の中にも無いみたい。なので、 FreeBSD 4.10 から /usr/local/etc/rsyncd.conf.sample をパチってくる *3。 /usr/share/doc/rsync-2.6.3/ とかに配置することになるだろう。

$ scp username@host.powerd.by.freebsd:/usr/local/etc/rsyncd.conf.sample ~/rpm/SOURCES

*1:おまけ: apt-get -d source cpufreqd して、 SRPM ファイルを less で見ようとすると中のファイル名が見えるよ

*2:ファイルサイズが小さくて簡単そうなので選びました

*3:ライセンス的に OK なのか謎