opsi-script libraries

opsi-script libraries from uib

Documentation of opsi-script libraries that are part of the opsiscript / opsi-script and are mantained by the uib gmbh

Documentation of opsi library: uib_backend.opsiscript

Documentation of local function setProductsToUninstall

Definition

setProductsToUninstall($productlist$ : stringlist) : string

Description

Sets for the given list of opsi productIds the action request to 'uninstall'

  • Parameter: $productlist$

    • Type: Stringlist - Calltype: CallByValue

    • Parameter $productlist$ Description:
      List of opsi product Ids

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 22.08.2019

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[actions]
DefStringlist $productlist$

set $productlist$ = CreateStringList("opsi-logviewer","opsi-configed")
if not(stringtobool(setProductsToUninstall($productlist$)))
  comment "call of setProductsToUninstall failed"
endif

Documentation of local function setProductsToSetup

Definition

setProductsToSetup($productlist$ : stringlist) : string

Description

Sets for the given list of opsi productIds the action request to 'setup' (try also resolving the dependencies)

  • Parameter: $productlist$

    • Type: Stringlist - Calltype: CallByValue

    • Parameter $productlist$ Description:
      List of opsi product Ids

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode) Works without resolving dependencies for use in WAN mode while withdependencies is missing in opsiclientd

  • Author: detlef oertel

  • Date: 05.11.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[actions]
DefStringlist $productlist$

set $productlist$ = CreateStringList("opsi-logviewer","opsi-configed")
if not(stringtobool(setProductsToSetup($productlist$)))
  comment "call of setProductsToSetup failed"
endif

Documentation of local function handle_setup_after_property

Definition

handle_setup_after_property($propname$ : string) : string

Description

The given parameter $propname$ has to be the name of a property that holds a list of productIds The function takes this list If it is only one string and this string contains ',' it will be splitted to a list Sets for the given list of opsi productIds the action request to 'setup' (try also resolving the dependencies)

  • Parameter: $propname$

    • Type: String - Calltype: CallByValue

    • Parameter $propname$ Description:
      List of opsi product Ids

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 26.05.2020

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[actions]
DefVar $propname$

if not(stringtobool(handle_setup_after_property($propname$)))
  comment "call of handle_setup_after_property failed"
endif

Documentation of local function getInstalledLocalbootProducts

Definition

getInstalledLocalbootProducts(ref $productlist$ : stringlist) : string

Description

Gets a list of productIds which are

  • known to the client (productOnClient object exists)

  • and localboot products. to 'setup' (also resolving the dependencies)

  • Parameter: $productlist$

    • Type: Stringlist - Calltype: CallByReference

    • Parameter $productlist$ Description:
      Output list of opsi product Ids that were be found

    • Parameter $productlist$ Advice:
      May be empty

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 20.4.2018

  • Email: d.oertel@uib.de

  • Version: 1.1

  • Copyright: AGPLv3

Example:

if stringToBool(getInstalledLocalbootProducts($resultlist$))
	comment "getInstalledLocalbootProducts successful finished"
else
	LogError "getInstalledLocalbootProducts failed"
endif
set $tmplist$ = getListContainingList($baseproducts$,$resultlist$)
if stringToBool(compareLists($tmplist$,$baseproducts$))
	comment "check installed products successful finished"
else
	LogError "check installed products failed"
endif
comment " now install and rest products ...."
if stringToBool(setProductsToSetup($resetproducts$))
	comment "setProductsToSetup successful finished"
else
	LogError "setProductsToSetup failed"
endif

Documentation of local function delOpsiPoc

Definition

delOpsiPoc($donotdelList$ : stringlist) : string

Description

Delete all productOnClientObjects for this client and only for localboot products and not for products that are included in the $donotdelList$ parameter

  • Parameter: $donotdellist$

    • Type: Stringlist - Calltype: CallByValue

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 17.4.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

set $opsiMetaDataFile$ = $targetDir$+"\poc.json"
if Fileexists($opsiMetaDataFile$)
	comment "Delete existing meta data ...."
	set $tmplist$ = createStringList ("opsi-vhd-tester","opsi-vhd-control","opsi-vhd-auto-upgrade")
	if stringToBool(delOpsiPoc($tmplist$))
		comment "Delete existing meta data successful finished"
	else
		LogError "Delete existing meta data failed"
	endif
	comment "Restore existing meta data ...."
	if stringToBool(restoreOpsiPoc($opsiMetaDataFile$))
		comment "Restore existing meta data successful finished"
	else
		LogError "Restore existing meta data failed"
	endif
else
	comment "No meta data existing - creating it...."
	if stringToBool(backupOpsiPoc($opsiMetaDataFile$))
		comment "Backup meta data successful finished"
	else
		LogError "Backup meta data failed"
	endif
endif

Documentation of local function backupOpsiPoc

Definition

backupOpsiPoc($filename$ : string) : string

Description

Get all localboot productOnClient objects for this client and write it to the json file $filename$

  • Parameter: $filename$

    • Type: String - Calltype: CallByValue

    • Parameter $filename$ Description:
      Complete name of the file to create

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • References: [restoreOpsiPoc] [delOpsiPoc]

  • Author: detlef oertel

  • Date: 17.4.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

