Änderungen von Dokument Eigene Autoconf-Rolle erstellen

Zuletzt geändert von Tom Altenbrunn am 2023/03/17 08:03

Von Version 28.1
bearbeitet von Jonas Mayer
am 2023/03/16 07:55
Änderungskommentar: Es gibt keinen Kommentar für diese Version
Auf Version 27.1
bearbeitet von Jonas Mayer
am 2023/03/16 07:48
Änderungskommentar: Es gibt keinen Kommentar für diese Version

Zusammenfassung

Details

Seiteneigenschaften
Inhalt
... ... @@ -96,6 +96,14 @@
96 96  ----
97 97  
98 98  
99 +
100 +
101 +
102 +
103 +
104 +
105 +
106 +
99 99  = (% style="font-size:22px" %)__**Weiteres, funktionsfertiges Beispiel: Rolle „WLAN Profil mit PSK anlegen“**__(%%) =
100 100  
101 101  
... ... @@ -118,7 +118,7 @@
118 118   license: SBE
119 119  (% style="color:#8e44ad" %) uuid:(%%) 52318636-c4f5-11ea-baf9-0bff00c66ff4
120 120   visible: true
121 -(% style="color:#19177c" %) priority:(%%) 0
129 + (% style="color:#19177c" %)priority:(%%) 0
122 122   applyAlways: false
123 123  (% style="color:#f1c40f" %) tags:(%%)
124 124   - CUSTOM
... ... @@ -158,17 +158,16 @@
158 158  
159 159  == (% style="font-size:16px" %)**Inhalt des PowerShell-Skripts main.ps1, das die Variablen entgegennimmt**(%%) ==
160 160  
161 -Im Unterverzeichnis {{box}} win/ {{/box}} oder {{box}} lin/ {{/box}} der Autoconf-Rolle können sich wie erläutert unterschiedliche PowerShell-Skripte zur Ausführung in den verschiedenen Phasen befinden.
162 -In dieser Rolle liegt konkret das allgemeingültige Skript {{box}}main.ps1{{/box}} vor, welches die Variablen als Parameter ##$ssid## und ##$psk## intern verwendet.
169 +Im Unterverzeichnis {{box}} win/ {{/box}} oder {{box}} lin/ {{/box}} der Autoconf-Rolle können sich unterschiedliche PowerShell-Skripte zur Ausführung in den Phasen befinden. In dieser Rolle liegt das allgemeingültige Skript {{box}}main.ps1{{/box}} vor, welches die Variablen als Parameter ##$ssid## und ##$psk## intern verwendet.
163 163  
171 +(% class="box" %)
172 +(((
173 +(% style="color:#27ae60" %)# Windows Variante(%%)
174 +root@ctrl-g1:~~ # cat /usr/lib/ld-autoconf/logodidact/roles/ld_wlan_psk/win/main.ps1
175 +)))
164 164  
165 -(% style="color:#19177c" %)**Windows Variante**
166 166  
167 -{{code language="text" width="50%"}}
168 -root@ctrl-g1:~ # cat /usr/lib/ld-autoconf/logodidact/roles/ld_wlan_psk/win/main.ps1
169 -{{/code}}
170 -
171 -{{code width="50%" language="powershell"}}
178 +{{code width="50%"}}
172 172  Param
173 173  (
174 174   [parameter(Mandatory=$false)]
... ... @@ -223,69 +223,18 @@
223 223  }
224 224  {{/code}}
225 225  
233 +==== ====
226 226  
227 -(% style="color:#19177c" %)**Linux Variante (Network Manager)**
235 +==== ====
228 228  
229 -{{code width="50%" language="text"}}
230 -root@ctrl-g1:~ # cat /usr/lib/ld-autoconf/logodidact/roles/ld_wlan_psk/win/main.ps1
231 -{{/code}}
237 +==== ====
232 232  
233 -{{code language="powershell" width="50%"}}
234 -Param
235 -(
236 - [parameter(Mandatory=$false)]
237 - [String]
238 - $ssid,
239 - [parameter(Mandatory=$false)]
240 - [String]
241 - $psk
242 -)
239 +==== ====
243 243  
244 -if ($ssid -ne '' -and $psk -ne '') {
245 - if (Get-Command "nmcli" -ErrorAction SilentlyContinue) {
246 - # Check if kernel modules are up
247 - nmcli dev wifi rescan
248 - if ($LASTEXITCODE -ne 0) {
249 - Start-Sleep -Seconds 30
250 - }
251 -
252 - # Check again
253 - nmcli dev wifi rescan
254 - if ($LASTEXITCODE -ne 0) {
255 - Write-Verbose "Skipping role. There might be no WiFi device installed."
256 - exit 0
257 - }
258 -
259 - $config = "/etc/NetworkManager/system-connections/$ssid"
241 +==== ====
260 260  
261 - if (Test-Path -Path $config) {
262 - Write-Verbose "Removing '$config'"
263 - Remove-Item -Path $config -Recurse -Force
264 - }
243 +==== ====
265 265  
266 - Write-Verbose "Connecting to '$ssid'"
267 -
268 - nmcli device wifi connect """$ssid""" password """$psk"""
269 -
270 - if ($LASTEXITCODE -eq 0) {
271 - Start-Sleep -Seconds 5
272 - nmcli con up """$ssid"""
245 +==== ====
273 273  
274 - if ($LASTEXITCODE -ne 0) {
275 - Write-Verbose "Error: Credentials wrong?"
276 -
277 - if (Test-Path -Path $config) {
278 - Write-Verbose "Removing '$config'"
279 - Remove-Item -Path $config -Recurse -Force
280 - }
281 - }
282 - }
283 -
284 - Write-Verbose "Exiting with code: $LASTEXITCODE"
285 - exit $LASTEXITCODE
286 - }
287 -
288 - Write-Verbose "No suitable implementation found"
289 - exit 1
290 -}
291 -{{/code}}
247 +==== ====