[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
rc.d script
BOFで仕入れた知識を使って、
ちょっとpkg系のrc.d scriptを書いてみました。
sshdとcannaです。こういう方式にすれば、
1.4でも動かなきゃいけないpkgsrcを -currentと共有できそうです。
# mntbuildはlfsの安定度に感動して作ったもの :)
/etc/rc で /etc/rc.local.d を見るように、
files=`rcorder /etc/rc.d/* /etc/rc.local.d/*`
ってしてます。
sakamoto
--
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# rc.local.d
# rc.local.d/mntbuild
# rc.local.d/sshd
# rc.local.d/canna
#
echo c - rc.local.d
mkdir -p rc.local.d > /dev/null 2>&1
echo x - rc.local.d/mntbuild
sed 's/^X//' >rc.local.d/mntbuild << 'END-of-rc.local.d/mntbuild'
X#!/bin/sh
X#
X
X# PROVIDE: mntbuild
X# REQUIRE: local
X
X. /etc/rc.subr
X
Xname="mntbuild"
Xstart_cmd="start_mntbuild"
Xstop_cmd="stop_mntbuild"
X
Xstart_mntbuild()
X{
X if [ -f /a/img ]; then
X vnconfig vnd0 /a/img
X mount_lfs /dev/vnd0a /build
X mount_union -b /a/cvs/pkgsrc /build/pkgsrc
X fi
X}
X
Xstop_mntbuild()
X{
X if [ -f /a/img ]; then
X umount -a -t union
X umount /build
X vnconfig -u vnd0
X fi
X}
X
Xload_rc_config $name
Xrun_rc_command "$1"
END-of-rc.local.d/mntbuild
echo x - rc.local.d/sshd
sed 's/^X//' >rc.local.d/sshd << 'END-of-rc.local.d/sshd'
X#!/bin/sh
X#
X
X# PROVIDE: sshd
X# REQUIRE: local
X
X. /etc/rc.subr
X
Xname="sshd"
Xstart_cmd="/usr/pkg/etc/rc.d/${name}.sh"
Xcommand="/usr/pkg/sbin/${name}"
Xpidfile="/var/run/${name}.pid"
X
Xload_rc_config $name
Xrun_rc_command "$1"
END-of-rc.local.d/sshd
echo x - rc.local.d/canna
sed 's/^X//' >rc.local.d/canna << 'END-of-rc.local.d/canna'
X#!/bin/sh
X#
X
X# PROVIDE: canna
X# REQUIRE: local
X
X. /etc/rc.subr
X
Xname="canna"
Xstart_cmd="/usr/pkg/etc/rc.d/${name}.sh"
Xcommand="/usr/pkg/sbin/cannaserver"
Xstop_cmd="/usr/pkg/bin/cannakill"
X
Xload_rc_config $name
Xrun_rc_command "$1"
END-of-rc.local.d/canna
exit