see delOpsiPoc

Documentation of local function restoreOpsiPoc

Definition

restoreOpsiPoc($filename$ : string) : string

Description

Load productOnClient objects from $filename$ and write it to to the server

  • Parameter: $filename$

    • Type: String - Calltype: CallByValue

    • Parameter $filename$ Description:
      Complete name of the file to read

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 17.4.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

see delOpsiPoc

Documentation of local function getInstalledLocalbootProductsWithVersion

Definition

getInstalledLocalbootProductsWithVersion(ref $productlist$ : stringlist) : string

Description

Get all localboot productOnClient objects for this client and create a key/value list in the format <productId>=<productVersion>-<packageVersion> This list is be written to $productlist$

  • Parameter: $productlist$

    • Type: Stringlist - Calltype: CallByReference

    • Parameter $productlist$ Description:
      The key/value list with all <productId>=<productVersion>-<packageVersion> of the client

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 17.4.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

comment "check for installed products ...."
if stringToBool(getInstalledLocalbootProductsWithVersion($installedproducts$))
	comment "getInstalledLocalbootProducts successful finished"
else
	LogError "getInstalledLocalbootProducts failed"
endif
comment "check for installable products ...."
if stringToBool(getInstallableLocalbootProductsWithVersion($possibleproducts$))
	comment "getInstallableLocalbootProductsWithVersion successful finished"
else
	LogError "getInstallableLocalbootProductsWithVersion failed"
endif
comment "fill $upgradeproducts$ .."
set $tmplist$ = getKeyList($installedproducts$)
set $possibleproducts$ = getSubListByKey($tmplist$,$possibleproducts$)
for %aktprod% in $installedproducts$ do sub_find_updatable_products

Documentation of local function getInstallableLocalbootProductsWithVersion

Definition

getInstallableLocalbootProductsWithVersion(ref $productlist$ : stringlist) : string

Description

Get all localboot productOnDepot objects for the depot of this client and create a key/value list in the format <productId>=<productVersion>-<packageVersion> This list is be written to $productlist$

  • Parameter: $productlist$

    • Type: Stringlist - Calltype: CallByReference

    • Parameter $productlist$ Description:
      The key/value list with all <productId>=<productVersion>-<packageVersion> of the depot of this client

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 17.4.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

see getInstalledLocalbootProductsWithVersion

Documentation of opsi library: uib_bootutils.opsiscript

Documentation of local function delFromWindowsBootmanager

Definition

delFromWindowsBootmanager($bootlabel$ : string) : string

Description

Deletes the boot entry given given by the parameter $bootlabel$ from Windows boot manager by using bcdedit

Example:

[actions]
DefStringlist $productlist$

set $productlist$ = CreateStringList("opsi-logviewer","opsi-configed")
if not(stringtobool(setProductsToSetup($productlist$)))
  comment "call of setProductsToSetup failed"
endif

Documentation of local function getWinBcdbootGuid

Definition

getWinBcdbootGuid($bootlabel$ : string) : string

Description

Get the boot entry GUID for the label given by the parameter $bootlabel$ from Windows boot manager by using bcdedit

Example:

Message "get windows boot guid ...."
set $windows_bcd_guid$ = getWinBcdbootGuid("WINDOWS.vhdx")

Documentation of local function getUefiBcdbootGuid

Definition

getUefiBcdbootGuid($bootlabel$ : string) : string

Description

Get the boot entry GUID for the label given by the parameter $bootlabel$ from Windows boot manager by using bcdedit

Example:

if runningonUefi
	set $peuefiguid$ = getUefiBcdbootGuid("opsitempwinpe")
	set $exitcode$ = getlastexitcode
	if $exitcode$ = "0"
		if not ($peuefiguid$ = "")
			shellCall("bcdedit /delete "+$peuefiguid$)
		endif
	endif
endif

Documentation of local function bootNextToWinLabel

Definition

bootNextToWinLabel($bootlabel$ : string) : string

Description

Sets the Windows bootmanager to boot next to the label given by the parameter $bootlabel$ from Windows boot manager by using bcdedit

  • Parameter: $bootlabel$

    • Type: String - Calltype: CallByValue

    • Parameter $bootlabel$ Description:
      Windows boot manager entry label found in 'bcdedit /v'

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Winows only

  • References: [delFromWindowsBootmanager] [getUefiBcdbootGuid] [bootNextToUefiLabel]

  • Author: detlef oertel

  • Date: 17.5.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

See bootNextToUefiLabel

Documentation of local function bootNextToUefiLabel

Definition

bootNextToUefiLabel($bootlabel$ : string) : string

Description

Sets the uefi bootmanager to boot next to the label given by the parameter $bootlabel$ from uefi boot manager by using bcdedit

  • Parameter: $bootlabel$

    • Type: String - Calltype: CallByValue

    • Parameter $bootlabel$ Description:
      UEFI boot manager entry label found in 'bcdedit /enum firmware'

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Winows only

  • References: [delFromWindowsBootmanager] [getUefiBcdbootGuid] [bootNextToUefiLabel]

  • Author: detlef oertel

  • Date: 17.5.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

