2017-03-28 02:54:50 +00:00
|
|
|
#!/bin/bash
|
2016-08-31 02:20:00 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
trap true HUP INT QUIT TSTP
|
2016-11-09 22:59:39 +00:00
|
|
|
echo_on () { stty echo; }
|
|
|
|
trap echo_on EXIT
|
2016-08-31 02:20:00 +00:00
|
|
|
|
2016-09-13 03:44:30 +00:00
|
|
|
# agetty only sets ICRNL if it has read the username and seen whether
|
|
|
|
# it was terminated by CR or NL. We pass -n to agetty so that hasn't
|
|
|
|
# happened and need to force it on. Yay UNIX!
|
2016-11-09 01:16:59 +00:00
|
|
|
stty icrnl -echo
|
2016-09-13 03:44:30 +00:00
|
|
|
|
2016-10-07 15:34:45 +00:00
|
|
|
if [ "$(snap managed)" = "true" ]; then
|
2016-11-09 01:33:41 +00:00
|
|
|
# check if we have extrausers that have no password set
|
|
|
|
if grep -qE '^[-a-z0-9+.-_]+:x:' /var/lib/extrausers/passwd && ! grep -qE '^[-a-z0-9+.-_]+:\$[0-9]+\$.*:' /var/lib/extrausers/shadow; then
|
2017-02-17 02:08:12 +00:00
|
|
|
tty=$(tty)
|
|
|
|
tty=$(echo ${tty#/dev/} | tr '/' '-')
|
2017-03-28 02:54:50 +00:00
|
|
|
readargs=()
|
|
|
|
filepath="/run/console-conf/login-details-${tty}.txt"
|
|
|
|
if [ ! -f ${filepath} ]; then
|
2016-11-09 22:59:39 +00:00
|
|
|
mkdir -p /run/console-conf
|
2017-03-28 02:54:50 +00:00
|
|
|
set +e
|
|
|
|
/usr/share/subiquity/console-conf-write-login-details > ${filepath}.tmp
|
|
|
|
rval=$?
|
|
|
|
set -e
|
|
|
|
# A exit code of 2 from console-conf-write-login-details
|
|
|
|
# means there are no scope global IP addresses. It will
|
|
|
|
# have printed a message saying that you can't log in
|
|
|
|
# until the device gets an IP address so we display that
|
|
|
|
# but check every 5 seconds if an ip address has appeared.
|
|
|
|
if [ $rval -eq 0 ]; then
|
|
|
|
mv ${filepath}.tmp ${filepath}
|
|
|
|
elif [ $rval -eq 2 ]; then
|
|
|
|
mv ${filepath}.tmp ${filepath}.noip
|
|
|
|
filepath=${filepath}.noip
|
|
|
|
readargs=(-t 5)
|
|
|
|
else
|
|
|
|
exit $rval
|
|
|
|
fi
|
2016-11-09 22:59:39 +00:00
|
|
|
fi
|
2017-03-28 02:54:50 +00:00
|
|
|
cat $filepath
|
|
|
|
set +e
|
|
|
|
while :; do
|
|
|
|
read "${readargs[@]}" REPLY
|
|
|
|
if [ $? -le 128 ]; then
|
|
|
|
# If we didn't time out, re-display everything.
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
if ip addr show | grep -qE "scope global"; then
|
|
|
|
# If we timed out, but it appears that we may now have
|
|
|
|
# an IP address, re-display everything.
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
2016-11-09 01:33:41 +00:00
|
|
|
else
|
|
|
|
touch /var/lib/console-conf/complete
|
|
|
|
fi
|
2016-10-04 04:12:51 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2016-08-31 02:20:00 +00:00
|
|
|
cat /usr/share/subiquity/console-conf-wait
|
|
|
|
read REPLY
|
|
|
|
exec console-conf "$@"
|