5.5 Using Server Software Packages to Delete Directories on Servers

If you want to delete certain directories from a number of different network servers (NetWare, Windows, Linux, and Solaris), you normally do not have an automated method for performing this task. However, if you are using ZENworks 7 Server Management Policy and Distribution Services, the Server Software Packages feature of Server Management provides the capability for you to delete specified directories from any Subscriber server’s file system.

To automate the deletion of specified directories on multiple servers, you first set up path variables (if necessary), create a Server Software Package in its namespace in ConsoleOne, compile the software package, then distribute the package using Tiered Electronic Distribution. No further user intervention is required.

Do the following in order to create a software package that deletes specified directories on a server:

  1. Setting Up Variables for Use With the Server Software Package

  2. Creating the Server Software Package

  3. Creating and Configuring the Server Software Package Component

  4. Compiling the Server Software Package

  5. Manually Testing that the Directories Have Been Deleted

  6. What’s Next

5.5.1 Setting Up Variables for Use With the Server Software Package

Before you create the software package, you must set up the variables in your Subscriber objects’ properties if you are using variables in paths (for instance, if your target servers have different operating systems, like NetWare and Windows).

  1. Identify the directories to be deleted:

    1. Identify the root of the path, such as its volume name (NetWare), drive letter (Windows), or /var/opt/novell/zenworks (for Linux and Solaris). For example, data:.

    2. Identify the rest of the path, including the parent directory to the directories to be deleted, such as \zenworks\pds\ted\dist where dist is the parent directory.

    3. Identify the directories to be deleted, such as olddist.Distributions.ZENworks.Novell.

      The resulting full path and directory to be deleted would be:

      data:\zenworks\pds\ted\dist\olddist.Distributions.ZENworks.Novell
      

      You might have varying path elements from server to server. You should use variables as necessary to allow for those differences (see Step 2 and Step 3).

  2. In ConsoleOne, create a variable to represent data:, D:, or /var/opt/novell/zenworks for each Subscriber where the directories to be deleted reside, such as DELETEDDIRROOT.

    If you name a directory to be deleted that does not exist on a target server, nothing is done for that directory on that server.

    You can also define variables globally using the Tiered Electronic Distribution policy. There, you should define the default value for a variable and allow the exceptions to be defined in the applicable Subscriber objects’ properties.

  3. In ConsoleOne, create a Subscriber variable to represent where any path elements are different for the Subscriber server.

    For more information on variables, see Section 9.0, Variables.

  4. Repeat Step 2 and Step 3 as necessary.

  5. Continue with Section 5.5.2, Creating the Server Software Package.

5.5.2 Creating the Server Software Package

  1. In the left pane in ConsoleOne where the ZENworks 7 Server Management snap-ins have been installed, right-click the Server Software Packages namespace.

  2. Click File > New > Software Package to start the Create New Server Software Package Wizard.

  3. Click Next.

  4. Provide a name for the software package, such as Delete Old Directories.

  5. Specify a path and filename for the software package template file (.spk), such as c:\temp\deletedirs.spk.

    IMPORTANT:If you save your .spk file to a network server, use a UNC path so that you still have access to that software package file if your drive letters change.

    You can also save your .spk files to a workstation or server, because the .spk file sizes do not become large. For this particular type of software package (where you are only giving instructions for deleting directories and are not compiling data files), the .cpk (compiled software package) version is similar in size. Therefore, for management purposes, you might want to save these .spk files and their corresponding .cpk files in the same location, which can be on a workstation or server.

  6. Click Finish.

  7. If necessary, click the plus sign to expand the Server Software Package namespace to view the new package.

  8. Continue with Section 5.5.3, Creating and Configuring the Server Software Package Component.

    Unless otherwise instructed, you should perform the steps in the subsequent sections from the same instance of ConsoleOne you used in the above steps, because your .spk files are accessible from there.