Message "Enable PE boot...."
if runningonuefi
	set $bootLabel$ = "opsitempwinpe"
	if not(stringToBool(bootNextToUefiLabel($bootLabel$)))
		logerror "Activating peboot is failed"
		isFatalError "failed peboot"
	endif
else
	set $bootLabel$ = "ramdisk=[boot]\sources\boot.wim"
	if not(stringToBool(bootNextToWinLabel($bootLabel$)))
		logerror "Activating peboot is failed"
		;isFatalError "failed peboot"
	endif
endif

Documentation of local function getDiskUuid

Definition

getDiskUuid($disknumber$ : string , $tmpdir$ : string ) : string

Description

Gets the disk uuid for the disk with the number $disknumber$ by using diskpart. The temporary diskpart script is written to $tmpdir$

  • Parameter: $disknumber$

    • Type: String - Calltype: CallByValue

    • Parameter $disknumber$ Description:
      UEFI boot manager entry label found in 'bcdeit /enum firmware'

  • Parameter: $tmpdir$

    • Type: String - Calltype: CallByValue

    • Parameter $tmpdir$ Description:
      Temporary directory to use

    • Parameter $tmpdir$ Advice:
      Directory must exist

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Winows only

  • References: [enablePEPartition]

  • Author: detlef oertel

  • Date: 17.5.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

for %disk% = "0" to calculate($diskcount1$+" -1") do set $aktdisklist$ = addtolist($aktdisklist$,getDiskUuid("%disk%", "x:")+"=%disk%")
set $disk$ = getvalue($diskuuid$,$aktdisklist$)

Documentation of local function enablePEPartition

Definition

enablePEPartition($disknumber$ : string , $partitionNumber$ : string, $pepartletter$ : string, $useGpt$ : string) : string

Description

Try to make the partition $partitionNumber$ on the disk $disknumber$ visible, bootable and give and give it the Windows disk letter $pepartletter$ by using diskpart or powershell

  • Parameter: $disknumber$

    • Type: String - Calltype: CallByValue

    • Parameter $disknumber$ Description:
      Number of the disk where we look for the partition

    • Parameter $disknumber$ Advice:
      First disk = 0

  • Parameter: $partitionnumber$

    • Type: String - Calltype: CallByValue

    • Parameter $partitionnumber$ Description:
      Number of the partition on the given disk

    • Parameter $partitionnumber$ Advice:
      First partition = 1

  • Parameter: $pepartletter$

    • Type: String - Calltype: CallByValue

    • Parameter $pepartletter$ Description:
      Windows disk letter that the given partition should have

  • Parameter: $usegpt$

    • Type: String - Calltype: CallByValue

    • Parameter $usegpt$ Description:
      Should we expect GPT or MBR partitions ('true' or 'false')

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Winows only, works in PE

  • References: [getDiskUuid]

  • Author: detlef oertel

  • Date: 17.5.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

Message "Enable PE partition...."
if not(stringToBool(enablePEPartition($disknumber$, $swapPartitionNumber$, $pepartletter$, $useGpt$)))
	LogError "Could not activate PE partition ..."
	isFatalError "failed not activate PE partition"
endif

if not (isDriveReady($pePartLetter$))
	logerror "PE drive "+$pePartLetter$+": not ready"
	isFatalError "PE drive "+$pePartLetter$+": not ready"
	set $errorList$ = addtolist($errorList$, " failed pe_drive_ready")
	set $fatal_error$ = "true"
endif

Documentation of opsi library: uib_exitcode.opsiscript

Documentation of local function isMsiExitcodeFatal

Definition

isMsiExitcodeFatal($exitcode$ : string, $allowRebootRequest$ : string, ref $ErrorString$ : string) : string

Description

Evaluates the given $exitcode$ as MSI Error and and gives back a resulting error message on $ErrorString$ If the Error require a reboot the given parameter $allowRebootRequest$ is used to decide if a 'ExitWindows /Reboot' is called or not

Example:

[actions]
DefVar $ExitCode$
DefVar $ErrorString$
(...)
set $ExitCode$ = getlastexitcode
if stringtobool(isMsiExitcodeFatal($exitcode$, "true", $ErrorString$ ))
	LogError $ErrorString$
	isfatalerror $ErrorString$
else
	Comment $ErrorString$
endif

Documentation of local function isMsiExitcodeFatal_short

Definition

isMsiExitcodeFatal_short($exitcode$ : string, $allowRebootRequest$ : string, ref $ErrorString$ : string) : string

Description

Evaluates the given $exitcode$ as MS Error and and gives back a resulting error message on $ErrorString$ if the exit code is well known. For full list of exit dodes use isMsiExitcodeFatal If the Error require a reboot the given parameter $allowRebootRequest$ is used to decide if a 'ExitWindows /Reboot' is called or not

Documentation of local function isMsExitcodeFatal_short

Definition

isMsExitcodeFatal_short($exitcode$ : string, $allowRebootRequest$ : string, ref $ErrorString$ : string) : string

