#!/bin/sh  # can't assume bash yet

if [ ! -d /boot/root.overlay ]; then
    logger -s -t rc.local.txt cant find root overlay in /boot
else
    rsync -avP /boot/root.overlay/ /
    ln -s /etc/systemd/system/raspberrypi-initial-setup.service \
        /etc/systemd/system/multi-user.target.wants/raspberrypi-initial-setup.service
    # we only need to run once
    rm -rf /boot/rc.local.txt /boot/root.overlay
fi

reboot
