Service Operations
ensure_service.sh
Service-related ensure functions, currently only for systems using systemd.
Functionsensure_service_active
Ensure that a service is running, starting it if necessary.
Automatically performs a daemon-reload if the service unit file has changed.
Examples
- Start nginx if not running
- Enable and start docker
- Restart a service after config changes
-
--enable:Also enable the service to start on boot.
-
--restart:Force restart the service even if already running. NOT IDEMPOTENT.
-
--reload:Reload the service configuration. NOT IDEMPOTENT.
-
--no-start:Only configure the service (enable/daemon-reload) without starting it.
-
{service_name...}:The name of the service(s) to ensure are active.
ensure_service_inactive
Ensure that a service is stopped, stopping it if necessary.
Examples
- Stop apache2 if running
- Disable and stop a service
-
--disable:Also disable the service from starting on boot.
-
--no-stop:Only configure the service (disable) without stopping it.
-
{service_name...}:The name of the service(s) to ensure are inactive.