add automatic support to armbian-firstlogin
This commit is contained in:
parent
71753f4b3b
commit
cab0022fa9
@ -75,7 +75,17 @@ set_shell() {
|
||||
echo "$i) $o"
|
||||
((i++)) || true
|
||||
done
|
||||
read -r reply
|
||||
if [ -z $PRESET_USER_SHELL ];then
|
||||
read -r reply
|
||||
else
|
||||
reply=1
|
||||
for index in "${!optionsAudits[@]}"; do
|
||||
if [[ "${optionsAudits[$index]}" == "$PRESET_USER_SHELL" ]]; then
|
||||
reply=$(($index + 1))
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
case $reply in
|
||||
"1" | "${optionsAudits[0]}")
|
||||
@ -120,8 +130,12 @@ set_timezone_and_locales() {
|
||||
echo ""
|
||||
unset response
|
||||
while [[ ! "${response}" =~ ^(Y|y|N|n)$ ]]; do
|
||||
read -r -p "Connect via wireless? [Y/n] " response
|
||||
response=${response:-Y}
|
||||
if [ -z $PRESET_CONNECT_WIRELESS ];then
|
||||
read -r -p "Connect via wireless? [Y/n] " response
|
||||
response=${response:-Y}
|
||||
else
|
||||
response=n
|
||||
fi
|
||||
echo "$response"
|
||||
done
|
||||
if [[ "${response}" =~ ^(Y|y)$ ]]; then
|
||||
@ -150,8 +164,12 @@ set_timezone_and_locales() {
|
||||
echo ""
|
||||
unset response
|
||||
while [[ ! "${response}" =~ ^(Y|y|N|n)$ ]]; do
|
||||
read -r -p "Set user language based on your location? [Y/n] " response
|
||||
response=${response:-Y}
|
||||
if [ -z $SET_LANG_BASED_ON_LOCATION ];then
|
||||
read -r -p "Set user language based on your location? [Y/n] " response
|
||||
response=${response:-Y}
|
||||
else
|
||||
response=$SET_LANG_BASED_ON_LOCATION
|
||||
fi
|
||||
echo "$response"
|
||||
done
|
||||
# change it only if we have a match and if we agree
|
||||
@ -167,25 +185,33 @@ set_timezone_and_locales() {
|
||||
|
||||
readarray -t options <<< "${LOCALES}"
|
||||
|
||||
# when having more locales, prompt for choosing one
|
||||
if [[ "${#options[@]}" -gt 1 ]]; then
|
||||
if [ -z $PRESET_LOCALE ];then
|
||||
# when having more locales, prompt for choosing one
|
||||
if [[ "${#options[@]}" -gt 1 ]]; then
|
||||
|
||||
options+=("Skip generating locales")
|
||||
echo -e "\nAt your location, more locales are possible:\n"
|
||||
PS3='Please enter your choice:'
|
||||
select opt in "${options[@]}"; do
|
||||
if [[ " ${options[*]} " == *" ${opt} "* ]]; then
|
||||
LOCALES=${opt}
|
||||
break
|
||||
fi
|
||||
done
|
||||
options+=("Skip generating locales")
|
||||
echo -e "\nAt your location, more locales are possible:\n"
|
||||
PS3='Please enter your choice:'
|
||||
select opt in "${options[@]}"; do
|
||||
if [[ " ${options[*]} " == *" ${opt} "* ]]; then
|
||||
LOCALES=${opt}
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
LOCALES=$PRESET_LOCALE
|
||||
fi
|
||||
|
||||
if [[ "${LOCALES}" != *Skip* ]]; then
|
||||
|
||||
# if TZDATA was not detected, we need to select one
|
||||
if [[ -z ${TZDATA} ]]; then
|
||||
TZDATA=$(tzselect | tail -1)
|
||||
if [ -z $PRESET_TIMEZONE ];then
|
||||
# if TZDATA was not detected, we need to select one
|
||||
if [[ -z ${TZDATA} ]]; then
|
||||
TZDATA=$(tzselect | tail -1)
|
||||
fi
|
||||
else
|
||||
TZDATA=$PRESET_TIMEZONE
|
||||
fi
|
||||
|
||||
timedatectl set-timezone "${TZDATA}"
|
||||
@ -241,7 +267,11 @@ add_user() {
|
||||
REPEATS=3
|
||||
while [ -f "/root/.not_logged_in_yet" ]; do
|
||||
echo -e "\nPlease provide a username (eg. your first name): \c"
|
||||
read -r -e username
|
||||
if [ -z $PRESET_USER_NAME ];then
|
||||
read -r -e username
|
||||
else
|
||||
username=$PRESET_USER_NAME
|
||||
fi
|
||||
if ! grep '^[a-zA-Z][a-zA-Z0-9]*$' <<< "$username" > /dev/null; then
|
||||
echo -e "\n\x1B[91mError\x1B[0m: illegal characters in username"
|
||||
return
|
||||
@ -253,10 +283,18 @@ add_user() {
|
||||
done
|
||||
|
||||
while [ -f "/root/.not_logged_in_yet" ]; do
|
||||
read_password "Create user ($username)"
|
||||
if [ -z $PRESET_USER_PASSWORD ];then
|
||||
read_password "Create user ($username)"
|
||||
else
|
||||
password=$PRESET_USER_PASSWORD
|
||||
fi
|
||||
first_input="$password"
|
||||
echo ""
|
||||
read_password "Repeat user ($username)"
|
||||
if [ -z $PRESET_USER_PASSWORD ];then
|
||||
read_password "Repeat user ($username)"
|
||||
else
|
||||
password=$PRESET_USER_PASSWORD
|
||||
fi
|
||||
second_input="$password"
|
||||
echo ""
|
||||
if [[ "$first_input" == "$second_input" ]]; then
|
||||
@ -269,7 +307,11 @@ add_user() {
|
||||
fi
|
||||
fi
|
||||
echo -e ""
|
||||
read -r -e -p "Please provide your real name: " -i "${RealUserName^}" RealName
|
||||
if [ -z $PRESET_DEFAULT_REALNAME ];then
|
||||
read -r -e -p "Please provide your real name: " -i "${RealUserName^}" RealName
|
||||
else
|
||||
RealName=$PRESET_DEFAULT_REALNAME
|
||||
fi
|
||||
|
||||
adduser --quiet --disabled-password --home /home/"$RealUserName" --gecos "$RealName" "$RealUserName"
|
||||
if [[ -n "$first_input" ]]; then
|
||||
@ -354,8 +396,15 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then
|
||||
trap '' 2
|
||||
REPEATS=3
|
||||
while [ -f "/root/.not_logged_in_yet" ]; do
|
||||
|
||||
read_password "Create root"
|
||||
. /root/.not_logged_in_yet
|
||||
if [ -z $PRESET_ROOT_PASSWORD ];then
|
||||
read_password "Create root"
|
||||
else
|
||||
if [ "$(who am i | awk '{print $2}')" != "tty1" ];then
|
||||
exit
|
||||
fi
|
||||
password=$PRESET_ROOT_PASSWORD
|
||||
fi
|
||||
|
||||
# only allow one login. Once you enter root password, kill others.
|
||||
loginfrom=$(who am i | awk '{print $2}')
|
||||
@ -363,7 +412,11 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then
|
||||
|
||||
first_input="$password"
|
||||
echo ""
|
||||
read_password "Repeat root"
|
||||
if [ -z $PRESET_ROOT_PASSWORD ];then
|
||||
read_password "Repeat root"
|
||||
else
|
||||
password=$PRESET_ROOT_PASSWORD
|
||||
fi
|
||||
second_input="$password"
|
||||
echo ""
|
||||
if [[ "$first_input" == "$second_input" ]]; then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user