modules/zyxel-dual-image: init
This adds a simple boot blessing module, to be used, with the Zyxel NWA50AX. There's a lot of elephant in the rooms: how do you upgrade kernel, etc. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
c14b2f6356
commit
422f3edab1
4 changed files with 107 additions and 0 deletions
33
modules/zyxel-dual-image/service.nix
Normal file
33
modules/zyxel-dual-image/service.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
liminix
|
||||
, lib
|
||||
, zyxel-bootconfig
|
||||
}:
|
||||
{ ensureActiveImage, primaryMtdPartition, secondaryMtdPartition, bootConfigurationMtdPartition, kernelCommandLineSource }:
|
||||
let
|
||||
inherit (liminix.services) oneshot;
|
||||
activeImageIndex = if ensureActiveImage == "primary" then 0 else 1;
|
||||
in oneshot {
|
||||
name = "zyxel-boot-configure";
|
||||
up = ''
|
||||
set -- $(cat /proc/device-tree/chosen/bootargs)
|
||||
for x in "$@"; do
|
||||
case "$x" in
|
||||
bootImage=*)
|
||||
BOOT_IMAGE="''${x#bootImage=}"
|
||||
echo "Current boot image is $BOOT_IMAGE."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test -z "$BOOT_IMAGE"; then
|
||||
echo "No valid image was provided in the kernel command line."
|
||||
exit 1
|
||||
else
|
||||
${lib.getExe zyxel-bootconfig} ${bootConfigurationMtdPartition} set-image-status "$BOOT_IMAGE" valid
|
||||
${lib.getExe zyxel-bootconfig} ${bootConfigurationMtdPartition} set-active-image ${toString activeImageIndex}
|
||||
|
||||
echo "Active image is now ${ensureActiveImage}"
|
||||
fi
|
||||
'';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue