On Thu, Feb 21, 2008 at 06:09:53PM -0500, Jameson Rollins wrote:
> On Thu, Feb 21, 2008 at 10:23:06PM +0000, Gerrit Pape wrote:
> > Currently update-service --add doesn't touch the ./supervise/
> > subdirectories if <service-dir>/supervise already exists and is a
> > symlink. So the cereal package could create symlinks pointing to
> > elsewhere in the filesystem before running update-service --add.
>
> Ah. I hadn't fully appreciated that. We can definitely do that with
> cereal for now. The thing that's a little funny, though, is that
After re-reading that part of the code, I noticed it does that for the
./supervise/ dir, but not ./log/supervise/, I'll fix that so that the
symlink in ./log/ can be created in advance too.
> cereal creates it's session service directories in /var already
> (/var/lib/cereal/sessions), so the links would just be from one
> location in /var to a different one. This seems slightly redundant to
> me, but obviously still doable. Maybe update-service could just check
> to see if the supervise directory ultimately resides in /var to
> determine whether or not to replace it, ie:
>
> readlink -f "$svdir"/supervise | grep -q '^/var'
Good idea. I even suggest that update-service checks whether the
service directory is in /etc/, and only then cares about the
./supervise/ symlinks. See the first attached patch.
> Another solution would be to have update-service read the permissions
> of the supervise directory that's there before it deletes it, and then
> create the new supervise directory itself in the appropriate place
> with the correct permissions, and then create the link in the service
> dir.
I don't think we should do that. It's not only the permissions of the
./supervise/ dirs, you can additionally configure permissions by
chmod'ing supervise/ok and supervise/control individually.
> > But maybe update-service should generally place the actual supervise
> > directories not into /var/run/, but /var/lib/runit/supervise/ maybe?
>
> After reading the Debian FHS for /var [0], I think that this is
> probably the right thing to do, and maybe actually a more appropriate
> place that /var/run. From the description of /var/lib:
>
> "This hierarchy holds state information pertaining to an application
> or the system"
>
> This is a pretty good description of what's actually in the runit
> supervise directories. Doing this doesn't solve all the issues in
> about supervise directory creation mentioned above, but it definitely
> gets around the issue of /var/run being purged on reboot.
Yes, there's a second patch attached, that does this.
Regards, Gerrit.
>From 58d6d3204bf0909b8a4e40ac617bf4996d804554 Mon Sep 17 00:00:00 2001
From: Gerrit Pape <[EMAIL PROTECTED]>
Subject: [PATCH] debian/update-service: symlink ./supervise dirs only if service-dir is in /etc/
When adding a service, only force the ./supervise/ subdirectories to
symlinks if the <service-dir> resides in /etc/. Additionally fix
update-service to not create the log/supervise/ symlink if it already
is a symlink, just as already done for ./supervise/.
---
debian/update-service | 16 +++++++++-------
debian/update-service.8 | 6 +++++-
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/debian/update-service b/debian/update-service
index 93f2b14..ddf1efa 100755
--- a/debian/update-service
+++ b/debian/update-service
@@ -53,13 +53,15 @@ case "$opt" in
fi
! sv stat "$svdir" >/dev/null 2>&1 ||
fatal "$svdir is currently controlled by a runsv(8) process."
- if test ! -h "$svdir"/supervise; then
- rm -rf "$svdir"/supervise
- ln -s /var/run/sv."$sv" "$svdir"/supervise
- fi
- if test -d "$svdir"/log; then
- rm -rf "$svdir"/log/supervise
- ln -s /var/run/sv."$sv".log "$svdir"/log/supervise
+ if test "${svdir#/etc/}" != "$svdir"; then
+ if test ! -h "$svdir"/supervise; then
+ rm -rf "$svdir"/supervise
+ ln -s /var/run/sv."$sv" "$svdir"/supervise
+ fi
+ if test -d "$svdir"/log && test ! -h "$svdir"/log/supervise; then
+ rm -rf "$svdir"/log/supervise
+ ln -s /var/run/sv."$sv".log "$svdir"/log/supervise
+ fi
fi
ln -s "$svdir" "$servicedir"/"$sv"
printf '%s\n' "Service $sv added."
diff --git a/debian/update-service.8 b/debian/update-service.8
index f459e93..ca5e085 100644
--- a/debian/update-service.8
+++ b/debian/update-service.8
@@ -27,12 +27,16 @@ lists all registered system-wide services, or checks for a specific
whether it is registered.
.P
When adding a service,
+and the
+.I service-directory
+resides in /etc/,
.B update-service
makes sure that the ./supervise/ subdirectories in the
.IR service-directory ,
and the optional
.IR service-directory /log/,
-are symbolic links pointing into /var/run/.
+are symbolic links pointing into /var/run/, unless they already are
+symbolic links.
.SH OPTIONS
.TP
.B \--add | \-a
--
1.5.4.2
>From 805fbc4809e77714c9cb00fb590934b774d7902b Mon Sep 17 00:00:00 2001
From: Gerrit Pape <[EMAIL PROTECTED]>
Subject: [PATCH] debian/update-service: point ./supervise/ symlinks into /var/lib/runit/supervise
Have the symbolic links for ./supervise/ directories point into
/var/lib/runit/supervise/ instead of /var/run/, so that the actual
directories are guaranteed to survive a reboot. Make sure the
/var/lib/runit/supervise/ directory is provided through debian/rules.
---
debian/rules | 1 +
debian/update-service | 4 ++--
debian/update-service.8 | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/debian/rules b/debian/rules
index 50f0706..ee613a1 100755
--- a/debian/rules
+++ b/debian/rules
@@ -46,6 +46,7 @@ clean: deb-checkdir deb-checkuid
install: deb-checkdir deb-checkuid build-stamp
rm -rf '$(DIR)'
install -d -m0755 '$(DIR)'/etc/service
+ install -d -m0755 '$(DIR)'/var/lib/runit/supervise
install -d -m0755 '$(DIR)'/sbin
install -d -m0755 '$(DIR)'/usr/bin
install -d -m0755 '$(DIR)'/usr/sbin
diff --git a/debian/update-service b/debian/update-service
index ddf1efa..c8d42dd 100755
--- a/debian/update-service
+++ b/debian/update-service
@@ -56,11 +56,11 @@ case "$opt" in
if test "${svdir#/etc/}" != "$svdir"; then
if test ! -h "$svdir"/supervise; then
rm -rf "$svdir"/supervise
- ln -s /var/run/sv."$sv" "$svdir"/supervise
+ ln -s /var/lib/runit/supervise/"$sv" "$svdir"/supervise
fi
if test -d "$svdir"/log && test ! -h "$svdir"/log/supervise; then
rm -rf "$svdir"/log/supervise
- ln -s /var/run/sv."$sv".log "$svdir"/log/supervise
+ ln -s /var/lib/runit/supervise/"$sv".log "$svdir"/log/supervise
fi
fi
ln -s "$svdir" "$servicedir"/"$sv"
diff --git a/debian/update-service.8 b/debian/update-service.8
index ca5e085..e329055 100644
--- a/debian/update-service.8
+++ b/debian/update-service.8
@@ -35,8 +35,8 @@ makes sure that the ./supervise/ subdirectories in the
.IR service-directory ,
and the optional
.IR service-directory /log/,
-are symbolic links pointing into /var/run/, unless they already are
-symbolic links.
+are symbolic links pointing into /var/lib/runit/supervise/, unless they
+already are symbolic links.
.SH OPTIONS
.TP
.B \--add | \-a
--
1.5.4.2