Improvements to the original service(8) command

Improvements to the original service(8) command to allow multiple services management in a single invocation.
Supported actions include: start, stop, restart, status, rcvar, describe, onestart, onestop, onerestart, onestatus, reload, enable, disable. Try FBSD-Services
 
My rc.local , but you get the idea,
Code:
/usr/bin/nohup  /usr/local/bin/nvidia_gpu_prometheus_exporter &

/usr/bin/nohup /usr/sbin/service  moused                onestart &
/usr/bin/nohup /usr/sbin/service  seatd                 onestart &
/usr/bin/nohup /usr/sbin/service  jail                  onestart &
/usr/bin/nohup /usr/sbin/service  nginx                 onestart &
/usr/bin/nohup /usr/sbin/service  apache24              onestart &
/usr/bin/nohup /usr/sbin/service  minidlna              onestart &
/usr/bin/nohup /usr/sbin/service  cupsd                 onestart &
/usr/bin/nohup /usr/sbin/service  blackbox_exporter     onestart &
/usr/bin/nohup /usr/sbin/service  node_exporter         onestart &
/usr/bin/nohup /usr/sbin/service  gstat_exporter        onestart &
/usr/bin/nohup /usr/sbin/service  telegraf              onestart &
/usr/bin/nohup /usr/sbin/service  prometheus            onestart &
/usr/bin/nohup /usr/sbin/service  grafana               onestart &
/usr/bin/nohup /usr/sbin/service  zabbix74_server       onestart &
/usr/bin/nohup /usr/sbin/service  zabbix_agentd         onestart &
/usr/bin/nohup /usr/sbin/service  zabbix_server         onestart &
 
Alain De Vos I think the OP is talking about something different.

My understanding is the changes/improvements would allow you to do:
service restart moused seatd jail

instead of
service restart moused
service restart seatd
service restart jail

That example is probably not a useful thing, but the concept is useful for say:
you need restart the wpa_supplicant (to restart your wifi) and then restart the network:

service restart wpa_supplicant network

I'm assuming the changes would do the operation sequentially, so it's just saving a user a little bit of time.
Probably limited use during actual booting, but definitely useful during manual operation and debugging.
 
My rc.local , but you get the idea,
Code:
/usr/bin/nohup  /usr/local/bin/nvidia_gpu_prometheus_exporter &

/usr/bin/nohup /usr/sbin/service  moused                onestart &
/usr/bin/nohup /usr/sbin/service  seatd                 onestart &
/usr/bin/nohup /usr/sbin/service  jail                  onestart &
/usr/bin/nohup /usr/sbin/service  nginx                 onestart &
/usr/bin/nohup /usr/sbin/service  apache24              onestart &
/usr/bin/nohup /usr/sbin/service  minidlna              onestart &
/usr/bin/nohup /usr/sbin/service  cupsd                 onestart &
/usr/bin/nohup /usr/sbin/service  blackbox_exporter     onestart &
/usr/bin/nohup /usr/sbin/service  node_exporter         onestart &
/usr/bin/nohup /usr/sbin/service  gstat_exporter        onestart &
/usr/bin/nohup /usr/sbin/service  telegraf              onestart &
/usr/bin/nohup /usr/sbin/service  prometheus            onestart &
/usr/bin/nohup /usr/sbin/service  grafana               onestart &
/usr/bin/nohup /usr/sbin/service  zabbix74_server       onestart &
/usr/bin/nohup /usr/sbin/service  zabbix_agentd         onestart &
/usr/bin/nohup /usr/sbin/service  zabbix_server         onestart &
😯
 
on solaris,

svcadm: Manages service states (start/stop/restart).
  • svcadm enable <FMRI> (Start a service).
  • svcadm disable <FMRI> (Stop a service).
  • svcadm restart <FMRI> (Restart a service).
  • svcadm refresh <FMRI> (Reload configuration).
  • svcadm clear <FMRI> (Clear maintenance state).
 
I'm honestly not a fan of the <action> <service> order. It's one of the reasons why I dislike systemctl (systemd) because it has that same order of operands. I'm very used to doing things like
Code:
service something enable
<press the up key, ^W>start
Agreed. I can't tell you how many times I get the error "no such service as restart"
 
I also dislike the systemctl argument order.

I believe that Solaris and other Unix tools that have this ordering take influence from contextual CLIs such as IOS (Cisco), where you go into a context, e.g. "service" and then perform commands. There is a lot of this type of syntax in NT tools, you can encounter it in diskpart today.

I remember the systemd saga and the argument pro syntax was "Solaris used it". Which isn't really a good argument.
 
I think that the systemctl syntax is ok, especially if you need to execute a command on several services. It saves typing.

Seems to be a cool utility. It adds enable/disable, so you don't need to use sysrc. That said, is it worth the installation? I'm not sure.

If I was you, I'd change the name because fbsd-services is too long and I'd make it a port. It will become easier to install. Also, you may add others functionalities.

Anyway, it's a good work.
 
I think that the systemctl syntax is ok, especially if you need to execute a command on several services. It saves typing.

Seems to be a cool utility. It adds enable/disable, so you don't need to use sysrc. That said, is it worth the installation? I'm not sure.

If I was you, I'd change the name because fbsd-services is too long and I'd make it a port. It will become easier to install. Also, you may add others functionalities.

Anyway, it's a good work.
I agree that the name is cumbersome to write, so I’ve decided to change it to services. Thanks.
 
KISS. This task could have been solved with an alias to xargs(1).​
Bash:
alias services='xargs -J% -L1 service'

services -E LC_ALL=C.UTF-8 % onerestart << EOT
foo
bar
EOT

services % << EOT
foo enable
foo restart
EOT

[…]
Code:
/usr/bin/nohup  /usr/local/bin/nvidia_gpu_prometheus_exporter &

/usr/bin/nohup /usr/sbin/service  moused                onestart &
/usr/bin/nohup /usr/sbin/service  seatd                 onestart &
/usr/bin/nohup /usr/sbin/service  jail                  onestart &
/usr/bin/nohup /usr/sbin/service  nginx                 onestart &
/usr/bin/nohup /usr/sbin/service  apache24              onestart &
/usr/bin/nohup /usr/sbin/service  minidlna              onestart &
/usr/bin/nohup /usr/sbin/service  cupsd                 onestart &
/usr/bin/nohup /usr/sbin/service  blackbox_exporter     onestart &
/usr/bin/nohup /usr/sbin/service  node_exporter         onestart &
/usr/bin/nohup /usr/sbin/service  gstat_exporter        onestart &
/usr/bin/nohup /usr/sbin/service  telegraf              onestart &
/usr/bin/nohup /usr/sbin/service  prometheus            onestart &
/usr/bin/nohup /usr/sbin/service  grafana               onestart &
/usr/bin/nohup /usr/sbin/service  zabbix74_server       onestart &
/usr/bin/nohup /usr/sbin/service  zabbix_agentd         onestart &
/usr/bin/nohup /usr/sbin/service  zabbix_server         onestart &
You are making me sad.​
Bash:
for service in moused seatd jail nginx apache24 # and so on
do
	/usr/bin/nohup /usr/sbin/service $service onestart &
done
 
KISS. This task could have been solved with an alias to xargs(1).​
Bash:
alias services='xargs -J% -L1 service'

services -E LC_ALL=C.UTF-8 % onerestart << EOT
foo
bar
EOT

services % << EOT
foo enable
foo restart
EOT
You may want to raise this point with the maintainer of the service(8) script and the FreeBSD core team. If they consider your proposal, they could add your aliases to the system by default, thereby eliminating the need for the base system’s service(8) implementation.
 
Back
Top