[RFC PATCH 08/12] init-d-script: do_start/stop/restart should return 1 on errors

Trek trek00 at inbox.ru
Thu Jul 2 18:19:36 BST 2020


For those actions, LSB specification requires the script to
return 0 if action was successful or nothing was done, 1 on
unspecified errors, 2 on invalid arguments and 3 on unimplemented
feature, while start-stop-daemon returns 0 on success, 1 if
nothing was done, 2 if timeout occourred on stop and 3 on other
errors.

With this patch actions will return 0 on success and 1 on errors.
---
 debian/init-d-script | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/debian/init-d-script b/debian/init-d-script
index 756158b5..9cec708f 100755
--- a/debian/init-d-script
+++ b/debian/init-d-script
@@ -58,11 +58,9 @@ do_start()
 	fi
 	log_daemon_msg "Starting $DESC" "$NAME"
 	call do_start_cmd
+	test $? -lt 2
 	retval=$?
-	case ${retval} in
-		0|1) vlog_end_msg 0; retval=0 ;;
-		*) vlog_end_msg 1 ;;
-	esac
+	vlog_end_msg $retval
 	if is_call_implemented do_start_cleanup ; then
 		call do_start_cleanup
 	fi
@@ -104,11 +102,9 @@ do_stop()
 	fi
 	vlog_daemon_msg "Stopping $DESC" "$NAME"
 	call do_stop_cmd
+	test $? -lt 2
 	retval=$?
-	case ${retval} in
-		0|1) vlog_end_msg 0; retval=0 ;;
-		*)   vlog_end_msg 1 ;;
-	esac
+	vlog_end_msg $retval
 	if is_call_implemented do_stop_cleanup ; then
 		call do_stop_cleanup
 	fi
@@ -122,11 +118,9 @@ do_restart() {
 	vlog_daemon_msg "Restarting $DESC" "$NAME"
 	call do_stop_cmd
 	call do_start_cmd
+	test $? -lt 2
 	retval=$?
-	case ${retval} in
-		0|1) vlog_end_msg 0; retval=0 ;;
-		*)   vlog_end_msg 1 ;;
-	esac
+	vlog_end_msg $retval
 	if is_call_implemented do_restart_cleanup ; then
 		call do_restart_cleanup
 	fi
-- 
2.20.1





More information about the Debian-init-diversity mailing list