installer: operation installation script
authorKristof Provost <kp@FreeBSD.org>
Fri, 5 May 2023 09:29:41 +0000 (11:29 +0200)
committerKristof Provost <kp@FreeBSD.org>
Fri, 5 May 2023 09:29:41 +0000 (11:29 +0200)
Check if the device is the expected PC Engines CPU model, to reduce the
odds that we'll clobber something else.
If everything matches expectations copy the image to the device.

image/overlay/installer/etc/rc.local

index 79e6969..ff2c624 100644 (file)
@@ -1,15 +1,34 @@
 #!/bin/sh
 
-set -x
+find_rootdev()
+{
 
-echo "Running rc.local!"
+}
 
-# XXX Can we identify PC Engines boards?
-# hw.model Geode(TM) Integrated Processor by AMD PCS for old Alix boards
+do_install()
+{
+       target=$1
 
-if ! /usr/local/bin/bsddialog --pause "Auto-install?" 0 0 10;
+       logger -s "Installing to $target ...."
+       xz -c -d /domotica.img.xz | dd status=progress of=/dev/$target
+}
+
+logger -s "Running rc.local!"
+
+model=$(sysctl -n hw.model | awk '{$1=$1};1')
+echo Model: $model
+if [ "$model" != 'AMD GX-412TC SOC' ] \
+    && [ "$model" != 'Geode(TM) Integrated Processor by AMD PCS' ] \
+    && [ "$model" != 'QEMU Virtual CPU version 2.5+' ];
 then
-/bin/sh
+       logger -s "Unknown hardware ${model}, cowardly refusing to run installer."
+       exit 0
 fi
 
-echo "Autoinstall"
+export TERM=vt100
+/usr/local/bin/bsddialog --pause "Auto-install?" 0 0 10
+ret=$?
+if [ $ret -eq 0 ] || [ $ret -eq 4 ];
+then
+       do_install ada0
+fi