#!/bin/sh

if ischroot ; then
    echo "ostree install kernel in chroot"
else
    if ! mount | grep /sysroot/ostree > /dev/null;then
        echo "system not ostree type"
        exit 1
    fi
    version="$1"
    update_dir=$(realpath "$0")
    export version
    export update_dir
    echo "ostree update kernel ..."
    if [ ! -x "/usr/bin/ostree-update-kernel.py" ]; then
        echo "ostree-update-kernel file not found!"
        exit 1
    fi
    python3 /usr/bin/ostree-update-kernel.py update
    if [ $? -eq 0 ]; then
        echo "ostree update kernel success!"
    else
        echo "ostree update kernel fail"
    fi
fi
