Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Using a Master Source Location for a Script

Configuring and Refreshing from the Master Source for a Script

You can store a master copy of each script in a central repository. This eases file management because you can make changes to the master script in one place and then update the copy on each device where the script is currently enabled. This section discusses the following concepts:

Configuring the Master Source for a Script

To specify the location of the master source for a script, configure the source statement and the URL of the master file at the hierarchy level where the script is configured. Including the source statement in the configuration does not affect the local copy of the script until you issue the set refresh command. At that point, the device retrieves the master copy from the specified URL and overwrites the local copy.

The hierarchy location for the source statement depends on the script type and filename.

  • commit script—Include the source statement at the [edit system scripts commit file filename] hierarchy level.

    [edit system scripts commit file filename]user@R1# set source url
  • op script—Include the source statement at the [edit system scripts op file filename] hierarchy level.

    [edit system scripts op file filename]user@R1# set source url
  • event script—Include the source statement at the [edit event-options event-script file filename] hierarchy level.

    [edit event-options event-script file filename]user@R1# set source url
    Where
    • filename—Name of the script.
    • url—URL of the script’s master source file. Specify the source as a Hypertext Transfer Protocol (HTTP) URL, FTP URL, or secure copy (scp)-style remote file specification.

Updating a Script from the Master Source

If you configure a master source for one or more scripts on a device, you can refresh the scripts on that device using the set refresh configuration mode command. You can update a single script or all scripts of a given script type that have a master source location configured.

The update operation occurs as soon as you issue the set refresh command. When you issue the set refresh command, the switch, router, or security device immediately attempts to connect to the specified URL and retrieve a copy of the master file. The master copy overwrites the local script stored in the scripts directory on the device. If a master source is not defined for a script, that script is not updated and a warning is issued. For commit scripts, the updated commit script is executed when you next issue the commit command.

Issuing the set refresh command does not add the refresh statement to the configuration. Thus the command behaves like an operational mode command by executing an operation, instead of adding a statement to the configuration.

If the device has dual Routing Engines and you want to update a script on both Routing Engines, you must issue the set refresh command on each Routing Engine separately. The commit synchronize command does not cause the refresh statement to update scripts on both Routing Engines.

To update a single script from its master source, issue the set refresh command at the hierarchy level where the script is configured. The source statement specifying the master source location must already be configured.

  • commit script—Issue the set refresh command at the [edit system scripts commit file filename] hierarchy level.

    [edit system scripts commit file filename]user@R1# set refresh
  • op script—Issue the set refresh command at the [edit system scripts op file filename] hierarchy level.

    [edit system scripts op file filename]user@R1# set refresh
  • event script—Issue the set refresh command at the [edit event-options event-script file filename] hierarchy level.

    [edit event-options event-script file filename]user@R1# set refresh
    Where filename is the name of the script.

To update all enabled scripts of a given script type from their master source files, issue the set refresh command at the hierarchy level for that script type.

  • commit scripts—Issue the set refresh command at the [edit system scripts commit] hierarchy level:

    [edit system scripts commit]user@R1# set refresh
  • op scripts—Issue the set refresh command at the [edit system scripts op] hierarchy level:

    [edit system scripts op]user@R1# set refresh
  • event scripts—Issue the set refresh command at the [edit event-options event-script] hierarchy level:

Example: Configuring and Refreshing from the Master Source for a Script

The following example configures a master source file for an op script on a device running Junos OS. The remote source is defined as an HTTP URL. The example uses the master source to update the local copy of the script on the device.

Requirements

  • Routing, switching, or security device running Junos OS.

Overview

You can store a master copy of each script in a central repository. You can make changes to the master script in one place and then update the local copy of the script on devices where the script is enabled.

This example enables the op script iso.xsl on a device running Junos OS and then configures a master source location for the script. The remote source for the iso.xsl file is the HTTP URL http://my.example.com/pub/scripts/iso.xsl.

Once you configure the master source location, you refresh the local script by issuing the set refresh configuration mode command at the hierarchy level where you configured the script. In this example, you would issue the set refresh command at the [edit system scripts op file iso.xsl] hierarchy level.

Configuration

Step-by-Step Procedure

To download, enable, and configure the master source location for the script:

  1. Copy the script to the /var/db/scripts/op/ directory on the device.
  2. In configuration mode, configure the file statement to enable the iso.xsl script.

    [edit system scripts op]user@R1# set file iso.xsl
  3. To configure the master source for the iso.xsl file, include the source statement and source location at the [edit system scripts op file iso.xsl] hierarchy level.

    [edit system scripts op file iso.xsl]user@R1# set source http://my.example.com/pub/scripts/iso.xsl
  4. Issue the commit and-quit command to commit the configuration and exit to operational mode.

    [edit]user@R1# commit and-quit

Results

system {scripts {op {file iso.xsl {source http://my.example.com/pub/scripts/iso.xsl;}}}}

Verifying the Script

Purpose

Verify that the script is on the device and enabled in the configuration.

Action

Issue the file list operational mode command to view the files in the specified directory. The detail option provides additional information such as permissions, file size, and modified date.

user@R1> file list /var/db/scripts/op detail
/var/db/scripts/op:
total 128
-rw-r--r--  1 root  admin  13897 Feb 10  2011 iso.xsl
...

Issue the show configuration system scripts op operational mode command to list the op scripts currently enabled on the device.

user@R1> show configuration system scripts op
file iso.xsl

Refreshing the Script from the Master Source

Step-by-Step Procedure

To refresh the local copy of the script from the master source file:

  1. In configuration mode, issue the set refresh command at the [edit system scripts op file iso.xsl] hierarchy level.

    [edit system scripts op file iso.xsl]user@R1# set refresh

Verification

Verifying the Updated Script

Purpose

After refreshing the script, verify that the local copy is updated.

Action

Issue the file list operational mode command with the detail option to view the files in the specified directory. Verify that the modified date reflects the refreshed version.

user@R1> file list /var/db/scripts/op detail
/var/db/scripts/op:
total 128
-rw-r--r--  1 root  admin  14128 May 26  2011 iso.xsl
...

Published: 2013-03-05