serviced script

The serviced script command verifies or performs the commands in a script file.

USAGE

A script file is a text file that contains commands to automate common or repetitive tasks and tasks that might require specific services or conditions.

The serviced script command provides three subcommands.

help
Display the help message.
parse
Verify the syntax of a script file.
run
Perform the commands in a script file.
The correct invocation of serviced script run depends on whether the REQUIRE_SVC command is present in a script file.
  • If a script file does not include REQUIRE_SVC, no additional parameters are required. For example:
    serviced script run task1.txt
  • If a script file includes REQUIRE_SVC, the --service parameter is required. For example:
    serviced script run task2.txt --service Zenoss.core

The log file of a serviced script run invocation is /var/log/serviced/script-TIMESTAMP-$USER.log

SYNTAX

The script file syntax rules are as follows:

  • Lines that contain no text and lines that start with the number sign character (#) are ignored.
  • Lines are terminated with LF or CR+LF.
  • A command and its arguments cannot span lines.
  • The maximum number of characters per line (command and arguments) is 300000.
  • Unless otherwise noted, all command arguments are treated as strings.

COMMANDS

Commands are performed in the order in which they occur in a script. Scripts terminate on completion and when a command returns an exit code other than zero.

DESCRIPTION argument...
A statement about the script.
Scripts may contain one or zero DESCRIPTION commands. At least one argument is required.
VERSION argument
A revision reference for the script.
Scripts may contain one or zero VERSION commands. Only one argument is supported.
REQUIRE_SVC
The script needs a reference service in order to perform some or all of its tasks. The service is specified with the --service parameter of the serviced script run command.
Scripts may contain one or zero REQUIRE_SVC commands.
SNAPSHOT
Perform a snapshot. If a script command fails, serviced rolls back to the most recent snapshot.
The REQUIRE_SVC command must be present in the script.
Scripts may contain multiple SNAPSHOT commands.
SVC_USE Image-ID
Use the specified image for script commands that occur after this SVC_USE command. If your application uses multiple images, enter additional SVC_USE commands to specify each image. If the specified image is not present in the local Docker registry, serviced attempts to pull it from Docker Hub.
The REQUIRE_SVC command must be present in the script.
Scripts may contain multiple SVC_USE commands. Only one argument is supported.
SVC_RUN Service Run-Command arguments
Invoke one of the pre-defined commands associated with a service.
Service must be the absolute path of a service, with each service in the path separated by the solidus character (/). For example, Zenoss.core/Zope.
The REQUIRE_SVC command must be present in the script.
Scripts may contain multiple SVC_RUN commands. Multiple arguments are supported.
SVC_EXEC [COMMIT|NO_COMMIT] Service argument...
Start a new container to run arbitrary commands. (Equivalent to a non-interactive invocation of serviced service shell.)
When COMMIT is specified, changes are committed on successful completion of the commands in argument. When NO_COMMIT is specified, changes are not committed.
Service must be the absolute path of a service, with each service in the path separated by the solidus character (/). For example, Zenoss.core/Zope.
The REQUIRE_SVC command must be present in the script.
Scripts may contain multiple SVC_EXEC commands.
SVC_START {auto|recurse} Service
Start a new instance of Service.
If auto or recurse is not specified, all configured instances of Service are started. If auto or recurse is specified, all configured instances of Service and all of their child services are started.
Service must be the absolute path of a service, with each service in the path separated by the solidus character (/). For example, Zenoss.core/Zope.
The REQUIRE_SVC command must be present in the script.
Scripts may contain multiple SVC_START commands.
SVC_STOP {auto|recurse} Service
Stop the specified service.
If auto or recurse is not specified, all instances of Service are stopped. If auto or recurse is specified, all instances of Service and all of their child services are stopped.
Service must be the absolute path of a service, with each service in the path separated by the solidus character (/). For example, Zenoss.core/Zope.
The REQUIRE_SVC command must be present in the script.
Scripts may contain multiple SVC_STOP commands.
SVC_RESTART {auto|recurse} Service
Restart the specified service.
If auto or recurse is not specified, all instances of Service are restarted. If auto or recurse is specified, all instances of Service and all of their child services are restarted.
Service must be the absolute path of a service, with each service in the path separated by the solidus character (/). For example, Zenoss.core/Zope.
The REQUIRE_SVC command must be present in the script.
Scripts may contain multiple SVC_RESTART commands.
SVC_WAIT Service... [started|stopped|paused] Duration
Pause Duration seconds, or pause until the specified service or services reach the started, stopped, or paused state. If the state is not reached when Duration expires, the command fails.
Duration must be an integer.
Each Service must be the absolute path of a service, with each service in the path separated by the solidus character (/). For example, Zenoss.core/Zope.
The REQUIRE_SVC command must be present in the script.
Scripts may contain multiple SVC_WAIT commands.