Skip to content

Example of deployment scripts

The deployment can be divided into several steps:

  • the installation of the application;
  • the installation of the Outlook plugin (optional);
  • the creation of accounts.

WARNING

Environment variables vary between 32-bit and 64-bit versions of Windows.

Installation of the application:

powershell
# Required when running with administrator rights.
cd %~dp0

# Seald's installation on the station in a silent way
Seald-Setup-1.0.0.exe /allusers /S

# Creation of the Seald configuration directory.
mkdir %APPDATA%\Seald\

# Adding the essential configuration after a program installation.
echo {"autoUpdate": "disable", "windowsRegistry": "READ_ONLY"} > %APPDATA%\Seald\config.json

Installing the Outlook plugin:

TIP

The environment variable %CommonProgramFiles% must be replaced by %CommonProgramFiles(X86)% if the version of Outlook is in 64 bits.

powershell
# Required when running with administrator rights.
cd %~dp0

# Adding the Seald signature certificate
certutil -addstore TRUSTEDPUBLISHER "plugin-cert.cer"

# Installation of plugin prerequisites
.\vstor_redist.exe Setup /q /norestart #Installing VSTO redistributable
.\NDP472-KB4054530-x86-x64-x86-x64-AllOS-ENU.exe Setup /q /norestart # Installing.NET 4.7

# Plugin installation
# %CommonProgramFiles% if Outlook 32 bits. %CommonProgramFiles(X86)% if Outlook 64 bits
"%CommonProgramFiles%\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe" /s /I https://api.seald.io/outlook-v2/SealdOutlookPlugin.vsto # silent installation command for the outlook plugin

Smart Assistant rules deployment

It is possible to deploy a custom rule file for the Smart Assistant using the following command:

powershell
copy new-rules.js %APPDATA%\Seald\rules.js

TIP

For more information on writing and deploying the rule file, refer to this page

TIP

To activate the rules programmatically, refer to the plugin configuration help.

Create an account and launch:

TIP

The environment variable %ProgramFiles% must be replaced by %ProgramFilesX86% if the version of Windows is in 64 bits.

powershell
# Create an account. 
cd %ProgramFiles%\Seald
seald-cli create-account -d "Tim" -e tim@seald.io --email-validation 5f32fdb5-cb1d-4b1b-b981-d35f75e9376c:1b4e5537890f92cce85d86df22eergerg4 --accept-licence --force --accept-backup-keys

# Launch the application. The first argument (empty string) allows the process not to be stopped at the end of this script
start "" "%ProgramFiles%\Seald\Seald.exe"

Example of account creation script generation

This snippet script was written for Node.js 14 LTS, and is based on the csv@5.3.2 package in addition to the standard library. Adjustments are certainly necessary depending on the target environment:

js
const csv = require('csv')
const fs = require('fs')
const { promisify } = require('util')
const crypto = require('crypto')
const path = require('path')

const csvPath = './mails.csv' // CSV with the "Display name" in the first colum, and the "Email address" in the second column, separated with ";"
const domainValidationKeyId = process.env.DOMAIN_ID
const domainValidationKey = process.env.DOMAIN_KEY
const outputDir = './out'

try {
  fs.rmdirSync(outputDir, { recursive: true })
} catch (err) {
  console.warn(err)
  console.warn('directory outputDir does not exist')
} finally {
  fs.mkdirSync(outputDir, { recursive: true })
}

const random = (size = 1000) => crypto.randomBytes(size)

const scrypt = (buff, salt) => new Promise((resolve, reject) => {
  crypto.scrypt(
    buff,
    salt,
    64, // 64 bytes for a 256 bits key (there is also a signing key for HMAC)
    { N: 16384, r: 8, p: 1 },
    (err, key) => {
      if (err) reject(err)
      else resolve(key)
    }
  )
})

const generate = async (email, domainValidationKeyId, domainValidationKey) => {
  const nonce = random(32).toString('hex')
  const token = (await scrypt(
    Buffer.from(`${email}-${domainValidationKey}`, 'utf8'),
    Buffer.from(nonce, 'utf8')
  )).toString('hex')
}

const makeScript = (displayName, emailAddress) =>
  `"%LOCALAPPDATA%\\Programs\\Seald\\Seald.exe" --headless create-account -d "${displayName.replace('"', '\\"')}" -e "${emailAddress.replace('"', '\\"')}" --email-validation ${generate(emailAddress, domainValidationKeyId, domainValidationKey)} --accept-backup-keys --accept-licence --force
start "" "%LOCALAPPDATA%\\Programs\\Seald\\Seald.exe"`

const main = async () => {
  const result = await promisify(csv.parse)(fs.readFileSync(csvPath), { delimiter: ';' })
  result.shift() // remove header
  for (const [displayName, emailAddress] of result) {
    // Writes indiviual script for each user to be executed on each machine
    fs.writeFileSync(path.join(outputDir, emailAddress + '.bat'), makeScript(displayName, emailAddress).replace('\n', '\r\n'))
  }
}

main()