Package: runit
Version: 2.1.2-17
Severity: wishlist
Tags: patch


-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.17.3-van (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages runit depends on:
ii  libc6         2.27-8
ii  runit-helper  2.7.3

Versions of packages runit recommends:
ii  runit-init  2.1.2-17

runit suggests no packages.

-- Configuration Files:
/etc/runit/3 changed [not included]

-- no debconf information

-- debsums errors found:
debsums: changed file /sbin/update-service (from runit package)

Hi Dmitry, 

Please consider add those --auto/--noauto options to update-service: noauto 
prevent an already enabled
service to restart if it's terminated and prevent to automatically start a 
service at boot.
Somehow a duplicate of 'sv d service' or 'update-service --remove', but is also 
different in 
that (unlike 'sv d service') it persist across reboot and also (unlike 
update-service --remove)
does not need to act on symlink. Maybe could be useful, see if you like it.
The patch add --auto/--noauto options and also update the manpage to describe 
those options.

Lorenzo
>From 8b0ee16e824e776d59471b4da1b025f6706f12bf Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti <lorenzo.r...@gmail.com>
Date: Mon, 29 Oct 2018 11:15:39 +0100
Subject: [PATCH 2/2] Add --auto/--noauto option to update-service

'noauto' touches a down file inside the service directory, preventing
the service from automatically start at boot;
'auto' removes the down file restoring the default behavior.
Also update synopsis and description of update-service's man page.
---
 debian/contrib/update-service   | 24 +++++++++++++--
 debian/contrib/update-service.8 | 53 +++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/debian/contrib/update-service b/debian/contrib/update-service
index 36fa5f9..01d10da 100644
--- a/debian/contrib/update-service
+++ b/debian/contrib/update-service
@@ -11,7 +11,8 @@ fatal() { err "${0##*/}: fatal: $*"; }
 warn() { err "${0##*/}: warning: $*"; }
 usage() {
   err "Usage: ${0##*/} --add|--remove <service-directory> [<service-name>]
-       ${0##*/} --list|--check [<service-name>]"
+       ${0##*/} --list|--check [<service-name>]
+       ${0##*/} --auto|--noauto <service-directory>"
 }
 
 opt=$1
@@ -45,7 +46,6 @@ test "$sv" = "${sv#*/}" ||
 test "$defaultrun" = "$(readlink "$servicedir")" && \
   relsymdir=../../../sv
   
-  
 case "$opt" in
   -a|--add)
     test "$(id -u)" = 0 || fatal "${0##*/} -a must be run by root."
@@ -90,6 +90,26 @@ case "$opt" in
       "the service daemon received the TERM and CONT signals."
     exit 0
   ;;
+  -u|--auto)
+    test "$(id -u)" = 0 || fatal "${0##*/} -u must be run by root."
+    sv=$(basename "$svdir")
+    test -f "$svdir"/down || warn "Service $sv is already set to auto"
+    rm "$svdir"/down
+    printf '%s %s\n' \
+      "Service $sv is set to auto," \
+      "now the wanted status of the service is up."
+    exit 0
+  ;;
+  -n|--noauto)
+    test "$(id -u)" = 0 || fatal "${0##*/} -n must be run by root."
+    sv=$(basename "$svdir")
+    test -f "$svdir"/down && warn "Service $sv is already set to no-auto"
+    touch "$svdir"/down
+    printf '%s %s\n' \
+      "Service $sv is set to no-auto," \
+      "now the wanted status of the service is down."
+    exit 0 
+  ;;
   *) usage
   ;;
 esac
diff --git a/debian/contrib/update-service.8 b/debian/contrib/update-service.8
index 5d3d1f3..a45e113 100644
--- a/debian/contrib/update-service.8
+++ b/debian/contrib/update-service.8
@@ -10,6 +10,10 @@ update-service \- add/remove a service to/from system-wide 
service supervision
 .B update-service
 \--list|--check
 [\fIservice-name\fB]
+.P
+.B update-service
+\--auto|--noauto
+.I service-directory
 .SH DESCRIPTION
 .I service-directory
 must be a directory to be used by
@@ -106,6 +110,55 @@ services, one per line.
 The same as --list, but
 .B update-service
 doesn't print anything to standard out or standard error.
+
+.TP
+.B \--auto | \-u
+Remove the down file, if any, from the directory
+.IR service-directory .
+This way, the service represented by the
+.IR service-directory 
+will be started and monitored as soon as a runsv process is started
+for that directory; the requested status of the service will be 'up'.
+This is the default.
+If
+.I service-name
+is given, will be ignored as 
+.BR --auto 
+directly act on the
+.IR service-directory 
+and thus only takes
+.IR service-directory
+as argument.
+.TP
+.B \--noauto | \-n
+Touch a down file into the
+.IR service-directory .
+This way the service represented by
+.IR service-directory
+will not be automatically started when a runsv process is started for that 
directory.
+The requested status of the service will be 'down'.
+A service set to
+.BR --noauto
+does not start automatically at boot or when a 
+.BR runsvchdir (8)
+takes place,
+but can still be started using the
+.BR sv (8)
+program, e.g.:
+
+# sv up
+.I service-name
+
+If
+.I service-name
+is given, will be ignored as 
+.BR --noauto 
+directly act on the
+.IR service-directory 
+and thus only takes
+.IR service-directory
+as argument.
+
 .SH ENVIRONMENT
 .TP
 .B SVDIR
-- 
2.19.1

Reply via email to