Description
  • Parameter: $exitcode$

    • Type: String - Calltype: CallByValue

  • Parameter: $allowrebootrequest$

    • Type: String - Calltype: CallByValue

  • Parameter: $errorstring$

    • Type: String - Calltype: CallByReference

  • Author: detlef oertel

  • Date: 14.05.2019

  • Email: d.oertel@uib.de

  • Version: 1.0.2

  • Copyright: AGPLv3

Documentation of local function isAdvancedMsiExitcodeFatal

Definition

isAdvancedMsiExitcodeFatal($exitcode$ : string, $allowRebootRequest$ : string, ref $ErrorString$ : string) : string

Description

Please note: Import complete file uib_exitcode (not only isAdvancedMsiExitcodeFatal) Evaluates the given $exitcode$ as AdvancedMsi Error and and gives back a resulting error message on $ErrorString$ It is also checked if the exit code is one from the embedded msi. There for is isMsiExitcodeFatal used If the Error require a reboot the given parameter $allowRebootRequest$ is used to decide if a 'ExitWindows /Reboot' is called or not

  • Parameter: $exitcode$

    • Type: String - Calltype: CallByValue

    • Parameter $exitcode$ Description:
      Exit code given by AdvancedMsi

  • Parameter: $allowrebootrequest$

    • Type: String - Calltype: CallByValue

    • Parameter $allowrebootrequest$ Description:
      Should we call 'ExitWindows /Reboot' if the exit code require this ('true' or 'false')

  • Parameter: $errorstring$

    • Type: String - Calltype: CallByReference

    • Parameter $errorstring$ Description:
      Here we get the error string that belongs to the given exit code

  • Returns: Returns string "true" if the exit code points to a critical error. Returns string "true" if the exit code is not a number (not valid). Returns string "false" if the exit code is valid but not critical.

  • OnError: Returns string "true"

  • SpecialCase: Winows only

  • References: [isMsiExitcodeFatal] [isAdvancedMsiExitcodeFatal] [isInnoExitcodeFatal] [isInstallshieldExitcodeFatal] [isNsisExitcodeFatal]

  • Author: detlef oertel

  • Date: 14.05.2019

  • Email: d.oertel@uib.de

  • Version: 1.0.2

  • Copyright: AGPLv3

Documentation of local function isInnoExitcodeFatal

Definition

isInnoExitcodeFatal($exitcode$ : string, $allowRebootRequest$ : string, ref $ErrorString$ : string) : string

Description

Evaluates the given $exitcode$ as Inno Error and and gives back a resulting error message on $ErrorString$ If the Error require a reboot the given parameter $allowRebootRequest$ is used to decide if a 'ExitWindows /Reboot' is called or not

  • Parameter: $exitcode$

    • Type: String - Calltype: CallByValue

    • Parameter $exitcode$ Description:
      Exit code given by Inno

  • Parameter: $allowrebootrequest$

    • Type: String - Calltype: CallByValue

    • Parameter $allowrebootrequest$ Description:
      Should we call 'ExitWindows /Reboot' if the exit code require this ('true' or 'false')

  • Parameter: $errorstring$

    • Type: String - Calltype: CallByReference

    • Parameter $errorstring$ Description:
      Here we get the error string that belongs to the given exit code

  • Returns: Returns string "true" if the exit code points to a critical error. Returns string "true" if the exit code is not a number (not valid). Returns string "false" if the exit code is valid but not critical.

  • OnError: Returns string "true"

  • SpecialCase: Winows only

  • References: [isMsiExitcodeFatal] [isAdvancedMsiExitcodeFatal] [isInnoExitcodeFatal] [isInstallshieldExitcodeFatal] [isNsisExitcodeFatal]

  • Author: detlef oertel

  • Date: 17.5.2018

  • Email: d.oertel@uib.de

  • Version: 1.0.2

  • Copyright: AGPLv3

Documentation of local function isInstallshieldExitcodeFatal

Definition

isInstallshieldExitcodeFatal($exitcode$ : string, $allowRebootRequest$ : string, ref $ErrorString$ : string) : string

Description

Please note: Import complete file uib_exitcode (not only isAdvancedMsiExitcodeFatal) Evaluates the given $exitcode$ as Installshield Error and and gives back a resulting error message on $ErrorString$ It is also checked if the exit code is one from the embedded msi. There for is isMsiExitcodeFatal used If the Error require a reboot the given parameter $allowRebootRequest$ is used to decide if a 'ExitWindows /Reboot' is called or not

  • Parameter: $exitcode$

    • Type: String - Calltype: CallByValue

    • Parameter $exitcode$ Description:
      Exit code given by Installshield

  • Parameter: $allowrebootrequest$

    • Type: String - Calltype: CallByValue

    • Parameter $allowrebootrequest$ Description:
      Should we call 'ExitWindows /Reboot' if the exit code require this ('true' or 'false')

  • Parameter: $errorstring$

    • Type: String - Calltype: CallByReference

    • Parameter $errorstring$ Description:
      Here we get the error string that belongs to the given exit code

  • Returns: Returns string "true" if the exit code points to a critical error. Returns string "true" if the exit code is not a number (not valid). Returns string "false" if the exit code is valid but not critical.

  • OnError: Returns string "true"

  • SpecialCase: Winows only

  • References: [isMsiExitcodeFatal] [isAdvancedMsiExitcodeFatal] [isInnoExitcodeFatal] [isInstallshieldExitcodeFatal] [isNsisExitcodeFatal]

  • Author: detlef oertel

  • Date: 14.05.2019

  • Email: d.oertel@uib.de

  • Version: 1.0.2

  • Copyright: AGPLv3

