Control the Execution of Commit Scripts During Commit Operations
Commit scripts are stored on a device’s hard disk in the
/var/db/scripts/commit
directory or on the flash drive in the
/config/scripts/commit
directory. Only users in the
superuser login class can access
and edit files in these directories. For
information about setting the storage location for
scripts, see Store and Enable Junos Automation Scripts and Store Scripts in Flash Memory.
A commit script is not actually executed during commit operations
unless its filename is included at the [edit system scripts commit
file] hierarchy level. When you configure the script filename,
you must include the appropriate filename extension for SLAX (.slax) and Python (.py) scripts. XSLT scripts do not require a filename extension, but
we strongly recommend that you append the .xsl extension for clarity. To prevent execution of a commit script,
delete the commit script’s filename at that hierarchy level.
By default, the commit operation fails unless all scripts included
at the [edit system scripts commit file] hierarchy level
actually exist in the commit script directory. To enable the commit
operation to succeed even if a script is missing, include the optional statement at the [edit system scripts commit
file filename] hierarchy level. For example,
you might want to mark a script as optional if you anticipate the
need to quickly remove it from operation by deleting it from the commit
script directory, but do not want to remove the commit script filename
at the [edit system scripts commit file] hierarchy level.
To enable use of the script again later, you simply replace the file
in the commit script directory.
When you include the optional statement
at the [edit system scripts commit file filename] hierarchy level, no error message is generated during the
commit operation if the file does not exist. As a result, you might
not be aware that a script is not executed as you expect.
You can also deactivate and reactivate
commit scripts by issuing the deactivate and activate configuration mode commands. When a commit script is deactivated,
the script is marked as inactive in the configuration and does not
execute during the commit operation. When a commit script is reactivated,
the script is again executed during the commit operation.
To determine which commit scripts are currently enabled on the
device, use the show command to display the files configured
at the [edit system scripts commit] hierarchy level. To
ensure that the enabled files are on the device, list the contents
of the /var/run/scripts/commit/ directory
by using the file list /var/run/scripts/commit operational
mode command.
Enabling Commit Scripts to Execute During Commit Operations
To configure a commit script to execute during a commit operation:
Preventing Commit Scripts from Executing During Commit Operations
You can prevent a commit script from executing during a commit
operation by removing the script’s filename from the [edit
system scripts commit] hierarchy in the configuration.
You can also use the deactivate statement to
deactivate a script instead of removing the script’s filename
from the configuration. Deactivated scripts may be reactivated later.
To prevent a commit script from executing during a commit operation:
Deactivating Commit Scripts
Deactivating a commit script marks it as inactive in the configuration. Inactive
scripts are ignored during a commit operation.
To deactivate a commit script so that it does not execute during the commit operation:
Activating Commit Scripts
Deactivating a commit script marks it as inactive in the configuration. Inactive scripts are not executed during the commit operation. You can reactivate the script by using the activate statement.
To activate an inactive commit script:
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.