#!/bin/bash
# Test if live-config and upstart are used. If so, we have to wait for live-config to be finished. Otherwise the clonezilla-related process might be faster than live-config. E.g. if the "sudo" config (/lib/live/config/003-sudo) is not yet run, but S03prep-drbl-clonezilla is run, the autologin account won't be found, then the clonezilla auto startup config in the autologin account won't be generated.
if [ -e /lib/live/config.sh -a -e /etc/init/live-config.conf ]; then
  echo "Waiting for live-config to be finished..."
  to_wait=""
  while [ -z "$to_wait" ]; do
    # Here we choose config /lib/live/config/*login as the decision process,
    # i.e. after /lib/live/config/*login is run, we can start clonezilla live related process.
    if [ -e /var/lib/live/config/login ]; then
      echo "live-config is finished."
      to_wait="no"
    else
      sleep 0.2
    fi
  done
fi
echo "Starting to prepare Clonezilla live env..."
