>>        if test ! -h "$svdir"/supervise; then
>>          rm -rf "$svdir"/supervise
>> -        ln -s /var/lib/runit/supervise/"$sv" "$svdir"/supervise
>> +        ln -s /run/runit/supervise/"$sv" "$svdir"/supervise
>
>Will it handle both /var/lib and /run/runit location?

Mmm.. No
In my system i have a mix of
* supervise inside /etc/sv/foo that is not a symlink ( due to my own
experiment i believe)
* supervise that is a symlink to /var/lib/runit/supervise/foo (current
dh-runit)
* supervise that is a symlink to /var/lib/supervise/foo (update-service
before dh-runit)
if you prefer i can force a replace of /var/ with /run each time one types
'update-service --add  /etc/sv/foo'
new patch attached should handle all of the above cases, except
it won't replace a supervise dir of an already running service (of course)

About this, I forsee trouble during an upgrade of a package that already
ship a runscript, think of the following

1 acpid is running (with runit) and supervise links to /var/lib/
2 upgrade of acpid, with new dh (supervise links to /run/)
3 unpack will replace supervise symlink of a running service-- > what
happens?
4 then postinstall try to send signals to acpid..

I can test the opposite (switch from /run into /var) and it doesn't
end up good

# sv status acpid
run: acpid: (pid 5576) 17s; run: log: (pid 5575) 17s

# readlink /etc/sv/acpid/supervise
/run/runit/supervise/acpid

# apt-get install --reinstall acpid
Reading package lists... Done
Building dependency tree
Reading state information... Done
[...]
Preparing to unpack .../acpid_1%3a2.0.32-1_amd64.deb ...
Unpacking acpid (1:2.0.32-1) over (1:2.0.32-1) ...
Setting up acpid (1:2.0.32-1) ...
insserv: Script rsync has overlapping Default-Start and Default-Stop
runlevels (2 3 4 5) and (2 3 4 5). This should be fixed.
insserv: Script lvm2 has overlapping Default-Start and Default-Stop
runlevels (S) and (S). This should be fixed.
Stopping ACPI services: acpid.
Starting ACPI services: acpid.
Processing triggers for man-db (2.8.6.1-1) ...

Looks all good but then

# sv status acpid
fail: acpid: runsv not running

# ps aux | grep acpid
root      1473  0.0  0.0   2312  1284 ?        Ss   11:37   0:00 runsvdir
-P /etc/service log: t runsv acpid: warning: unable to open
supervise/pid.new: file does not exist runsv acpid: warning: unable to open
supervise/pid.new: file does not exist runsv acpid: warning: unable to open
supervise/pid.new: file does not exist runsv acpid: warning: unable to open
log/supervise/pid.new: file does not exist runsv acpid: warning: unable to
open log/supervise/pid.new: file does not exist .....
root      5574  0.0  0.0   2160   736 ?        Ss   16:25   0:00 runsv acpid
runit-l+  5575  0.0  0.0   2304   680 ?        S    16:25   0:00 svlogd -tt
/var/log/runit/acpid
root     13527  0.0  0.0   2452  1792 ?        S    16:26   0:00
/usr/sbin/acpid -f
root     28142  0.0  0.0   6524   880 pts/0    S+   16:29   0:00 grep acpid

Looks an acpid process managed by runsv survives but i can't send signal to
it!

Maybe let runit-helper create the symlinks rather than
shipping in the package itself is a more flexible approach?
Anything else I'm missing ?

Lorenzo
From 1abd914b1a171ea89899699bbec3e2a901e61bac Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti <lorenzo.r...@gmail.com>
Date: Mon, 19 Aug 2019 14:58:38 +0200
Subject: [PATCH] update-service: move supervise directories in tmpfs

Create log and service's supervise directories under /run/
tmpfs (they were in /var/ previously).
Also try to replace old supervise directories pointing to /var
with new one pointing to /run, when possible.
---
 debian/contrib/update-service | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/debian/contrib/update-service b/debian/contrib/update-service
index 7e72501..bb83f2b 100644
--- a/debian/contrib/update-service
+++ b/debian/contrib/update-service
@@ -63,11 +63,24 @@ case "$opt" in
     if test "${svdir#/etc/}" != "$svdir"; then
       if test ! -h "$svdir"/supervise; then
         rm -rf "$svdir"/supervise
-        ln -s /var/lib/runit/supervise/"$sv" "$svdir"/supervise
+        ln -s /run/runit/supervise/"$sv" "$svdir"/supervise
+      else
+        #934500 force the switch of supervise into /run, keep untill bullseye +1
+        if [ $(readlink "$svdir"/supervise) != /run/runit/supervise/"$sv" ]; then
+            rm -rf "$svdir"/supervise
+            ln -s /run/runit/supervise/"$sv" "$svdir"/supervise
+        fi
       fi
       if test -d "$svdir"/log && test ! -h "$svdir"/log/supervise; then
         rm -rf "$svdir"/log/supervise
-        ln -s /var/lib/runit/log/supervise/"$sv" "$svdir"/log/supervise
+        ln -s /run/runit/supervise/"$sv".log "$svdir"/log/supervise
+      fi
+      #934500 force the switch of supervise into /run, keep untill bullseye +1
+      if [ -h "$svdir"/log/supervise ]; then
+        if [ $(readlink "$svdir"/log/supervise) != /run/runit/supervise/"$sv".log ]; then
+            rm -rf "$svdir"/log/supervise
+            ln -s /run/runit/supervise/"$sv".log "$svdir"/log/supervise
+        fi
       fi
     fi
     ln -s "$svdir" "$servicedir"/"$sv"
-- 
2.23.0

Reply via email to