bootstrap should not fail if no tty present
This commit is contained in:
parent
499b30d175
commit
603684211f
@ -4,16 +4,21 @@
|
||||
|
||||
# read the transmitted data from STDIN
|
||||
cleanup_on_bootstrap_exit() {
|
||||
[ ! -z "$saved_tty_settings" ] && command stty "$saved_tty_settings"
|
||||
[ -n "$saved_tty_settings" ] && command stty "$saved_tty_settings" 2> /dev/null
|
||||
}
|
||||
|
||||
die() { printf "\033[31m%s\033[m\n\r" "$*" > /dev/stderr; cleanup_on_bootstrap_exit; exit 1; }
|
||||
dsc_to_kitty() { printf "\033P@kitty-$1|%s\033\\" "$(printf "%s" "$2" | base64 | tr -d \\n)" > /dev/tty; }
|
||||
debug() { dsc_to_kitty "print" "debug $1"; }
|
||||
echo_via_kitty() { dsc_to_kitty "echo" "$1"; }
|
||||
saved_tty_settings=$(command stty -g)
|
||||
command stty raw min 1 time 0 -echo || die "stty not available"
|
||||
saved_tty_settings=$(command stty -g 2> /dev/null < /dev/tty)
|
||||
tty_ok="n"
|
||||
[ -n "$saved_tty_settings" ] && tty_ok="y"
|
||||
|
||||
if [ "$tty_ok" = "y" ]; then
|
||||
command stty raw min 1 time 0 -echo 2> /dev/null < /dev/tty || die "stty not available"
|
||||
trap 'cleanup_on_bootstrap_exit' EXIT
|
||||
fi
|
||||
|
||||
data_started="n"
|
||||
data_complete="n"
|
||||
@ -31,7 +36,7 @@ fi
|
||||
# ensure $HOME is set
|
||||
if [ -z "$HOME" ]; then HOME=~; fi
|
||||
# ensure $USER is set
|
||||
if [ -z "$USER" ]; then USER=$(whoami); fi
|
||||
if [ -z "$USER" ]; then USER=$(whoami 2> /dev/null); fi
|
||||
|
||||
# ask for the SSH data
|
||||
data_password="DATA_PASSWORD"
|
||||
@ -39,7 +44,7 @@ password_filename="PASSWORD_FILENAME"
|
||||
data_complete="n"
|
||||
leading_data=""
|
||||
|
||||
dsc_to_kitty "ssh" "hostname=$hostname:pwfile=$password_filename:pw=$data_password"
|
||||
[ "$tty_ok" = "y" ] && dsc_to_kitty "ssh" "hostname=$hostname:pwfile=$password_filename:pw=$data_password"
|
||||
record_separator=$(printf "\036")
|
||||
|
||||
mv_files_and_dirs() {
|
||||
@ -102,8 +107,9 @@ get_data() {
|
||||
untar_and_read_env "$size"
|
||||
}
|
||||
|
||||
if [ "$tty_ok" = "y" ]; then
|
||||
get_data
|
||||
command stty "$saved_tty_settings"
|
||||
command stty "$saved_tty_settings" 2> /dev/null
|
||||
saved_tty_settings=""
|
||||
if [ -n "$leading_data" ]; then
|
||||
# clear current line as it might have things echoed on it from leading_data
|
||||
@ -129,6 +135,7 @@ if [ -x "$(command -v tic)" ]; then
|
||||
rc=$?
|
||||
if [ "$rc" != "0" ]; then die "$tic_out"; fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
login_shell_is_ok() {
|
||||
@ -208,6 +215,14 @@ execute_with_python() {
|
||||
# If a command was passed to SSH execute it here
|
||||
EXEC_CMD
|
||||
|
||||
if [ "$tty_ok" = "n" ]; then
|
||||
if [ -z "$(command -v stty)" ]; then
|
||||
printf "%s\n" "stty missing ssh kitten cannot function" > /dev/stderr
|
||||
else
|
||||
printf "%s\n" "stty failed ssh kitten cannot function" > /dev/stderr
|
||||
fi
|
||||
fi
|
||||
|
||||
LOGIN_SHELL="OVERRIDE_LOGIN_SHELL"
|
||||
if [ -n "$LOGIN_SHELL" ]; then
|
||||
login_shell="$LOGIN_SHELL"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user