Category / Section
How to move patch files into the installation directories and restart services automatically?
Published:
Overview
The Patch Controller (patchctl) scripts automate patch management for applications across Windows and Linux environments. These scripts simplify the process of:
- Backing up existing application files (e.g., DLLs).
- Applying patch files to update components.
- Rolling back to the previous state using backups.
- Restarting associated services (IIS App Pools on Windows, systemd services on Linux).
Windows Script
Requirements
- Administrator privileges.
- PowerShell 5.1 or higher.
patch.jsonconfiguration file in the same directory.
Usage Explained
For Windows, the patch controller script is a PowerShell script named patchctl.ps1. It supports two main operations:
- Update (Apply Patch)
Command:.\patchctl.ps1 -patch updateWhat it does:- Reads the
patch.jsonconfiguration file. - Creates a backup of the existing application files (DLLs) in a versioned folder.
- Copies the new patch files from the
/patchfolder to the specified destination paths. - Restarts the associated IIS App Pools to apply changes.
- Reads the
Sample for the Bold BI service
Bold BI Api Service
- Rollback (Restore Previous State)
Command:.\patchctl.ps1 -patch rollbackWhat it does:- Restores the original files from the backup folder created during the update process.
- Restarts the IIS App Pools to revert the application to its previous state.
Sample for the Bold BI service
Bold BI Api Service
Features
- Backup: Saves current DLLs to a versioned folder.
- Update: Replaces DLLs with patch files.
- Rollback: Restores DLLs from backup.
- Service Restart: Restarts IIS App Pools.
Linux Script
Requirements
- Root privileges (via
sudo). - Bash shell.
- Python 3 (for JSON parsing).
patch.jsonandpatch/folder in the same directory.
Usage Explained
For Linux, the patch controller script is a PowerShell script named patchctl.sh. It supports two main operations:
- Update (Apply Patch)
Command:sudo ./patchctl.sh --patch updateWhat it does:- Reads the
patch.jsonconfiguration file. - Creates a versioned backup of the existing application files.
- Copies the new patch files from the
/patchfolder to the specified destination directories. - Restarts the associated systemd services to apply the changes.
- Reads the
- Rollback (Restore Previous State)
Command:sudo ./patchctl.sh --patch rollbackWhat it does:- Restores the original files from the backup folder created during the update process.
- Restarts the systemd services to revert the application to its previous state.
Features
- Backup: Copies existing files to a versioned backup folder.
- Update: Replaces files with patch versions.
- Rollback: Restores files from backup.
- Service Restart: Uses
systemctlto restart services.
Configuration File: patch.json
Structure
{
"patchVersion": "14.1.10_11032025_123411",
"bi_api": {
"source": [
"patch/BoldBi.Ai.Core.dll"
],
"destination": [
"bi/dataservice",
"ai/aiservice"
],
"service": [
"BoldBiDesigner",
"BoldBIApi"
]
}
}Notes
- source: Patch file names.
- destination: Relative paths under install root.
- service: App Pool names (Windows) or systemd service names (Linux).
Best Practices
- Verify
patch.jsonbefore running the script. - Ensure patch files exist in the
/patchfolder. - Use versioned
patchVersionto avoid overwriting backups. - Run rollback only after an update has been performed.