Linbo 4.2, Wlan, Kennwort verteilen

So und hier kommt die (momentane Lösung):

  1. update-linbofs pre hook erstellen und update-linbofs ausführen
#!/bin/bash
# /var/lib/linuxmuster/hooks/update-linbofs.pre.d/01_copy_wlan_profile 
# nomisge AT live.de 
# 20240326
#

echo "### Copy Wlan Profile ###"

# copies profile to linbofs; <dir> entsprechend anpassen
profile="<dir>/WLAN-Schule.xml"
cp "$profile" etc
  1. Geplante Aufgabe im Image mit folgenden Skripten installieren.

/srv/linbo/linuxmuster-win/install.cmd (angepasst):

REM Installiert geplante Aufgaben für linuxmuster.net
REM nomisge AT live.de
REM thomas@linuxmuster.net
REM 26.03.2024

REM alte Tasks zuerst deinstallieren
call %SystemDrive%\linuxmuster-win\uninstall.cmd

REM erstellt linuxmuster-start-tasks, die beim Start ausgeführt werden
schtasks /Create /XML %SystemDrive%\linuxmuster-win\linuxmuster-start-tasks.xml /TN linuxmuster\linuxmuster-start-tasks

/srv/linbo/linuxmuster-win/uninstall.cmd (angepasst)

REM entfernt die geplanten linuxmuster-tasks
REM nomisge AT live.de
REM thomas@linuxmuster.net
REM 26.03.2024

schtasks /delete /TN linuxmuster-start-tasks /f
schtasks /delete /TN linuxmuster-shutdown-tasks /f
schtasks /delete /TN linuxmuster\linuxmuster-start-tasks /f
schtasks /delete /TN linuxmuster\linuxmuster-shutdown-tasks /f

/srv/linbo/linuxmuster-win/linuxmuster-start-tasks.xml (führt start-tasks.cmd mehrmals aus, da WLAN Schnittstelle evtl. noch nicht bereit):

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2015-09-21T10:33:20.1523216</Date>
    <Author>Administrator</Author>
    <Description>Run tasks defined C:\linuxmuster-win\start-tasks.cmd</Description>
    <URI>\linuxmuster\linuxmuster-start-tasks</URI>
  </RegistrationInfo>
  <Triggers>
    <BootTrigger>
      <Enabled>true</Enabled>
    </BootTrigger>
    <BootTrigger>
      <Enabled>true</Enabled>
      <Delay>PT10S</Delay>
    </BootTrigger>
    <BootTrigger>
      <Enabled>true</Enabled>
      <Delay>PT20S</Delay>
    </BootTrigger>
    <BootTrigger>
      <Enabled>true</Enabled>
      <Delay>PT30S</Delay>
    </BootTrigger>
    <BootTrigger>
      <Enabled>true</Enabled>
      <Delay>PT1M</Delay>
    </BootTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>false</AllowHardTerminate>
    <StartWhenAvailable>true</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
    <RestartOnFailure>
      <Interval>PT1M</Interval>
      <Count>3</Count>
    </RestartOnFailure>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>%SystemDrive%\linuxmuster-win\start-tasks.cmd</Command>
    </Exec>
  </Actions>
</Task>
  1. start-tasks.cmd anpassen und set-wlan-profile.cmd anlegen, danach update-linbofs ausführen:
REM /srv/linbo/linuxmuster-win/start-tasks.cmd 
REM Tasks, die beim Start ausgefuehrt werden
REM nomisge AT live.de
REM thomas@linuxmuster.net
REM 26.03.2024

REM Stelle sicher, dass linuxmuster-win versteckt ist.
if exist %SystemDrive%:\linuxmuster-win\ (
	ATTRIB +h %SystemDrive%:\linuxmuster-win
)

REM Wlan Profil setzen, falls vorhanden
if exist %SystemDrive%\linuxmuster-win\set-wlan-profile.cmd call %SystemDrive%\linuxmuster-win\set-wlan-profile.cmd

REM Eigenes Skript aufrufen, falls vorhanden
if exist %SystemDrive%\linuxmuster-win\custom.cmd call %SystemDrive%\linuxmuster-win\custom.cmd
REM /srv/linbo/linuxmuster-win/set-wlan-profile.cmd 
REM Setze Wlan-Profil falls Änderung vorliegt.
REM nomisge AT live.de
REM 26.03.2024

rem # Aktualisiere Wlan Profil

if exist %SystemDrive%\linuxmuster-win\WLAN-Schule.xml (
	rem # Lösche alle Wlan Profile; sinnvoll, falls jemand ein anderes profil aktiviert hat.
	netsh wlan delete profile name=* i=*
	rem # Installiere Wlan Profil, welches via postsync gespeichert wurde.
	netsh wlan add profile filename=%SystemDrive%\linuxmuster-win\WLAN-Schule.xml
)
  1. Postsyncscript für entsprechendes Image in Schulkonsole anlegen und device-import durchführen: Dank dem Hinweis von @Till wird das Profil nur für Geräte deren Gruppe „_wlan“ enthält kopiert.
#!/bin/sh
if  [[ $HOSTGROUP == *"_wlan"* ]]; then
  mkdir /mnt/windows```

  ISNVME=$(fdisk -l | grep nvme)
  if [ -n "$ISNVME" ]; then
    echo "Found nvme, try to mount it..."
    WINDISK="/dev/nvme0n1p3"
  else
    echo "Device has no nvme fallback to sda..."
    WINDISK="/dev/sda3"
  fi

  mount "$WINDISK" /mnt/windows
  cp /etc/WLAN-Schule.xml /mnt/windows/linuxmuster-win/

  umount /mnt/windows
  rm -rf /mnt/windows
fi

Hinweis: Beim Imageing sollte sichergestellt werde, dass C:\linuxmuster-win\WLAN-Schule.xml nicht aus Versehen ins Image aufgenommen wird.

Es gibt noch Optimierungsbedarf, dafür aber mehr im folgenden Post. Feedback mit Verbesserungsvorschlägen ist immer Willkommen.