#!/bin/bash
#
# Copyright (C) 2017 ~ 2018 Deepin Technology Co., Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Read kernel parameter and set global variables.

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

auto_install_mode=0

cd_rom() {
    if [ -d /lib/live/mount/medium/live ]; then
        CDROM=/lib/live/mount/medium
    else
        CDROM=/run/live/medium
    fi
    echo ${CDROM}
}

parse_cmdline() {
  for x in $(cat /proc/cmdline); do
    case $x in
      install-mode-cli=true)
        echo $x
        cli_mode=true
        ;;
	auto-deepin-installer)
        auto_install_mode=1
        ;;
      esac
  done
}

parse_cmdline

if [ x"$cli_mode" = xtrue ]; then
    systemctl stop lightdm
    chvt 2
    systemctl restart deepin-installer-cli
else
    if [ $auto_install_mode -eq 1 ]; then
       /usr/lib/live/config/1081-deepin-auto-install
    else
       /usr/lib/live/config/1082-deepin-livecd true
    fi
fi

