#!/bin/sh
#
# workarounds for glitches in the system

set -ex

# some versions of snappy left this file behind after a upgrade
# and that will confuse the next upgrade which will run "SyncBootfiles"
# and copy the kernel around. We never need this file after a
# successful boot
# 
rm -f /writable/cache/hardware.yaml


# bug #1498620, double writable directores are created:
#  /etc/ppp/ppp and /etc/modprobe.d/modprobe.d
if [ -d /etc/ppp/ppp ]; then
   mv /etc/ppp/ppp/* /etc/ppp
   rmdir /etc/ppp/ppp
fi
if [ -d /etc/modprobe.d/modprobe.d ]; then
   mv /etc/modprobe.d/modprobe.d/* /etc/modprobe.d
   rmdir /etc/modprobe.d/modprobe.d
fi

# fwupdate needs this directory
if [ -d /boot/efi/EFI/ubuntu/ ] && ! [ -d /boot/efi/EFI/ubuntu/fw ]; then
    mkdir -p  /boot/efi/EFI/ubuntu/fw
fi
