| 1 | <!DOCTYPE html> |
| 2 | <html><head> |
| 3 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 4 | <title>test.opsiscript</title> |
| 5 | <meta name="generator" content="KF5::SyntaxHighlighting - Definition (opsi-script) - Theme (Breeze Light)"/> |
| 6 | </head><body style="background-color:#ffffff;color:#1f1c1b"><pre> |
| 7 | <span style="color:#898887">; opsiscript syntax highlighting test</span> |
| 8 | <span style="color:#898887">;</span> |
| 9 | <span style="color:#898887">; SPDX-FileCopyrightText: 2024 Stefan Staeglich <[email protected]></span> |
| 10 | <span style="color:#898887">;</span> |
| 11 | <span style="color:#898887">; SPDX-License-Identifier: LGPL-2.1-or-later</span> |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | <span style="color:#0057ae">[Actions]</span> |
| 17 | <span style="color:#644a9b;font-weight:bold">requiredWinstVersion</span> <span style="color:#ca60ca">>=</span> <span style="color:#bf0303">"4.12.8"</span> |
| 18 | <span style="color:#644a9b;font-weight:bold">ScriptErrorMessages</span><span style="color:#ca60ca">=</span>off |
| 19 | <span style="color:#644a9b;font-weight:bold">setLogLevel</span> <span style="color:#ca60ca">=</span> 7 |
| 20 | |
| 21 | |
| 22 | <span style="font-weight:bold">DefVar</span> <span style="color:#0057ae">$OS$</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">GetOS</span> |
| 23 | <span style="font-weight:bold">DefVar</span> <span style="color:#0057ae">$ProductId$</span> <span style="color:#ca60ca">=</span> <span style="color:#bf0303">"test"</span> |
| 24 | |
| 25 | <span style="font-weight:bold">DefVar</span> <span style="color:#0057ae">$filename$</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">GetProductProperty</span>(<span style="color:#bf0303">"filename"</span>, <span style="color:#bf0303">"/tmp/testfile.txt"</span>) |
| 26 | |
| 27 | <span style="color:#644a9b;font-weight:bold">comment</span> <span style="color:#bf0303">"Show product picture"</span> |
| 28 | <span style="color:#644a9b;font-weight:bold">ShowBitmap</span> <span style="color:#bf0303">"</span><span style="color:#0057ae">%ScriptPath%</span><span style="color:#bf0303">\"</span> <span style="color:#ca60ca">+</span> <span style="color:#0057ae">$ProductId$</span> <span style="color:#ca60ca">+</span> <span style="color:#bf0303">".png"</span> <span style="color:#0057ae">$ProductId$</span> |
| 29 | |
| 30 | <span style="font-weight:bold">Switch</span> <span style="color:#0057ae">$OS$</span> |
| 31 | <span style="font-weight:bold"> case</span> <span style="color:#bf0303">"Linux"</span> |
| 32 | <span style="color:#644a9b;font-weight:bold">Message</span> <span style="color:#bf0303">"Try to install "</span> <span style="color:#ca60ca">+</span> <span style="color:#0057ae">$ProductId$</span> <span style="color:#bf0303">" on "</span> <span style="color:#ca60ca">+</span> <span style="color:#0057ae">$OS$</span> |
| 33 | <span style="color:#644a9b"> sub_main_linux</span> |
| 34 | <span style="font-weight:bold"> EndCase</span> |
| 35 | <span style="font-weight:bold"> case</span> <span style="color:#bf0303">"Windows_NT"</span> |
| 36 | <span style="color:#644a9b;font-weight:bold">Message</span> <span style="color:#bf0303">"Try to install "</span> <span style="color:#ca60ca">+</span> <span style="color:#0057ae">$ProductId$</span> <span style="color:#bf0303">" on "</span> <span style="color:#ca60ca">+</span> <span style="color:#0057ae">$OS$</span> |
| 37 | <span style="color:#644a9b"> sub_main_windows</span> |
| 38 | <span style="font-weight:bold"> EndCase</span> |
| 39 | <span style="font-weight:bold"> DefaultCase</span> |
| 40 | <span style="color:#644a9b;font-weight:bold">Message</span> <span style="color:#0057ae">$OS$</span> <span style="color:#ca60ca">+</span> <span style="color:#bf0303">" is not supported"</span> |
| 41 | <span style="font-weight:bold"> EndCase</span> |
| 42 | <span style="font-weight:bold">EndSwitch</span> |
| 43 | |
| 44 | <span style="color:#0057ae">[sub_main_linux]</span> |
| 45 | <span style="font-weight:bold">DefVar</span> <span style="color:#0057ae">$distrotype$</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getLinuxDistroType</span> |
| 46 | <span style="font-weight:bold">DefStringList</span> <span style="color:#0057ae">$linuxInfo$</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getLinuxVersionMap</span> |
| 47 | <span style="font-weight:bold">DefVar</span> <span style="color:#0057ae">$distCodeName$</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getValue</span>(<span style="color:#bf0303">"Codename"</span>, <span style="color:#0057ae">$linuxInfo$</span>) |
| 48 | <span style="font-weight:bold">DefVar</span> <span style="color:#0057ae">$distRelease$</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getValue</span>(<span style="color:#bf0303">"Release"</span>, <span style="color:#0057ae">$linuxInfo$</span>) |
| 49 | <span style="font-weight:bold">DefVar</span> <span style="color:#0057ae">$distroName$</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getValue</span>(<span style="color:#bf0303">"Distributor ID"</span>, <span style="color:#0057ae">$linuxInfo$</span>) |
| 50 | |
| 51 | <span style="font-weight:bold">if</span> <span style="color:#ca60ca">not</span> (<span style="color:#0057ae">$distrotype$</span> <span style="color:#ca60ca">=</span> <span style="color:#bf0303">'debian'</span>) |
| 52 | <span style="color:#644a9b;font-weight:bold">LogError</span> <span style="color:#bf0303">"Product: "</span> <span style="color:#ca60ca">+</span> <span style="color:#0057ae">$ProductId$</span> <span style="color:#ca60ca">+</span> <span style="color:#bf0303">"is desinged for Debian/Ubuntu"</span> |
| 53 | <span style="color:#644a9b;font-weight:bold">isFatalError</span> <span style="color:#bf0303">"Wrong Distrotype"</span> |
| 54 | <span style="font-weight:bold">endif</span> |
| 55 | |
| 56 | <span style="color:#644a9b;font-weight:bold">Message</span> <span style="color:#bf0303">"Try to get Package Lock..."</span> |
| 57 | <span style="font-weight:bold">if</span> waitForPackageLock(<span style="color:#bf0303">"60"</span>,<span style="color:#bf0303">"false"</span>) |
| 58 | <span style="color:#644a9b;font-weight:bold">comment</span> <span style="color:#bf0303">"we got the package lock."</span> |
| 59 | <span style="font-weight:bold">else</span> |
| 60 | <span style="color:#644a9b;font-weight:bold">LogError</span> <span style="color:#bf0303">"could not get Package Lock"</span> |
| 61 | <span style="color:#644a9b;font-weight:bold">isFatalError</span> <span style="color:#bf0303">"package lock failed"</span> |
| 62 | <span style="font-weight:bold">endif</span> |
| 63 | |
| 64 | <span style="color:#644a9b">ShellInAnIcon_install_linux</span> |
| 65 | <span style="font-weight:bold">if</span> <span style="color:#ca60ca">not</span>(<span style="color:#bf0303">"0"</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getLastExitCode</span>) |
| 66 | <span style="color:#644a9b;font-weight:bold">LogError</span> <span style="color:#bf0303">"failed ShellInAnIcon_install_linux"</span> |
| 67 | <span style="color:#644a9b;font-weight:bold">isFatalError</span> <span style="color:#bf0303">"ShellInAnIcon_install_linux"</span> |
| 68 | <span style="font-weight:bold">endif</span> |
| 69 | |
| 70 | <span style="color:#644a9b">Patches_config_systemd </span><span style="color:#bf0303">"/etc/systemd/system/test.service.d/override.conf"</span> |
| 71 | <span style="font-weight:bold">if</span> <span style="color:#ca60ca">not</span>(<span style="color:#bf0303">"0"</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getLastExitCode</span>) |
| 72 | <span style="color:#644a9b;font-weight:bold">Message</span> <span style="color:#bf0303">"failed Patches_config_systemd"</span> |
| 73 | <span style="color:#644a9b;font-weight:bold">LogError</span> <span style="color:#bf0303">"failed Patches_config_systemd"</span> |
| 74 | <span style="color:#644a9b;font-weight:bold">isFatalError</span> <span style="color:#bf0303">"config_systemd"</span> |
| 75 | <span style="font-weight:bold">endif</span> |
| 76 | |
| 77 | <span style="color:#644a9b;font-weight:bold">Message</span> <span style="color:#bf0303">"Patch config file ..."</span> |
| 78 | <span style="color:#644a9b">XML2_config </span><span style="color:#bf0303">"/etc/test.conf"</span> |
| 79 | <span style="font-weight:bold">if</span> <span style="color:#ca60ca">not</span>(<span style="color:#bf0303">"0"</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getLastExitCode</span>) |
| 80 | <span style="color:#644a9b;font-weight:bold">Message</span> <span style="color:#bf0303">"failed XML2_config"</span> |
| 81 | <span style="color:#644a9b;font-weight:bold">LogError</span> <span style="color:#bf0303">"failed XML2_config"</span> |
| 82 | <span style="color:#644a9b;font-weight:bold">isFatalError</span> <span style="color:#bf0303">"XML2_config"</span> |
| 83 | <span style="font-weight:bold">endif</span> |
| 84 | |
| 85 | <span style="color:#644a9b">PatchTextFile_config </span><span style="color:#bf0303">"/etc/test.conf"</span> |
| 86 | <span style="font-weight:bold">if</span> <span style="color:#ca60ca">not</span>(<span style="color:#bf0303">"0"</span> <span style="color:#ca60ca">=</span> <span style="color:#644a9b;font-weight:bold">getLastExitCode</span>) |
| 87 | <span style="color:#644a9b;font-weight:bold">Message</span> <span style="color:#bf0303">"failed PatchTextFile_config"</span> |
| 88 | <span style="color:#644a9b;font-weight:bold">LogError</span> <span style="color:#bf0303">"failed PatchTextFile_config"</span> |
| 89 | <span style="color:#644a9b;font-weight:bold">isFatalError</span> <span style="color:#bf0303">"XML2_config"</span> |
| 90 | <span style="font-weight:bold">endif</span> |
| 91 | |
| 92 | <span style="color:#0057ae">[ShellInAnIcon_install_linux]</span> |
| 93 | <span style="color:#644a9b;font-weight:bold">set</span> -x |
| 94 | <span style="color:#644a9b;font-weight:bold">export</span> PATH<span style="color:#ca60ca">=</span>/usr/<span style="color:#644a9b;font-weight:bold">local</span>/bin:/usr/bin:/bin:/usr/<span style="color:#644a9b;font-weight:bold">local</span>/sbin:/usr/sbin:/sbin |
| 95 | <span style="color:#644a9b;font-weight:bold">export</span> DEBIAN_FRONTEND<span style="color:#ca60ca">=</span>noninteractive |
| 96 | EXITCODE<span style="color:#ca60ca">=</span>0 |
| 97 | apt-get --<span style="color:#644a9b">yes</span> <span style="color:#644a9b">install</span> <span style="color:#644a9b;font-weight:bold">test</span> |
| 98 | <span style="font-weight:bold">if</span> [ <span style="color:#0057ae">$?</span> -ne 0 ]<span style="color:#ca60ca">;</span> <span style="font-weight:bold">then</span> EXITCODE<span style="color:#ca60ca">=</span>1<span style="color:#ca60ca">;</span> <span style="font-weight:bold">fi</span> |
| 99 | <span style="color:#644a9b;font-weight:bold">exit</span> <span style="color:#0057ae">$EXITCODE</span> |
| 100 | |
| 101 | <span style="color:#0057ae">[XML2_config]</span> |
| 102 | <span style="color:#644a9b;font-weight:bold">openNode</span> <span style="color:#bf0303">'file'</span> |
| 103 | <span style="color:#644a9b;font-weight:bold">SetAttribute</span> <span style="color:#bf0303">"name"</span> <span style="color:#bf0303">"</span><span style="color:#0057ae">$filename$</span><span style="color:#bf0303">"</span> |
| 104 | |
| 105 | <span style="color:#0057ae">[PatchTextFile_config]</span> |
| 106 | <span style="color:#644a9b;font-weight:bold">FindLine_Containing</span> <span style="color:#bf0303">"</span><span style="color:#0057ae">$filename$</span><span style="color:#bf0303">"</span> |
| 107 | <span style="color:#644a9b;font-weight:bold">DeleteTheLine</span> |
| 108 | <span style="color:#644a9b;font-weight:bold">SaveToFile</span> <span style="color:#bf0303">"/etc/test2.conf"</span> |
| 109 | |
| 110 | <span style="color:#0057ae">[Patches_config_systemd]</span> |
| 111 | <span style="color:#644a9b;font-weight:bold">delsec</span> [Service] |
| 112 | <span style="color:#644a9b;font-weight:bold">set</span> [Service] Restart<span style="color:#ca60ca">=</span>on-failure |
| 113 | </pre></body></html> |