#!/bin/bash
# bash is used because easydialog requires bash for some functions

#$lessdisks_path/usr/sbin/lessdisks-terminal-setup

# this script is run when configuring a new terminal
# typically this is only used for non-graphical terminals.
# it merely calls the lessdisks-setup script on the server anyways.

# copyright 2004 vagrant@freegeek.org, distributed under the terms of the
# GNU General Public License version 2 or any later version.

lessdisks_setup="/usr/sbin/lessdisks-setup"

. /etc/lessdisks/server.config

if [ -z "$rw" ]
then
  rw="/var/state/lessdisks/"
fi

if [ -z "$export_type" ]
then
  echo "WARNING: no export type defined..."
else
  # TODO check to make sure export is not already running..
  . /usr/sbin/lessdisks-export
fi

. $rw/etc/config

PATH="/usr/local/lib/easydialog:/usr/share/easydialog:/usr/lib/easydialog:$PATH" . easydialog.sh

if [ -z $(which ssh) ]
then
  msgBox "ssh not found" "please install ssh into the terminal root filesystem, $lessdisks_path"
  exit 1
fi

inputBox "which user" "please enter a username on $disk_server in the group $lessdisks_group"

username="$REPLY"

if [ -z "$DISPLAY" ]
then
  ssh="ssh"
else
  ssh="ssh -X"
fi

# the -t option forces tty allocation, without it easydialog
# menus fail
$ssh -t $username@$disk_server $lessdisks_setup $ipaddress
