#!/bin/sh -e

lxc-wait -n android -s RUNNING -t 30
containerpid="$(lxc-info -n android -p -H)"
if [ -n "$containerpid" ]; then
    while true; do
        [ -f /proc/$containerpid/root/dev/.coldboot_done ] && break
        sleep 0.1
    done

    # Allow custom properties before announcing that the boot is completed
    if [ -f /custom/custom.prop ]; then
        while [ ! -e /dev/socket/property_service ]; do sleep 0.1; done
        grep "^custom\." /custom/custom.prop | sed 's/=/ /' | while read property value; do
            setprop $property $value
        done
    fi
else
    exit 1
fi