Documentation of local function isNsisExitcodeFatal

Definition

isNsisExitcodeFatal($exitcode$ : string, $allowRebootRequest$ : string, ref $ErrorString$ : string) : string

Description

Evaluates the given $exitcode$ as Nsis Error and and gives back a resulting error message on $ErrorString$ If the Error require a reboot the given parameter $allowRebootRequest$ is used to decide if a 'ExitWindows /Reboot' is called or not

  • Parameter: $exitcode$

    • Type: String - Calltype: CallByValue

    • Parameter $exitcode$ Description:
      Exit code given by Nsis

  • Parameter: $allowrebootrequest$

    • Type: String - Calltype: CallByValue

    • Parameter $allowrebootrequest$ Description:
      Should we call 'ExitWindows /Reboot' if the exit code require this ('true' or 'false')

  • Parameter: $errorstring$

    • Type: String - Calltype: CallByReference

    • Parameter $errorstring$ Description:
      Here we get the error string that belongs to the given exit code

  • Returns: Returns string "true" if the exit code points to a critical error. Returns string "true" if the exit code is not a number (not valid). Returns string "false" if the exit code is valid but not critical.

  • OnError: Returns string "true"

  • SpecialCase: Winows only

  • References: [isMsiExitcodeFatal] [isAdvancedMsiExitcodeFatal] [isInnoExitcodeFatal] [isInstallshieldExitcodeFatal] [isNsisExitcodeFatal]

  • Author: detlef oertel

  • Date: 17.5.2018

  • Email: d.oertel@uib.de

  • Version: 1.0.2

  • Copyright: AGPLv3

Documentation of local function isGenericExitcodeFatal

Definition

isGenericExitcodeFatal($exitcode$ : string, $allowRebootRequest$ : string, ref $ErrorString$ : string) : string

Description

Evaluates the given $exitcode$ as Generic Error and and gives back a resulting error message on $ErrorString$ If the Error require a reboot the given parameter $allowRebootRequest$ is used to decide if a 'ExitWindows /Reboot' is called or not

  • Parameter: $exitcode$

    • Type: String - Calltype: CallByValue

    • Parameter $exitcode$ Description:
      Exit code given

  • Parameter: $allowrebootrequest$

    • Type: String - Calltype: CallByValue

    • Parameter $allowrebootrequest$ Description:
      Should we call 'ExitWindows /Reboot' if the exit code require this ('true' or 'false')

  • Parameter: $errorstring$

    • Type: String - Calltype: CallByReference

    • Parameter $errorstring$ Description:
      Here we get the error string that belongs to the given exit code

  • Returns: Returns string "true" if the exit code points to a critical error. Returns string "true" if the exit code is not a number (not valid). Returns string "false" if the exit code is valid but not critical.

  • OnError: Returns string "true"

  • References: [isMsiExitcodeFatal] [isAdvancedMsiExitcodeFatal] [isInnoExitcodeFatal] [isInstallshieldExitcodeFatal] [isNsisExitcodeFatal]

  • Author: detlef oertel

  • Date: 16.2.2021

  • Email: d.oertel@uib.de

  • Version: 1.0.2

  • Copyright: AGPLv3

Documentation of local function boolToGenericExitcode

Definition

boolToGenericExitcode($BoolString$ : string) : string

Description

Converts the given $BoolString$ as Generic Exitcode: "True": returns "0" "False": returns "1" is used to decide if a 'ExitWindows /Reboot' is called or not

  • Parameter: $boolstring$

    • Type: String - Calltype: CallByValue

    • Parameter $boolstring$ Description:
      boolean string given

    • Parameter $boolstring$ Advice:
      if not "true" default result is "1"

  • Returns: Returns string "0" or "1"

  • OnError: Returns string "1"

  • Author: detlef oertel

  • Date: 08.3.2021

  • Email: d.oertel@uib.de

  • Version: 1.0.2

  • Copyright: AGPLv3

Documentation of opsi library: uib_strlistutils.opsiscript

Documentation of local function compareLists

Definition

compareLists($list1$ : stringlist, $list2$ : stringlist) : string

Description

Checks if two string lists are completely identical or not. The check is not case sensitive.

  • Parameter: $list1$

    • Type: Stringlist - Calltype: CallByValue

    • Parameter $list1$ Description:
      First stringlist to compare

  • Parameter: $list2$

    • Type: Stringlist - Calltype: CallByValue

    • Parameter $list2$ Description:
      Second stringlist (to compare with first)

  • Returns: Returns string "true" if the given lists are identical. Returns string "false" if the given lists are not identical

  • OnError: Returns string "false"

  • Author: detlef oertel

  • Date: 17.5.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

