#!/bin/bash
# Steven Maresca
# lightyear4 @t gmail dot com
#
# This script is a wrapper around thunderbird that prompts 
# the user for their username and email address prior to 
# starting thunderbird; this allows prefs.js in their default
# profile to be populated beforehand and thereby automate
# configuration. 
#
# Note that it uses zenity, which is a gnome-specific gtk based
# Xdialog/gdialog replacement.  Converting this script to work
# with either would be trivial.
#
# Start thunderbird-wrapper

export netid
export email

zenity --info --text "To access your HuskyMail Account, please enter your NetID and email address."

netid=`zenity --entry \
        --title="Please enter your NetID" \
        --text="Enter your _NetID:"`

email=`zenity --entry \
        --title="Please enter your email address" \
        --text="Enter your _Email address up to, but not including, @uconn.edu:"`

#echo $netid, $password 

sed "s/netid/$netid/g" prefs.js > /tmp/prefs.js
sed "s/studentemail/$email/g" /tmp/prefs.js > /tmp/prefs2.js

mv /tmp/prefs2.js /home/ubuntu/.mozilla-thunderbird/0aufpcox.default/prefs.js

thunderbird &

# End thunderbird-wrapper
