#!/bin/sh
#
# Script for starting one or more ssh sessions
#

#
# Get the lts.conf entries, and assign them to shell
# variables.
#
. /usr/share/ltsp/ltsp_config

#
# Get the IP address of the host to ssh into.
# First look for 'SSH_HOST', if not specified, then
# look for 'SERVER'. If that isn't specified, then use
# the default of '192.168.67.1'
#

unset SSH_ARGS
if [ -n "$1" ]; then
    SSH_ARGS=$*
else
    SSH_HOST=${SSH_HOST:-"server"}
fi
SSH_ARGS="$SSH_ARGS $SSH_HOST"

export TERM=linux           # Setup the terminal type

# Clear the screen, to place cursor at the top
clear

# Get the username
echo -n "Username: "
read SSH_USER

SSH_ARGS="$SSH_ARGS -l $SSH_USER"

# Launch ssh 
ssh ${SSH_ARGS}

if [ "$?" != 0 ]; then
    # Brief pause, in case ssh had errors to report
    echo -n "Please wait..."
    sleep 1
fi
