Skip to content

mxservicectl: Accept service unit name in mxstartups #4

Merged
merged 1 commit into from
Apr 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not switch on "user" name ...if eq _systemctl (underscore to make clear its special) so you can actually also start other systemd units like mounts and targets and stuff.. ? ;) gruss m. ... ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIMTOWTDI . We discussed, that this way we were no longer able to call out startstop scripts something with .service (which we would never do, but its a nice argument nonetheless). On the other hand, we had the vision that we might start user specific systemd services (systemctl --user) which would be an argument not to use the user field for something else. Of course, in reality we will never do that, even if it worked, which it doesn't.

We discussed the better solution to allow a script with arguments in the script field - possibly indicated by quotes - possibly with some placeholder for the start/stop argument like

tonerlow argh - "systemdctl %ACTION tonerlow-cups.service"

which is a nice coding challenge - especially if you want to support quoted arguments with whitespace, too - but nobody was eager to take it. So we dismissed it with "makes the line to long, which is ugly in vi" as an excuse. :-)

*.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