16.8 Text File Policy

The Text File policy is used to make changes to any text file on a device.

To configure the Text File policy:

  1. In the ZENworks Control Center, click the Policies tab.

  2. In the Policies list, click New, then click Policy to display the Create New Policy page.

  3. In the Policy Type list, click Text File Policy, then click Next to display the Policy Name page.

    Policy Name page
  4. Fill in the fields:

    • Policy name: (Required) Provide a unique name for the policy. The name you provide displays in the ZENworks Control Center interface, which is the administrative tool for ZENworks Linux Management.

      For more information, see Section C.0, Naming Conventions in the ZENworks Control Center.

    • Folder: (Required) Type the name or browse to the folder that this policy will be created in. Folders display in the ZENworks Control Center.

    • Description: Provide a short description of the policy. This description displays on the policy's Summary page in the ZENworks Control Center interface.

  5. Click Next to display the General page.

    General page
  6. Select the desired options:

    Filename: Specify the name and the complete path of a file you want to change.

    Maximum number of versions to retain: Specify the maximum number of backups to be maintained for a file that has been changed. If the maximum limit of backups is reached, the oldest backup of a file is deleted. The backup is created in the same location as the specified file.

    Change name: Specify the name of the change you want to perform in the file. If you want to make more than one change in the same file, go to the Settings page.

    Change mode: Select an option from the drop-down list:

    • Search file: Lets you search for the given text in the entire file. Fill in the fields:

      • Search string: Specify the text you want to search for in a given file. The search string can be simple text or a regular expression. For detailed information on regular expressions, click the Help icon button.

        Case sensitive: Select this option to distinguish between uppercase and lowercase characters. When Case sensitive is selected, the system finds only those instances in which the capitalization matches the text you have specified in the search string.

        Search occurrence: Indicates the occurrence of the search text you have given. The available options are First Occurrence, Last Occurrence, and Find All Occurrences. For example, if you select First Occurrence, the system finds the first occurrence of the search string and performs the specified action on it.

        Result action: Select the operation from the drop-down list that you want perform on the specified search text.

    • Append lines to file: Lets you append the given lines of text to the file

    • Prepend lines to file: Lets you prepend the given lines of text to the file.

    New string: Specify the text to be used for carrying out the specified action in the file. For example, you can select to replace a search string with a new string.

    Create the file, if it does not exist: Allows you to create the specified file, if it does not exist. The file is created with the specified contents.

    Contents of the file: Allows you to add contents to the specified file. This option is available only if you select the Create the file, if it does not exist option. The file is created with owner and group set to root and r w - r - - r - - (644) permission. If any directory specified in the absolute file path does not exist, then it is created with owner and group set to root and r w x r - x r- x (755) permission. You can modify the ownership and permissions by configuring a script in the Post Change Action pane. (The Post Change Action pane is located in the Script page. To access the Script page, click Next in the General Page user interface.)

    Apply the change details: Applies the settings configured in the Change Details pane. By default, this option is selected when you select the Create the file, if it does not exist option.

  7. Click Next to display the Script Page.

    Script page
  8. Fill in the fields:

    Pre-change action: Specify the actions to perform before modifying the text files:

    • Executable type: Select the executable type from the drop-down list that you want to run before modifying the file. The available options are None, Binary, Java, and Script.

      (Conditional) If you chose Script in the Executable type field, the following options are available:

      Script to run: Select an option from the drop-down list (Specify a File or Define Your Own Script):

      • Specify a file: Fill in the fields:

        Script filename: Specify the complete path, including the filename, of the script you want to run on a managed device.

        Script parameters: Specify any parameters to be passed to the specified script file.

        Script engine: Specify the name and location of the script engine that runs the script. For example, /usr/bin/perl.

        Script engine parameters: Specify any parameters to be passed to the specified script engine.

      • Define your own script: Type your script in the box.

      (Conditional) If you chose Binary in the Executable type field, the following options are available:

      Executable file name: Specify the complete path, including the filename, of the binary program you want to run on a managed device.

      Executable file parameters: Specify any parameters to be passed to the specified binary program.

      (Conditional) If you chose Java in the Executable type field, the following options are available:

      Java program name: Specify the Java program you want to run on a managed device.

      Program parameters: Specify any parameters to be passed to the specified Java program.

      Java Runtime Executable (JRE): Specify the complete path, including the Java Runtime Executable (JRE) name. JRE is used to interpret the Java binary file.

      JRE parameters: Specify the parameters to be passed to the Java Runtime Executable (JRE).

      NOTE:The Own Defined Script specified in the Remote Execute policy is executed in the shell specified by the environment variable SHELL. The value of the variable SHELL is taken from the environment in which ZENworks Management daemon runs. If a value is not specified, then /bin/sh is used, which is a default value.

      Action when the execution fails: Select an action you want the system to perform when an execution fails. You can continue modifying the file by selecting Continue modifying the text file or you can stop the modifications in the file by selecting Do not modify the text file.

      NOTE:The backup of the text file is taken after the pre-change action completes the execution and before the text file modification starts.

    Post-change action: Specify the actions to perform after the actual changes are done in the file.

    • Executable type: Select the executable type you want to run after modifying the file. Select Binary, Java, Script, or None from the drop-down list. Depending on which type you select, the available options vary. For more information about the specific options, see the descriptions in the Pre-Change Action section directly above.

  9. Click Next to display the Summary page.

  10. Click Finish to create the policy as configured according to the settings on the Summary page. If you click Finish, the Text File policy is created but it does not have devices assigned or a schedule specified. At some point in the future, you need to configure additional options for the policy by continuing with Section 17.4, Assigning Policies.

    or

    Click Next to display the Policy Assignment page to perform the following tasks:

    • Specify assignments for this policy

    • Specify the schedule for this policy

    • Specify groups for this policy

    Policy Assignments page
  11. Assign the policy to the devices.

    1. Click Add to browse for and select the appropriate Server or Workstation objects.

      You can also select Folder or Group objects.

    2. Click the down-arrow next to Servers or Workstations to expand the list, then click the underlined link in the Name column to select the desired objects and display their names in the Selected list box.

      Assigning a policy to a Group object is the preferred method of assigning the policy. Assigning the policy to a large number of objects (for example, more than 250) might cause increased server utilization.

    3. Click OK.

  12. Click Next to display the Policy Schedule page, then select the schedule to apply to the assignments.

    The settings you configure on this page determine when the policy is applied to devices.

    See Section 15.3, Schedules for information about the available schedules.

  13. Click Next to display the Policy Groups page.

    Policy Groups page
  14. (Optional) Click Add to open the Select Groups dialog box, then click the underlined links in the Name column to select the desired policy groups and display their names in the Selected list box.

    Using policy groups eases administration efforts by letting you group several policies so you can use common assignments, schedules, and so forth, rather than configuring these settings for each policy you create. For more information, see Section 17.3, Creating Policy Groups.

  15. Click Next to display the Finish page.

  16. Review the information on the Finish page, making any changes to the policy settings by using the Back button as necessary. Click Finish to create the policy as configured according to the settings on the Finish page.