5.5.3 Creating and Configuring the Server Software Package Component

  1. Right-click the software package object that you just created, then select New Component.

  2. Provide a name for the component, such as Delete Directories.

  3. If necessary, click the plus sign to expand the Server Software Package object.

  4. Right-click the component and select Properties.

  5. Select the Copy File tab.

  6. Click the drop-down list button next to the Add button, then select Add File Group.

  7. Click Add.

  8. Provide a name for the file group, such as Delete Working Directories.

  9. In the Group Target Path field, specify the name of the variable that you created containing the location of the directories to be deleted, and add any path information that is not contained in the variable; however, do not specify the name of the directory to be deleted as part of that path.

    For example, if the location for the directories to be deleted is the same for all target servers, specify the actual volume (NetWare) or drive (Windows) with the path information (which can also contain variables).

    However, if you need to use variables because the server operating systems are different, then specify the variable name (within the % symbols) plus the full path (which can also contain variables) to the directory just above the directories to be deleted. For example, %DELETEDDIRROOT% (variable name) and %TARGET%\pds\ted\dist (full path to the parent directory of the directories you want to delete).

    IMPORTANT:When using variables, the path you provide must be the directory containing the directory to be deleted. In Step 11 you add the actual directory names to be deleted.

  10. Click OK to exit the dialog box.

  11. Click the drop-down list button again and select Add Directory.

    Make sure you first select the tree item under which you want to add this directory.

  12. Click Add.

  13. To change the name (“Directory”) that defaults in the tree structure to the actual directory name that you want deleted (such as olddist.Distributions.ZENworks.Novell), edit the directory name and press the Enter key to save the change.

    If you do not press the Enter key, “Directory” is displayed again. The Rename button allows you to edit the directory name.

  14. Click the drop-down list button next to the Copy Mode combo box, then select Delete.

  15. Click Apply.

  16. Repeat Step 10 through Step 15 for each directory you want this software package to delete using this component’s file group.

    You can start at Step 6 to add other file groups, or from Step 1 to add a new component. You might want to repeat from these steps if you cannot add all of your directories to be deleted under the file group that you created in Step 6.

  17. When finished configuring the software package component, click OK or Close.

    Using the examples from the above steps, you would have entered:

    %DELETEDDIRROOT%
    

    and

    %TARGET%\pds\ted\dist
    

    and

    olddist.Distributions.ZENworks.Novell
    

    in order to delete the directories having the following paths:

    data:\zenworks\pds\ted\dist\olddist.Distributions.ZENworks.Novell
    d:\zfs\zenworks\pds\ted\dist\olddist.Distributions.ZENworks.Novell
    
  18. Continue with Section 5.5.4, Compiling the Server Software Package.

5.5.4 Compiling the Server Software Package

You now have a .spk file that serves as the template for what you want to delete. You need to compile this .spk file into a .cpk file.

  1. Right-click the software package, such as Delete Old Directories.

  2. Select Compile to start the Compile Software Package Wizard.

  3. Click Next on the first page of the wizard.

  4. Provide the full path and filename for the .cpk file that you are generating.

    IMPORTANT:Do not use the .spk extension for this filename, or your template file could be overwritten by its compiled version if they are stored in the same location. This would prevent you from making further edits to the software package. You can use the same filename, such as DELETEDIRS, but you should use only the .cpk filename extension.

  5. Click Next, then click Finish.

  6. Continue with Section 5.5.5, Manually Testing that the Directories Have Been Deleted.

5.5.5 Manually Testing that the Directories Have Been Deleted

The software package is now ready for sending as a Software Package Distribution. However, for testing, you can manually process the software package on one of the target servers to determine that the directories were deleted as intended.

  1. On a server where you want to delete a directory, create a directory that is contained in your software package (such as olddist.Distributions.ZENworks.Novell) under \zenworks\pds\ted\dist.

  2. Copy the .cpk file (for example, deletedirs.cpk) to the \temp directory on that server.

  3. At the server’s ZENworks Server Management console prompt, enter the PACKAGE PROCESS command to process the software package.

    For example, if it is a NetWare server, at the ZENworks Server Management prompt you should enter:

    package process data:\temp\deletedirs.cpk
    

Server Management processes the package and report that it has finished processing. Check the server’s file system to see that the \olddist.Distributions.ZENworks.Novell directory, or the directories you specified, were deleted.

5.5.6 What’s Next

After you are satisfied with the result of your test, you can distribute the deletedirs.cpk file using Tiered Electronic Distribution to all your target Subscriber servers with your new Software Package Distribution in order to delete directories on your Subscriber servers’ file systems.