#!/bin/bash
#This service is started only if the X server is not started or then xinit is killed

export PATH="./:/hive/bin:/hive/sbin:$PATH"

#[ -t 1 ] &&
#. colors #use them anyway

source /etc/environment
[[ -f $RIG_CONF ]] && source $RIG_CONF

function console_restart() {
    # clear trap
    trap - EXIT
	echo "Restarting console..."
	systemctl restart hive-console
}

# set trap
#trap 'console_restart' EXIT

systemctl status getty@tty1 > /dev/null 2>&1 && HIDDEN_MODE_ENABLE=1

if [[ $HIDDEN_MODE_ENABLE == 1 ]]; then
	cat /dev/null > /etc/issue
	systemctl start getty@tty1
else
        if [[ ! "$(grep 'Hive OS' /etc/issue)" ]]; then
		echo "Hive OS" >> /etc/issue
	fi
	sudo -i bash -c "firstrun; motd boot; bash"
fi
