post_install() {
	# Enable the service
	systemctl enable orangepi800-post-install.service

	# add uwe5622-net.conf to /etc/modules-load.d/
	echo "Editing uwe5622-net.conf..."
	cat <<-EOF > "/etc/modules-load.d/uwe5622-net.conf"
	sprdbt_tty
	sprdwl_ng
	EOF

	# add for wiringOP
	echo "Editing orangepi-release..."
	cat <<-EOF > "/etc/orangepi-release"
	BOARD=orangepi800
	EOF

	# Configure mkinitcpio.conf
	if [ -f /etc/mkinitcpio.conf ] && \
		grep -q '^MODULES=()' /etc/mkinitcpio.conf; then
		echo "Configuring /etc/mkinitcpio.conf..."
		sed -i s/"^MODULES=()"/"MODULES=(rtc_rk808 rockchipdrm)"/g /etc/mkinitcpio.conf
	fi

	[[ -f /usr/share/xsessions/kodi.desktop ]] && rm /usr/share/xsessions/kodi.desktop

	# Configure extlinux.conf
	if [ -f /boot/extlinux/extlinux.conf ] && \
		grep -q -F 'bootsplash.bootfile=bootsplash-themes/manjaro/bootsplash' /boot/extlinux/extlinux.conf; then
		echo "Configuring /boot/extlinux/extlinux.conf..."
		sed -i s!"bootsplash.bootfile=bootsplash-themes/manjaro/bootsplash"!"quiet splash plymouth.ignore-serial-consoles"!g \
	         /boot/extlinux/extlinux.conf
	fi

        echo "LABEL=BOOT_MNJRO  /boot   vfat    defaults        0       0" >> /etc/fstab
        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
        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
}
