summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Bogatov <KAction@gnu.org>2016-06-08 23:12:38 +0300
committerDmitry Bogatov <KAction@gnu.org>2016-06-08 23:12:38 +0300
commit2522d781a1fe724f8433160f0df9a3091aeacfb6 (patch)
treecdb800ba5649f3ab6b7b647e0b146108a9f9e879
parent28dfe2564c8f6bc4422b4d1eee7d707190bea7db (diff)
Improve created /etc/sv/${NAME} directory
* ensure that run/finish scripts are executable * create 'supervise' symlink to not pollute /etc/ directory
-rwxr-xr-xdh_runit17
-rw-r--r--postinst-runit6
-rw-r--r--prerm-runit1
3 files changed, 19 insertions, 5 deletions
diff --git a/dh_runit b/dh_runit
index ba066d8..28daea0 100755
--- a/dh_runit
+++ b/dh_runit
@@ -11,6 +11,8 @@ use Debian::Debhelper::Dh_Lib;
11use File::Find; 11use File::Find;
12use Path::Tiny; 12use Path::Tiny;
13use File::stat; 13use File::stat;
14use feature 'signatures';
15no warnings 'experimental::signatures';
14 16
15=head1 SYNOPSIS 17=head1 SYNOPSIS
16 18
@@ -64,6 +66,13 @@ specify, that it should not be enabled.
64 66
65=cut 67=cut
66 68
69sub ensure_executable($directory) {
70 for my $f ('run', 'finish', 'log/run', 'log/finish') {
71 my $file = "$directory/$f";
72 doit('chmod', '+x', $file) if (-e $file);
73 }
74}
75
67init(option => { 'no-enable' => \$dh{NO_ENABLE} }); 76init(option => { 'no-enable' => \$dh{NO_ENABLE} });
68 77
69PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { 78PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
@@ -85,10 +94,16 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
85 error("can't read `$path'") unless -r $path; 94 error("can't read `$path'") unless -r $path;
86 95
87 if ( -f $path) { 96 if ( -f $path) {
88 doit('install', 'd', '-m755', $path, "$sv_dir/$name/run"); 97 install_dir("$sv_dir/$name");
98 install_prog($path, "$sv_dir/$name/run");
89 } elsif ( -d $path) { 99 } elsif ( -d $path) {
90 doit('cp', '-r', $path, "$sv_dir/$name"); 100 doit('cp', '-r', $path, "$sv_dir/$name");
101 # Unfortunately, dh_fixperms does not handle executable bit here.
102 ensure_executable("$sv_dir/$name");
91 } 103 }
104 make_symlink("/etc/sv/$name/supervise",
105 "/var/lib/runit/supervise/$name", $tmp);
106
92 if ($enable eq 'enable' && !$dh{NO_ENABLE}) { 107 if ($enable eq 'enable' && !$dh{NO_ENABLE}) {
93 autoscript($pkg, 'postinst', 'postinst-runit', "s/#NAME#/$name/"); 108 autoscript($pkg, 'postinst', 'postinst-runit', "s/#NAME#/$name/");
94 } 109 }
diff --git a/postinst-runit b/postinst-runit
index 8b09a95..7c21f0e 100644
--- a/postinst-runit
+++ b/postinst-runit
@@ -16,7 +16,5 @@ restart installation.
16EOF 16EOF
17 exit 1 17 exit 1
18fi 18fi
19ln -s '/etc/sv/#NAME#' "$SV_DIR/" 19ln -sf '/etc/sv/#NAME#' "$SV_DIR/"
20 20mkdir -p /var/lib/runit/supervise/#NAME#
21
22
diff --git a/prerm-runit b/prerm-runit
index a919418..b23abeb 100644
--- a/prerm-runit
+++ b/prerm-runit
@@ -1 +1,2 @@
1rm -f /etc/service/#NAME# 1rm -f /etc/service/#NAME#
2rm -fr /var/lib/runit/supervise/#NAME#/*