Debian Codegraph @

autotests/input/test.opsiscript

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