set $tmplist$ = getListContainingList($baseproducts$,$resultlist$)
if stringToBool(compareLists($tmplist$,$baseproducts$))
	comment "check installed products successful finished"
else
	LogError "check installed products failed"
	set $errorList$ = addtolist($errorList$, "check installed products failed")
	;set $fatal_error$ = "true"
endif

Documentation of opsi library: uib_driver_install.opsiscript

Documentation of local function install_driver_recursive_from_dir

Definition

install_driver_recursive_from_dir($driverdir$ : string, ref $errorstrings$ : stringlist) : string

Description

Sets for the given list of opsi productIds the action request to 'setup' (also resolving the dependencies)

  • Parameter: $driverdir$

    • Type: String - Calltype: CallByValue

  • Parameter: $errorstrings$

    • Type: Stringlist - Calltype: CallByReference

  • Returns: Returns string "true" if all is ok

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 17.5.2018

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[actions]
DefStringlist $productlist$

set $productlist$ = CreateStringList("opsi-logviewer","opsi-configed")
if not(stringtobool(setProductsToSetup($productlist$)))
  comment "call of setProductsToSetup failed"
endif

Documentation of local function setFirewallExceptionsTcpUdp4product4profile

Definition

setFirewallExceptionsTcpUdp4product4profile($rulename$ : string, $fwprofile$ : string, $path2product$ : string) : void

Description
  • Parameter: $rulename$

    • Type: String - Calltype: CallByValue

  • Parameter: $fwprofile$

    • Type: String - Calltype: CallByValue

  • Parameter: $path2product$

    • Type: String - Calltype: CallByValue

  • Author: detlef oertel

  • Date: 27.08.2013

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Documentation of opsi library: uib_reboot_lib.opsiscript

Documentation of local function prepare_uefi_boot_to

Definition

prepare_uefi_boot_to($prefer_boot_option$ : string) : void

Description

if this is an uefi OS, then prepare the uefi nextboot to the stored uefi bootlabel that belongs to the boot target $prefer_boot_option$

  • Parameter: $prefer_boot_option$

    • Type: String - Calltype: CallByValue

    • Parameter $prefer_boot_option$ Description:
      'network' or "local-stored-bootimage" defaults to 'network' if empty

  • Returns: Returns string "void"

  • OnError: nothing

  • Author: detlef oertel

  • Date: 20.05.2020

Example:

[actions]
prepare_uefi_boot_to('network')
ExitWindows /Reboot

Documentation of opsi library: uib_state_and_condition.opsiscript

Documentation of local function isRebootPending

Example:

[actions]
if stringToBool(isRebootPending())
	comment "we need a reboot"
else
	comment "we do not need a reboot"
endif

Documentation of local function get_dotnet4_version

Definition

get_dotnet4_version() : string

Description

Checks which dotnet 4.x is installed

  • Returns: Returns string with the version number (aka "4.6") or empty string if no dotnet 4 is installed

  • OnError: Returns string ""

  • Author: detlef oertel

  • Date: 27.08.2019

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[actions]
if ("" = get_dotnet4_version()) or CompareDotSeparatedNumbers(get_dotnet4_version(), "<","4.6")
	comment "No dotnet 4 >= 4.6 installed"
else
	dotnet 4 >= 4.6 installed"
endif

Documentation of local function isdotnet_3_5_installed

Definition

isdotnet_3_5_installed() : string

Description

Checks if a dotnet 3.5 is installed

  • Returns: Returns string "true" dotnet 3.5 is installed

  • OnError: Returns string "false"

  • Author: detlef oertel

  • Date: 27.08.2019

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[actions]
if stringToBool(isdotnet_3_5_installed())
	comment "dotnet 3.5 is installed"
else
	comment "No dotnet 3.5 found"
endif

Documentation of local function getOpsiNetworkMedium

Definition

getOpsiNetworkMedium() : string

Description
  • Author: detlef oertel

  • Date: 27.08.2019

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Documentation of local function isVhdMode

Definition

isVhdMode() : string

Description

check if this installation is a 'vhd-reset' installation

  • Returns: Returns string "true" if vhd is detected

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 22.08.2019

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[actions]
if stringtobool(isVhdMode())
  comment "vhd mode detected"
endif

Documentation of local function isOliMode

Definition

isOliMode() : string

Description

check if this installation is a 'opsi local image' (oli) installation

  • Returns: Returns string "true" if oli is detected

  • OnError: Returns string "false"

  • SpecialCase: Works only in opsi service mode (not in interactive or batch mode)

  • Author: detlef oertel

  • Date: 22.08.2019

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[actions]
if stringtobool(isOliMode())
  comment "oli mode detected"
endif

opsi Library uib_lin_install.opsiscript

Local Function cleanupPackageSystem

Definition

cleanupPackageSystem() : void

Description

