Automated OIBus Installation
Objective
This automated installation procedure enables efficient, large-scale OIBus deployments by combining secure installation with standardized initial configuration.
Key Benefits:
- Scalable deployment across multiple machines
- Consistent configurations from first launch
- Immediate remote management via OIAnalytics
- Reduced manual effort and minimized setup errors
Perfect for enterprise environments, industrial implementations, or any scenario requiring multiple OIBus instances with uniform configurations.
Disk Image Preparation
Sample Implementation
- Extract the OIBus installation ZIP to
C:\Program Files\OIBus - Add your installation script to this directory
- Configure the script to run on startup (only if OIBus isn't already installed)
- Create a disk image (without OIBus installed) for deployment
Additional curl commands can be added to the installation script for initial setup. Specific configurations will be managed through OIAnalytics.
Sample Installation Script
The following script automates the installation, startup, and registration of OIBus. The OIANALYTICS_URL can be
customized to point to your OIAnalytics instance. If you don’t use OIAnalytics, you can omit the registration step.
@echo off
:: This script checks if OIBus is already installed. If not, it waits for the network, installs OIBus, waits for the service to start, and registers it.
:: Path to the installation script (assumes it is in the same folder as this script)
:: Set the path before et local
set INSTALL_SCRIPT_PATH=%~dp0install.bat
setlocal enabledelayedexpansion
set USERNAME=admin
set PASSWORD=pass
set OIANALYTICS_URL=https://instance.optimistik.fr/
:: Default values
set n=OIBus
set c=C:\OIBusData
:PARSE_PARAMETERS
if "%~1"=="" goto PARSE_PARAMETERS_DONE
if "%~1"=="-n" (
set "n=%~2"
shift
shift
goto PARSE_PARAMETERS
)
if "%~1"=="-c" (
set "c=%~2"
shift
shift
goto PARSE_PARAMETERS
)
shift
goto PARSE_PARAMETERS
:PARSE_PARAMETERS_DONE
:: Check if running as Admin
net session >nul 2>&1
if %errorLevel% neq 0 (
echo This script must be run as Administrator.
exit /b 1
)
:: Check if OIBus service is already installed
sc query "%n%" >nul 2>&1
if %errorlevel% equ 0 (
echo %n% service is already installed. Skipping installation.
goto END
)
:: Wait for the network service to be running
echo Waiting for the network service to start...
:WAIT_FOR_NETWORK
sc query "Dnscache" | find "RUNNING" >nul
if %errorlevel% neq 0 (
timeout /t 5 >nul
goto WAIT_FOR_NETWORK
)
echo Network service is running.
:: Create data directory if it doesn't exist
if not exist "%c%" mkdir "%c%"
:: Call the installation script, passing the data directory as a parameter
call "%INSTALL_SCRIPT_PATH%" -c "%c%" -n "%n%"
if %errorlevel% neq 0 (
echo Error: %n% installation failed.
exit /b %errorlevel%
)
:: Wait for the OIBus service to be running
echo Waiting for %n% service to start...
:WAIT_FOR_OIBUS
for /f "tokens=3 delims=: " %%H in ('sc query "%n%" ^| findstr "STATE"') do (
if /I "%%H" NEQ "RUNNING" (
timeout /t 5 >nul
goto WAIT_FOR_OIBUS
)
)
echo %n% service is now running.
:: Wait for the OIBus web server to be up
echo Waiting for %n% web server to be up...
:WAIT_FOR_WEB
curl --silent --output NUL --fail http://localhost:2223/api
if %errorlevel% neq 0 (
timeout /t 5 >nul
goto WAIT_FOR_WEB
)
echo %n% web server is now up.
:: Execute the curl command to create North connector
echo Creating North connector...
curl --location --user %USERNAME%:%PASSWORD% "http://localhost:2223/api/north" ^
--header "Content-Type: application/json" ^
--header "Accept: application/json" ^
--data "{\"name\": \"North OIAnalytics\", \"type\": \"oianalytics\", \"description\": \"\", \"enabled\": true, \"settings\": {\"useOiaModule\": true, \"timeout\": 15000, \"compress\": false}, \"caching\": {\"archive\": {\"retentionDuration\": 0, \"enabled\": false}, \"error\": {\"retentionDuration\": 0, \"retryCount\": 3, \"retryInterval\": 5000}, \"throttling\": {\"maxNumberOfElements\": 10000, \"maxSize\": 0, \"runMinDelay\": 200}, \"trigger\": {\"numberOfFiles\": 1, \"numberOfElements\": 1, \"scanModeName\": \"Every minute\", \"scanModeId\": \"\"}}, \"subscriptions\": [], \"transformers\": []}"
echo.
if %errorlevel% neq 0 (
echo Error: Failed to create North connector.
exit /b %errorlevel%
)
:: Execute the curl command to create South connector
echo Creating South connector...
curl --location --user %USERNAME%:%PASSWORD% "http://localhost:2223/api/south" ^
--header "Content-Type: application/json" ^
--header "Accept: application/json" ^
--data "{\"name\": \"Modbus\", \"type\": \"modbus\", \"description\": \"\", \"enabled\": true, \"settings\": {\"host\": \"127.0.0.1\", \"port\": 502, \"connectTimeout\": 10000, \"retryInterval\": 10000, \"slaveId\": 1, \"addressOffset\": \"modbus\", \"endianness\": \"big-endian\", \"swapBytesInWords\": false, \"swapWordsInDWords\": false}, \"items\": []}"
echo.
if %errorlevel% neq 0 (
echo Error: Failed to create South connector.
exit /b %errorlevel%
)
:: Execute the curl command to create a scan mode
echo Creating scan mode...
curl --location --user %USERNAME%:%PASSWORD% "http://localhost:2223/api/scan-modes" ^
--header "Content-Type: application/json" ^
--header "Accept: application/json" ^
--data "{\"name\": \"Daily Backup Scan\", \"description\": \"Scans for new backup data every day at midnight\", \"cron\": \"0 0 * * *\"}"
echo.
if %errorlevel% neq 0 (
echo Error: Failed to create scan mode.
exit /b %errorlevel%
)
:: Execute the curl command to register OIBus
echo Registering OIBus...
curl --location --user %USERNAME%:%PASSWORD% "http://localhost:2223/api/oianalytics/register" ^
--header "Content-Type: application/json" ^
--data "{\"host\": \"%OIANALYTICS_URL%\", \"useProxy\": false, \"proxyUrl\": \"\", \"proxyUsername\": \"\", \"proxyPassword\": \"\", \"acceptUnauthorized\": false, \"commandRefreshInterval\": 60, \"commandRetryInterval\": 10, \"messageRetryInterval\": 10, \"commandPermissions\": {\"setpoint\": true, \"testNorthConnection\": true, \"deleteNorth\": true, \"updateNorth\": true, \"createNorth\": true, \"testSouthItem\": true, \"testSouthConnection\": true, \"createOrUpdateSouthItemsFromCsv\": true, \"deleteSouth\": true, \"updateSouth\": true, \"createSouth\": true, \"testHistorySouthItem\": true, \"testHistorySouthConnection\": true, \"testHistoryNorthConnection\": true, \"createOrUpdateHistoryItemsFromCsv\": true, \"deleteHistoryQuery\": true, \"updateHistoryQuery\": true, \"createHistoryQuery\": true, \"deleteCertificate\": true, \"updateCertificate\": true, \"createCertificate\": true, \"deleteIpFilter\": true, \"updateIpFilter\": true, \"createIpFilter\": true, \"deleteScanMode\": true, \"updateScanMode\": true, \"createScanMode\": true, \"updateRegistrationSettings\": true, \"updateEngineSettings\": true, \"regenerateCipherKeys\": true, \"restartEngine\": true, \"updateVersion\": true}}"
echo.
if %errorlevel% neq 0 (
echo Error: Failed to register OIBus.
exit /b %errorlevel%
)
:END
For a complete list of available endpoints, visit the API documentation page.
Usage
.\mass-install.bat -n "OIBus" -c "C:\OIBusData"