| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #!/bin/sh
- set -eux
- exec >/boot/firstrun.log 2>&1
- date
- # 1) SSH + utilisateur pi (hash déjà connu)
- if [ -x /usr/lib/userconf-pi/userconf ]; then
- /usr/lib/userconf-pi/userconf 'pi' '$5$VOr2jdaVXo$nZI1v259hiMq0IM0KpPu8pDI/Zu08Yh5/ZQEOrHTP11' || true
- if [ -f /usr/lib/raspberrypi-sys-mods/imager_custom ]; then
- /usr/lib/raspberrypi-sys-mods/imager_custom enable_ssh || true
- else
- systemctl enable ssh || true
- fi
- else
- FIRSTUSER="$(getent passwd 1000 | cut -d: -f1 || echo pi)"
- echo "$FIRSTUSER:"'$5$VOr2jdaVXo$nZI1v259hiMq0IM0KpPu8pDI/Zu08Yh5/ZQEOrHTP11' | chpasswd -e || true
- [ "$FIRSTUSER" = "pi" ] || {
- usermod -l pi "$FIRSTUSER" || true
- usermod -m -d /home/pi pi || true
- groupmod -n pi "$FIRSTUSER" || true
- }
- systemctl enable ssh || true
- fi
- # 2) Locale/clavier/fuseau (best-effort, sans bloquer)
- if command -v raspi-config >/dev/null 2>&1; then
- raspi-config nonint do_change_locale fr_FR.UTF-8 || true
- raspi-config nonint do_configure_keyboard fr || true
- raspi-config nonint do_change_timezone Europe/Paris || true
- fi
- # 3) Préparer /home/pi/install-waouw + y déposer le zip
- inst=/home/pi/install-waouw
- mkdir -p "$inst"
- chown -R pi:pi "$inst" || true
- if [ -f /boot/waouw-deploy.zip ]; then
- mv -f /boot/waouw-deploy.zip "$inst/" || cp -f /boot/waouw-deploy.zip "$inst/"
- chown pi:pi "$inst/waouw-deploy.zip" || true
- if command -v unzip >/dev/null 2>&1; then
- (cd "$inst" && unzip -o waouw-deploy.zip) || true
- fi
- fi
- # 4) Installer/activer le service one-shot
- cat >/etc/systemd/system/check-waouwinit.service <<'EOF'
- [Unit]
- Description=Vérifie /boot/.waouwinit puis lance init_host.sh (une seule fois)
- After=network-online.target
- Wants=network-online.target
- [Service]
- Type=oneshot
- ExecStart=/bin/bash -lc 'if [ ! -f /boot/.waouwinit ] && [ ! -f /boot/firmware/.waouwinit ]; then INIT=$(find /home/pi/install-waouw -maxdepth 5 -name "init_host.sh" -type f 2>/dev/null | head -1); [ -n "$INIT" ] && [ -x "$INIT" ] && /bin/bash "$INIT"; fi'
- RemainAfterExit=yes
- [Install]
- WantedBy=multi-user.target
- EOF
- systemctl daemon-reload
- systemctl enable check-waouwinit.service || true
- # 5) Nettoyage cmdline pour ne PAS reboucler sur firstrun
- for f in /boot/cmdline.txt /boot/firmware/cmdline.txt; do
- [ -f "$f" ] && sed -i 's| systemd.run[^ ]*||g;s| systemd.run_success_action[^ ]*||g;s| systemd.unit[^ ]*||g' "$f" || true
- done
- rm -f /boot/firstrun.sh
- touch /boot/FIRSTRUN_DONE
- exit 0
|