Skip to content

Commit

Permalink
mxservicectl: Accept service unit name in mxstartups
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donald committed Apr 12, 2018
1 parent 0b543dc commit 6f0dd5f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mxservicectl
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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}

Expand Down

0 comments on commit 6f0dd5f

Please sign in to comment.