From 6f0dd5f7a21b3edb5011fe07edc1c29226eaffed Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 12 Apr 2018 14:34:28 +0200 Subject: [PATCH] mxservicectl: Accept service unit name in mxstartups Regard the 4th column of /etc/mxstartups as the name of a systemd service unit if it ends in ".service". In that case, ignore the username and use systemctl to start/stop that unit. The idea is to use /etc/mxstartups for services, which we want to run as a systems service, e.g. to use the features of systemd. Currently there is an option to use unit files with an encoded hostname but we prefer to have the information of which hosts starts which service in /etc/mxstartups. --- mxservicectl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/mxservicectl b/mxservicectl index 5541f25..49dacd9 100755 --- a/mxservicectl +++ b/mxservicectl @@ -19,7 +19,14 @@ function mxsrv_start_one() { . ${cfg} - su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} start" & + case "${MX_SRV_SCRIPT}" in + *.service) + systemctl start "${MX_SRV_SCRIPT}" + ;; + *) + su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} start" & + ;; + esac mv ${cfg}{,.r} @@ -34,7 +41,14 @@ function mxsrv_stop_one() { . ${cfg} - su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} stop" & + case "${MX_SRV_SCRIPT}" in + *.service) + systemctl stop "${MX_SRV_SCRIPT}" + ;; + *) + su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} stop" & + ;; + esac rm ${cfg}