reads repo list und try to repair well known problems should be called after modifying the repo list or after failed installs

  • Returns: nothing

  • OnError: error counter increased ; Error messages in the log

  • Author: Detlef Oertel

  • Date: 19.08.2020

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[Actions]
importlib "uib_lin_install"

DefStringlist $packages$
DefVar $installresult$
DefStringlist $errorList$
DefVar $fatal_error$
DefVar $result_string$

comment "update and clean package system"
cleanupPackageSystem()
comment "install pending updates"
set $result_string$ = installupdates()
comment "install new needed packages"
set $packages$ = CreateStringlist("lsb-release","cifs-utils","xterm", "dnsutils","lsof","openssl","pkg-config","desktop-file-utils","libnotify-bin","libgtk2.0-0")
comment "if we are on debian / ubuntu we can use debinstall()"
set $installresult$ = debinstall($packages$)
if not(stringtobool($installresult$))
	if waitForPackageLock("300", "false")
		comment "we got the package lock."
	else
		LogError "could not get Package Lock"
	endif
	cleanupPackageSystem()
	set $installresult$ = debinstall($packages$)
	if not(stringtobool($installresult$))
		LogError "failed dependent packages"
		Message "failed dependent packages"
		;isFatalError "failed dependent packages"
		set $fatal_error$ = "true"
		setloglevel = 6
		set $errorList$ = addtolist($errorList$, " failed dependent_packages")
	endif
endif

Local Function installupdates

Definition

installupdates() : string

Description

try to install pending updates from the known repsitories should be called after modifying the repo list or after failed installs

  • Returns: nothing

  • OnError: Returns string "false"; error counter increased ; Error messages in the log

  • Author: Detlef Oertel

  • Date: 19.08.2020

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

see: cleanupPackageSystem()

Local Function runCommandWithList

Definition

runCommandWithList($command$ : string, $list$ : stringlist) : string

Description
  • Parameter: $command$

    • Type: String - Calltype: CallByValue

  • Parameter: $list$

    • Type: Stringlist - Calltype: CallByValue

  • Author: Detlef Oertel

  • Date: 19.8.2020

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Local Function debinstall

Definition

debinstall($packagelist$ : stringlist) : string

Description

try to install the packages given by $packagelist$

Example:

see: cleanupPackageSystem()

Local Function redinstall

Definition

redinstall($packagelist$ : stringlist) : string

Description

try to install the packages given by $packagelist$

Example:

see: cleanupPackageSystem()

Local Function suseinstall

Definition

suseinstall($packagelist$ : stringlist) : string

Description

try to install the packages given by $packagelist$

Example:

see: cleanupPackageSystem()

Local Function ucsinstall

Definition

ucsinstall($packagelist$ : stringlist) : string

Description

try to install the packages given by $packagelist$

Example:

see: cleanupPackageSystem()

Local Function genericLinInstall

Definition

genericLinInstall($packagelist$ : stringlist) : string

Description

try to determine the Linux familily and try to install the packages given by $packagelist$

Example:

see: cleanupPackageSystem()

Local Function linuxInstallOneOf

Definition

linuxInstallOneOf($packagelist$ : stringlist) : string

Description

try to install any package given by $packagelist$ This can be used specifying a package with different names for different linux distributions.

  • Parameter: $packagelist$

    • Type: Stringlist - Calltype: CallByValue

    • Parameter $packagelist$ Description:
      stringlist with packages to install

  • Returns: Returns string 'True' if one package was successfully installed

  • OnError: Returns string 'False'

  • References: Local Function isOneInstalled, Local Function getLinuxCommand

  • Author: Nils Doerrer

  • Date: 16.11.2020

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[Actions]
importlib "uib_lin_install"
if isOneInstalled(createStringList("lsusb", "usbutils")) = "False"
	message "installing lsusb or usbutils"
	set $success$ = linuxInstallOneOf(createStringList("lsusb", "usbutils"))
endif

Local Function isOneInstalled

Definition

isOneInstalled($packagelist$ : stringlist) : string

Description

check for installation status and return if any of $packagelist$ exists This can be used to check a package with different names for different linux distributions.

  • Parameter: $packagelist$

    • Type: Stringlist - Calltype: CallByValue

    • Parameter $packagelist$ Description:
      stringlist with packages to check

  • Returns: Returns string 'True' if one specified package is installed

  • OnError: Returns string 'False'

  • References: Local Function linuxInstallOneOf, Local Function getLinuxCommand

  • Author: Nils Doerrer

  • Date: 16.11.2020

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Local Function getLinuxCommand

Definition

getLinuxCommand($type$ : string) : string

Description

Determine package manager and return command.

  • Parameter: $type$

    • Type: String - Calltype: CallByValue

    • Parameter $type$ Description:
      type of desired command 'install','check', 'localpackage'

  • Returns: Package manager command according to type

  • OnError: Returns string 'False'

  • References: Local Function linuxInstallOneOf, Local Function isOneInstalled

  • Author: Nils Doerrer, Detlef Oertel

  • Date: 14.01.2021

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Local Function getLinuxCommandAgnostic

Definition

getLinuxCommandAgnostic($type$ : string) : string

Description

Determine package manager and return command.

