Creating and Rolling Out Universal Script Packages (USP)
Universal Script Package and RPM Package
Universal Script Packages (USP) are not the usual eScript Packages but have their own package format. Basically they show the same behavior as the OS Action Packages you already know from DSM OS Deployment (OSD). The main difference is that they have platform settings. Installation targets must have an operating system that matches the package in the Basic Inventory, so that the system can create policy instances after the assignment. USP do not have user and computer portions.
Use the Packaging Workbench to edit the UPS you just created. You may use the package for installing the Discovery Client Agent as a template for installing and uninstalling an application in Linux. You can find this package in the DSMC in OS Library › OS Actions › Post OS Action Package Install Discovery for Linux.
You can use variables in your scripts. The variable syntax is the same as for OSD packages: %Variable%.
You can package the following types of scripts with a USP:
- DOS batch files (*.BAT)
- Linux Shell scripts (*.SH)
- VB script files (*.VBS)
- Windows PE Command files (*.CMD)
A special type of Universal Script Packages are RPM packages. They have been introduced in DSM to distribute RPM installation packages (commonly used in Linux environments) on Linux computers and to install the RedHat Package Manager.
Creating Universal Script Packages
How to create a Universal Script Package:
- Open the DSMC.
- Go to the Software Library.
- Start Create Application Package > Universal Script Package.
- Select Linux Shell Script (*.sh) as script type.
- Edit the script in the Packaging Workbench according to your requirements.
Universal Scripts also allow for using code snippets. Find more information on snippets in the DSM documentation.
- Assign the Universal Script Package to an installation target (computer).
Editing Universal Script Packages
You can edit your Universal Script Packages (USP) in the Packaging Workbench. Immediately after it was created, the USP's script part is empty.
With the help of excerpts from the USP used to install the Discovery Client Agent we would like to show you some options for controlling the process for Linux shell scripts and for employing DSM variables.
Shebang Header of a Linux Shell Script
By editing the script header (Shebang, #!/bin/sh) you can also package scripts in other script languages. However, the file extension must be *.sh. As a result, you may package and roll out Python or Perl scripts, for example, masked as Shell script. Make sure that the respective script interpreter (Python, Perl, etc.) is installed and configured on the installation target.
#!/bin/sh
Controlling the Installation and Uninstallation of Scripts
With the execution mode of the DSM Client Proxy you can control the installation and uninstallation of a USP.
if [ "%CLIENTPROXY.ExecutionMode%" == "Uninstall" ]
then
rpm -e `rpm -q -p "%RPMNAME%"`
else
rpm -i "%RPMNAME%"
fi
Mounting a Server Share on a Linux Client
You can access the DSM share on the management point from Linux as SMB share. Use the mount.cifs command in Linux for this purpose.
mkdir -p /mnt/disco
mount -t cifs -o user=%InstallationParameters.ShareUsername%,password=%InstallationParameters.DiscoverySharePwd% %InstallationParameters.DiscoveryServerShare /mnt/disco
Checking the Command Execution
You can use the result command to check whether a command has been executed successfully.
result=$?
if [ "$result" != "0" ]
then
echo "Error $result mounting the discovery share!" > _error.txt
exit -1
fi
Checking the Correct Linux Distribution
By checking the correct Linux distribution you can ensure that you have installed the right system environment on your Linux computer.
Use cat /etc/*{version,release} to get a reliable result you can check.
Copying Installation Files Locally To The Linux Client
mkdir -p %InstallationParameters.ClientInstallDir%
cp -f /mnt/disco/mpclient_${linuxDist}_i386.tar.gz %InstallationParameters.ClientInstallDir%
Unpacking the Archive Locally
cd %InstallationParameters.ClientInstallDir%
gunzip %InstallationParameters.ClientInstallDir%/mpclient_${linuxDist}_i386.tar.gz
tar -xf %InstallationParameters.ClientInstallDir%/mpclient_${linuxDist}_i386.tar
Copying the Initialization Files from the Server Share
cp -f /mnt/disco/xferwan.ini %InstallationParameters.ClientInstallDir%/mpclient_${linuxDist}_i386/xferwan.ini
cp -f /mnt/disco/client.xml %InstallationParameters.ClientInstallDir%/mpclient_${linuxDist}_i386/client.xml
cp -f /mnt/disco/kc-pub.pem %InstallationParameters.ClientInstallDir%/mpclient_${linuxDist}_i386/kc-pub.pem
Rolling Out the Installation on the Linux Client
cd %InstallationParameters.ClientInstallDir%/mpclient_${linuxDist}_i386
chmod +x ./deploy.sh
./deploy.sh
Unmounting the Server Share after Installation
umount /mnt/disco
System Cleanup
rm -Rf /disco
rm -Rf %InstallationParameters.ClientInstallDir%
Universal Software Set
You can combine several Universal Script Packages in a Universal Software Set, analogous to the usual Software Sets.
Included Templates and Packages
The Application Library > Application Templates folder in the Software Library contains RPM package samples. You can also create shell script packages by opening the Create an Application Package command from the context menu.
- Application Library › Application Templates › RPM Package Template
- OS Library › OS Actions › Post OS Action Package Install Discovery for Linux
Variable for the Installation Mode
The variable %CLIENTPROXY.ExecutionMode% returns the execution mode of the Client Proxy. This execution mode can take the status Install and Uninstall / Reinstall / Repair. By using this variable you can control the installation and uninstallation of a USP in your USP scripts.