OpenVoiceOS/buildroot-external/rootfs-overlay/usr/libexec/ovos-update

45 lines
899 B
Bash
Executable File

#!/bin/sh
if [ $# -lt 1 ]; then
exit 0;
fi
function get_current_root_device
{
CURRENT_ROOT=$(swupdate -g);
}
function get_update_part
{
CURRENT_PART="${CURRENT_ROOT: -1}"
if [ $CURRENT_PART = "2" ]; then
UPDATE_PART="3";
GRUB_DEFAULT="1";
GRUB_FALLBACK="0";
else
UPDATE_PART="2";
GRUB_DEFAULT="0";
GRUB_FALLBACK="1";
fi
}
function get_update_device
{
UPDATE_ROOT=${CURRENT_ROOT%?}${UPDATE_PART}
}
if [ $1 == "preinst" ]; then
# get the current root device
get_current_root_device
# get the device to be updated
get_update_part
get_update_device
# create a symlink for the update process
ln -sf $UPDATE_ROOT /dev/update
sync; /usr/bin/grub-editenv /boot/efi/EFI/BOOT/grubenv set default=$GRUB_DEFAULT; sync;
sync; /usr/bin/grub-editenv /boot/efi/EFI/BOOT/grubenv set fallback=$GRUB_FALLBACK; sync;
fi