Local Function linuxInstallOneFile

Definition

linuxInstallOneFile($packagefile$ : string) : string

Description

try to install the local file package given by $packagefile$ This can be used specifying a package with different names for different linux distributions.

Example:

[Actions]
importlib "uib_lin_install"
if stringToBool(linuxInstallOneFile("/tmp/dummy.deb")
	comment "success"
endif

Local Function linuxRemoveOnePackage

Definition

linuxRemoveOnePackage($packagename$ : string) : string

Description

try to remove the package given by $packagename$ This can be used specifying a package with different names for different linux distributions.

  • Parameter: $packagename$

    • Type: String - Calltype: CallByValue

    • Parameter $packagename$ Description:
      string with the name of a package to remove

  • Returns: Returns string '0' if package was successfully removed or was not installed

  • OnError: Returns string '-1'

  • References: Local Function isOneInstalled, Local Function getLinuxCommand

  • Author: Detlef Oertel

  • Date: 08.02.2021

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[Actions]
importlib "uib_lin_install"
if stringToBool(linuxRemoveOnePackage("dummy")
	comment "success"
endif

Local Function linuxRemoveOneOf

Definition

linuxRemoveOneOf($packagelist$ : stringlist) : string

Description

try to remove any package given by $packagelist$ This can be used specifying a package with different names for different linux distributions.

  • Parameter: $packagelist$

    • Type: Stringlist - Calltype: CallByValue

    • Parameter $packagelist$ Description:
      stringlist with packages to install

  • Returns: Returns string 'True' if one package was successfully installed

  • OnError: Returns string 'False'

  • References: Local Function isOneInstalled, Local Function getLinuxCommand

  • Author: Nils Doerrer, Detlef Oertel

  • Date: 16.11.2020

  • Email: d.oertel@uib.de

  • Version: 1.0

  • Copyright: AGPLv3

Example:

[Actions]
importlib "uib_lin_install"
if isOneInstalled(createStringList("lsusb", "usbutils")) = "True"
	message "installing lsusb or usbutils"
	set $success$ = linuxRemoveOneOf(createStringList("lsusb", "usbutils"))
endif

opsi Library uib_macosinstalllib.opsiscript

Local Function install_macos_app

Definition

install_macos_app($myapp$ : string) : string

Description

try to install the app given by $myapp$

Example:

[Actions]
importlib "uib_macosinstalllib"

DefVar $installfile$
DefVar $installresult$

comment "we have a *.app (directory) and install with install_macos_app"
set $installfile$ = "%scriptpath%/files/my_macos_app.app"
set $installresult$ = install_macos_app($installfile$)
if stringtobool($installresult$)
	comment "installation succseeded"
else
	LogError "installation failed"
endif

Local Function install_macos_pkg

Definition

install_macos_pkg($mypkg$ : string) : string

Description

try to install the pkg file given by $mypkg$

Example:

[Actions]
importlib "uib_macosinstalllib"

DefVar $installfile$
DefVar $installresult$

comment "we have a *.pkg and install with install_macos_pkg"
set $installfile$ = "%scriptpath%/files/my_macos_app.pkg"
set $installresult$ = install_macos_pkg($installfile$)
if stringtobool($installresult$)
	comment "installation succseeded"
else
	LogError "installation failed"
endif

Local Function install_macos_dmg

Definition

install_macos_dmg($mydmg$ : string) : string

Description

try to install the dmg file given by $mydmg$

Example:

[Actions]
importlib "uib_macosinstalllib"

DefVar $installfile$
DefVar $installresult$

comment "we have a *.dmg and install with install_macos_dmg"
set $installfile$ = "%scriptpath%/files/my_macos_app.dmg"
set $installresult$ = install_macos_dmg($installfile$)
if stringtobool($installresult$)
	comment "installation succseeded"
else
	LogError "installation failed"
endif

Local Function install_macos_zip

Definition

install_macos_zip($myzip$ : string) : string

Description

try to install the zip file given by $myzip$ unzips the file and try to find a installable part (*.app, *.pkg, *.dmg) and try to install this

Example:

[Actions]
importlib "uib_macosinstalllib"

DefVar $installfile$
DefVar $installresult$

comment "we have a *.zip and install with install_macos_zip"
set $installfile$ = "%scriptpath%/files/my_macos_app.zip"
set $installresult$ = install_macos_zip($installfile$)
if stringtobool($installresult$)
	comment "installation succseeded"
else
	LogError "installation failed"
endif

Local Function install_macos_generic

Definition

install_macos_generic($myfile$ : string) : string

Description

try to install the file given by $myfile$ Checks if the file is a well known installable (*.app, *.pkg, *.dmg, *.zip) and try to install this

Example:

see: install_macos_generic
[Actions]
importlib "uib_macosinstalllib"

DefVar $installfile$
DefVar $installresult$

comment "we have a *.* and install with install_macos_generic"
set $installfile$ = "%scriptpath%/files/opsi-script.app"
set $installresult$ = install_macos_generic($installfile$)
if stringtobool($installresult$)
	comment "installation succseeded"
else
	Error "installation failed"
endif