# bootargs.cfg inherits from grub.cfg several context variables:
#   'img' => defines the image path to boot from. Active img is statically defined, does not require a value
#   'state_label' => label of the state partition filesystem
#   'oem_label' => label of the oem partition filesystem
#   'recovery_label' => label of the recovery partition filesystem
#   'snapshotter' => snapshotter type, assumes loopdevice type if undefined
#
# In addition bootargs.cfg is responsible of setting the following variables:
#   'kernelcmd' => essential kernel command line parameters (all elemental specific and non elemental specific)
#   'kernel' => kernel binary path within the target image
#   'initramfs' => initramfs binary path within the target image

if [ -n "${img}" ]; then
  set img_arg="elemental.image=${img}"
fi

if [ "${mode}" == "recovery" ]; then
  set kernelcmd="console=tty1 console=ttyS0 root=LABEL=${recovery_label} ${img_arg} elemental.mode=${mode} elemental.oemlabel=${oem_label} security=selinux enforcing=0"
else
  if [ "${snapshotter}" == "btrfs" ]; then
    set snap_arg="elemental.snapshotter=btrfs"
  fi
  set kernelcmd="console=tty1 console=ttyS0 root=LABEL=${state_label} ${img_arg} ${snap_arg} elemental.mode=${mode} elemental.oemlabel=${oem_label} panic=5 security=selinux fsck.mode=force fsck.repair=yes"
fi

set kernel=/boot/vmlinuz
set initramfs=/boot/initrd
