Browse Source

runit: cleaned and fixed parse-config and djb-config (closes #11)

early
Alejandro Mery 16 years ago
parent
commit
2961846a41
  1. 6
      base/runit/djb-config
  2. 121
      base/runit/parse-config

6
base/runit/djb-config

@ -23,14 +23,12 @@ pkg_djb_hierarchy=$1
# #
# prepare root links for DJB filesystem hierarchy inside chrooted env. # prepare root links for DJB filesystem hierarchy inside chrooted env.
# #
if [ -n "$pkg_djb_servicedir" ]; then if [ "$SDECFG_PKG_DJB_LAYOUT" == "1" ]; then
:
elif [ "$SDECFG_PKG_DJB_LAYOUT" == "1" ]; then
for x in package command service; do for x in package command service; do
eval "pkg_djb_${x}dir='$root/$x'" eval "pkg_djb_${x}dir='$root/$x'"
var_append flistroot ' ' $x var_append flistroot ' ' $x
done done
elif [ "$SDECFG_PKG_DJB_LAYOUT" == "0" ]; then else
pkg_djb_packagedir= pkg_djb_packagedir=
pkg_djb_commanddir="$root${2:-$bindir}" pkg_djb_commanddir="$root${2:-$bindir}"
pkg_djb_servicedir="$root/var/service" pkg_djb_servicedir="$root/var/service"

121
base/runit/parse-config

@ -18,11 +18,11 @@
# #
# add init scripts # add init scripts
# #
if pkginstalled runit; then if [ "$SDECFG_INIT" == "runit" ]; then
# runit_substitute # runit_substitute
# #
runit_substitute() { runit_substitute() {
local logdir local logdir=
if [ "${localstatedir%$pkg}" != "$localstatedir" ]; then if [ "${localstatedir%$pkg}" != "$localstatedir" ]; then
logdir=$localstatedir/log logdir=$localstatedir/log
@ -33,59 +33,83 @@ if pkginstalled runit; then
sed -e "s,D_logdir,$logdir,g" $1 sed -e "s,D_logdir,$logdir,g" $1
} }
# runit_tail_prepare /foo/bar/$pkg-$service.tail # runit_tail_install $pkg-$service.tail
# #
runit_tail_prepare() { runit_tail_install() {
local tailfile=$1 pkg=$2 local tailfile=
local service=` echo $tailfile | sed -e "s,^.*/$pkg-,," -e "s,\.tail\$,," -e "s,_,/,g"` local service=
local servicedir= local servicedir=
if [ "${service#runit-}" != "$service" ]; then for tailfile; do
servicedir=\$root/etc/runit/${service#runit-} service=$(echo $tailfile | sed -e "s,^$pkg-,," -e "s,\.tail\$,," -e "s,_,/,g")
else
servicedir=\$root\$sysconfdir/$service
fi
echo_status "runit: Setting conf to install ${servicedir#\$root}/ (TAIL)" if [ "${service#runit-}" != "$service" ]; then
hook_add postdoc 5 "tail_install runit '$tailfile' '$servicedir'" servicedir="$root/etc/runit/${service#runit-}"
else
servicedir="$root$sysconfdir/$service"
fi
echo_status "runit: $tailfile -> ${servicedir#$root}"
tail_install runit "$(pkgdesc confdir runit)/packages/$tailfile" "$servicedir"
done
} }
runitconfdir=$base/package/*/runit runitconfdir=$(pkgdesc confdir runit)
runit_has_script=0 runit_has_script=0
for x in $( ls -1 $runitconfdir/packages/$pkg-*.tail 2> /dev/null ); do
runit_tail_prepare $x $pkg runit_files="$(cd "$runitconfdir/packages" && ls -1 $pkg-*.tail 2> /dev/null | tr '\n' ' ')"
if [ -n "$runit_files" ]; then
hook_add postdoc 5 "runit_tail_install $runit_files"
runit_has_script=1 runit_has_script=1
done fi
for x in $( cd $runitconfdir/packages; ls -1 $pkg-*.txt 2> /dev/null ); do
y=${x#$pkg-}; y=${y%.txt}; y=${y//_/\/} runit_files="$(cd "$runitconfdir/packages" && ls -1 $pkg-*.txt 2> /dev/null | tr '\n' ' ')"
if [ "${y#runit-}" != "$y" ]; then if [ -n "$runit_files" ]; then
y=\$root/etc/runit/${y#runit-} hook_add postmake 5 "runit_raw_install $runit_files"
else
y=\$root/\$sysconfdir/$y
fi
echo_status "runit: Setting conf to install $y"
runit_has_script=1 runit_has_script=1
case "${y##*/}" in fi
run|finish) runitxmode=1 ;;
*) runitxmode= ;; runit_raw_install() {
esac local x= y=
hook_add postmake 8 "mkdir -p ${y%/*}; \
${runitxmode:+chmod 755 ${y%/*};} \ for x; do
cat $runitconfdir/packages/$x | rock_substitute \ y=${x#$pkg-}; y=${y%.txt}; y=${y//_/\/}
| runit_substitute > $y; \
${runitxmode:+chmod 755 $y;}" if [ "${y#runit-}" != "$y" ]; then
done y="$root/etc/runit/${y#runit-}"
else
if [ "$SDECFG_INIT" == "runit" ]; then y="$root$sysconfdir/$y"
if [ "$SDECFG_PKG_DJB_LAYOUT" == "1" ]; then fi
for x in package command service; do
eval "pkg_djb_${x}dir='$root/$x'" echo_status "runit: $x -> ${y#$root}"
var_append flistroot ' ' $x
done mkdir -p "${y%/*}"
elif [ "$SDECFG_PKG_DJB_LAYOUT" == "0" ]; then cat "$(pkgdesc confdir runit)/packages/$x" | rock_substitute |
pkg_djb_packagedir= runit_substitute > "$y"
pkg_djb_commanddir="$root${2:-$bindir}"
pkg_djb_servicedir="$root/var/service" case "${y##*/}" in
run|finish) chmod 755 "$y" ;;
esac
done
}
if [ "$SDECFG_PKG_DJB_LAYOUT" == "1" ]; then
for x in package command service; do
var_append flistroot ' ' $x
done
fi
runit_layout() {
if [ -z "$pkg_djb_servicedir" ]; then
if [ "$SDECFG_PKG_DJB_LAYOUT" == "1" ]; then
for x in package command service; do
eval "pkg_djb_${x}dir='$root/$x'"
done
else
pkg_djb_packagedir=
pkg_djb_commanddir="$root$bindir"
pkg_djb_servicedir="$root/var/service"
fi
fi fi
# create them if it doesn't exist # create them if it doesn't exist
@ -97,6 +121,9 @@ if pkginstalled runit; then
[ "$x" = command ] || chmod 1755 "$y" [ "$x" = command ] || chmod 1755 "$y"
fi fi
done done
}
hook_add preconf 5 'runit_layout'
if [ $runit_has_script -eq 1 ]; then if [ $runit_has_script -eq 1 ]; then
install_init() { install_init() {
@ -131,9 +158,7 @@ if pkginstalled runit; then
hook_add postmake 9 'ln -svnf /etc/runit/klogd $pkg_djb_servicedir/klogd' hook_add postmake 9 'ln -svnf /etc/runit/klogd $pkg_djb_servicedir/klogd'
;; ;;
esac esac
fi
unset runitconfdir runitxmode runit_has_script unset runitconfdir runitxmode runit_has_script
fi fi

Loading…
Cancel
Save