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

# set the flag to show color output
BOOTUP=color
# some parameters for color output.
[ -z "$SETCOLOR_SUCCESS" ] && SETCOLOR_SUCCESS="echo -en \\033[1;32m"
[ -z "$SETCOLOR_FAILURE" ] && SETCOLOR_FAILURE="echo -en \\033[1;31m"
[ -z "$SETCOLOR_WARNING" ] && SETCOLOR_WARNING="echo -en \\033[1;33m"
[ -z "$SETCOLOR_NORMAL"  ] && SETCOLOR_NORMAL="echo -en \\033[0;39m"

# Append the PATH and default LANG in system.
echo "export PATH=/opt/drbl/sbin:/opt/drbl/bin:\$PATH" >> /etc/profile
echo "export PATH=/opt/drbl/sbin:/opt/drbl/bin:\$PATH" >> /etc/bash.bashrc
# Clean /etc/motd to avoid the following message is missing.
echo -n "" > /etc/motd
# Force to remount /live_media as rw, since it's rw device, like USB disk, we can try to save clonezilla image.
mount -o remount,rw /live_media
# We need to know ocsroot and functions in ocs-functions
. /opt/drbl/sbin/drbl-conf-functions
. /opt/drbl/sbin/ocs-functions
# Prepare default ocsroot.
if mkdir -p /live_media/$ocsroot 2>/dev/null; then
  mkdir -p `dirname $ocsroot`
  ln -fs /live_media/$ocsroot $ocsroot
else
  # mkdir a mount point to be used later.
  mkdir -p $ocsroot
fi
ask_language_if_supported_with_bterm
[ -z "$ocs_lang" ] && ocs_lang=en
ask_and_load_lang_set $ocs_lang
# run clonezilla
ocs-sr -x -l $ocs_lang -p true

# show prompt
show-general-ocs-live-prompt
