post_install() {
    # Configure fstab
    echo "Configuring /etc/fstab..."
    echo "LABEL=BOOT_MNJRO  /boot   vfat    defaults,noexec,nodev,showexec     0   0" >> /etc/fstab

    # Configure mkinitcpio.conf
    echo "Configuring /etc/mkinitcpio.conf..."
    sed -i s/"^MODULES=()"/"MODULES=(rtc_rk808 rockchipdrm panel_edp pwm_bl)"/g /etc/mkinitcpio.conf
    sed -i s/"^HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)"/"HOOKS=(base udev plymouth autodetect modconf block filesystems keyboard fsck)"/g \
        /etc/mkinitcpio.conf

    # Set Plymouth Manjaro theme
    if [[ -f /usr/bin/plymouth-set-default-theme && -d /usr/share/plymouth/themes/materia-manjaro ]]; then
        plymouth-set-default-theme -R materia-manjaro
    fi

}

post_upgrade() {

    # Provide instructions about the panel modules
    if ! grep -q '^MODULES=(.*rockchipdrm panel_edp pwm_bl)' /etc/mkinitcpio.conf; then
        echo "To have the boot screen visible as early as possible, please ensure that"
        echo "'rockchipdrm panel_edp pwm_bl' are found at the end of the 'MODULES' list"
        echo "in /etc/mkinitcpio.conf and rebuild the initcpio images."
        echo "You can configure the default list of early loaded modules by running:"
        echo "# sed -i 's/^MODULES=(.*)/MODULES=(rtc_rk808 rockchipdrm panel_edp pwm_bl)/g' /etc/mkinitcpio.conf"
        echo "# mkinitcpio -P"

        # Don't check for the presence of RTC module, to avoid
        # presenting confusing instructions to the users
        return
    fi

    # Provide instructions about the RTC module
    if ! grep -q '^MODULES=(.*rtc_rk808' /etc/mkinitcpio.conf; then
        echo "To prevent journal corruption on boot, please add 'rtc_rk808' to the start"
        echo "of the 'MODULES' list in /etc/mkinitcpio.conf and rebuild the initcpio images."
        echo "You can do this by running:"
        echo "# sed -i 's/^MODULES=(/MODULES=(rtc_rk808 /g' /etc/mkinitcpio.conf"
        echo "# mkinitcpio -P"
    fi
}

