armbian-build/scripts/check_first_login.sh

42 lines
1.8 KiB
Bash

#!/bin/bash
# only do this for interactive shells
if [ "$-" != "${-#*i}" ]; then
if [ -f "$HOME/.not_logged_in_yet" ]; then
echo -e "\n\e[0;31mThank you for choosing Armbian! Support: \e[1m\e[39mwww.armbian.com\x1B[0m\n"
echo -e "Creating new account. Please provide a username (eg. your forename): \c"
read username
RealUserName="$(echo "${username}" | tr '[:upper:]' '[:lower:]' | tr -d -c '[:alpha:]')"
adduser ${RealUserName} || reboot
for additionalgroup in sudo netdev audio video dialout plugdev ; do
usermod -aG ${additionalgroup} ${RealUserName}
done
rm -f "$HOME/.not_logged_in_yet"
RealName="$(awk -F":" "/^${RealUserName}:/ {print \$5}" </etc/passwd | cut -d',' -f1)"
echo -e "\nDear ${RealName}, your account ${RealUserName} has been created and is sudo enabled."
echo -e "Please use this account for your daily work from now on.\n"
# check for H3 since this is FAQ stuff, add other boards later
HARDWARE=$(awk '/Hardware/ {print $3}' </proc/cpuinfo)
if [ "X${HARDWARE}" = "Xsun8i" ]; then
setterm -default
echo -e "\nYour display settings are currently 720p (1280x720). To change this use the"
echo -e "h3disp utility. Do you want to change display settings now? [yN] \c"
read -n1 ConfigureDisplay
if [ "X${ConfigureDisplay}" = "Xy" -o "X${ConfigureDisplay}" = "XY" ]; then
echo -e "\n" ; /usr/local/bin/h3disp
fi
fi
# check whether desktop environment has to be considered
if [ -f /etc/init.d/nodm ] ; then
sed -i "s/NODM_USER=\(.*\)/NODM_USER=${RealUserName}/" /etc/default/nodm
sed -i "s/NODM_ENABLED=\(.*\)/NODM_ENABLED=true/g" /etc/default/nodm
if [ "X${ConfigureDisplay}" != "Xy" -a "X${ConfigureDisplay}" != "XY" ]; then
echo -e "\n\e[1m\e[39mNow starting desktop environment...\x1B[0m\n"
sleep 3
service nodm start
fi
fi
fi
fi