#!/bin/bash
# Author: Steven Shiau <steven _at_ nchc org tw>
# License: GPL

# To avoid there is no input output in rc running, we add this one:
exec </dev/console >/dev/console 2>&1

# Decide the path for live media.
# casper 1.77+debian-7 uses /live_media, 1.110 uses /cdrom
# live-initramfs uses /live/image.
if [ -f "/cdrom/casper/filesystem.squashfs" ]; then
  LIVE_MEDIA="cdrom"
elif [ -f "/live_media/casper/filesystem.squashfs" ]; then
  LIVE_MEDIA="live_media"
elif [ -f "/live/image/filesystem.squashfs" ]; then
  LIVE_MEDIA="live/image"
else
  echo "///WARNING/// filesystem.squashfs not found! No idea where is LIVE_MEDIA!!!"
fi

# This script will run those scripts in dir /$LIVE_MEDIA/ocs-live.d
[ ! -d "/$LIVE_MEDIA/ocs-live.d/" ] && exit 1
for script in /$LIVE_MEDIA/ocs-live.d/S[0-9][0-9]*; do
  . $script
done
