#!/bin/bash
#
# Initial script for Live operating system
# This script are launching before starting init from linux-live script.
# Current dir allways must be set to root (/)
# All system path must be relative, except initrd dirs

ENABLED=yes
[[ ${ENABLED} == "yes" ]] || exit 0

PATH=.:/:/usr/bin:/usr/local/bin:/usr/local/sbin
DEBUGMODE=no

[ -d ${ROOTFS}usr/lib/ublinux ] || ROOTFS=/
. ${ROOTFS}usr/lib/ublinux/functions

debug_mode "$0" "$@"

PATH_LIB_UBBOOT="${ROOTFS}usr/lib/ubboot"

#Profile updating
OS_RELEASE_PRETTY_NAME="UBLinux 0000 Unknown (x)"
PATH_VERSION=$(ls /memory/layer-base/0/VERSION* 2>/dev/null | head -1)
[[ -n "${PATH_VERSION}" ]] || PATH_VERSION="$(ls /VERSION* 2>/dev/null | head -1)"
[[ -n "${PATH_VERSION}" ]] && OS_RELEASE_PRETTY_NAME=$(head -1 "${PATH_VERSION}" 2>/dev/null )

echo "${OS_RELEASE_PRETTY_NAME}" > ${ROOTFS}etc/ublinux-release
${PATH_LIB_UBBOOT}/ubdistconv -l  ${OS_RELEASE_PRETTY_NAME} > ${ROOTFS}etc/lsb-release
${PATH_LIB_UBBOOT}/ubdistconv -o  ${OS_RELEASE_PRETTY_NAME} > ${ROOTFS}usr/lib/os-release
