incorporating improvements from awitter
authorChris Sharp <csharp@georgialibraries.org>
Tue, 29 Apr 2014 13:41:50 +0000 (09:41 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Tue, 29 Apr 2014 13:41:50 +0000 (09:41 -0400)
pines-ubuntu.sh

index a4fe8f8..233cc80 100755 (executable)
 # A program to install and configure the Evergreen Staff Client on Ubuntu Linux.
 
 # http://gapines.org/updates/clients/2.5.1pines.0_i686.tar.bz2
-WORKDIR=`pwd`
+_VERSION="0.4"
+export WORKDIR=`pwd`
 ARCH=`uname -p`
-CLIENT="2.5.1pines.0_$ARCH.tar.bz2"
-CLIENT_URL_BASE="http://gapines.org/updates/clients"
-CLIENT_DIR="$HOME/Evergreen_Staff_Client"
+export CLIENT="2.5.1pines.0_$ARCH.tar.bz2"
+export CLIENT_URL_BASE="http://gapines.org/updates/clients"
+export CLIENT_DIR="$HOME/Evergreen_Staff_Client"
 UBUNTU_VERSION=`lsb_release -r | cut -d':' -f2 | sed 's/\t//g'`
 DESKTOP="$HOME/Desktop"
 DE="$DESKTOP_SESSION"
-EPSON_URL="http://download.epson-biz.com/modules/pos/index.php?page=single_soft&cid=3839&scat=32&pcat=3&pid=36"
-DOWNLOAD_DIR="$HOME/Downloads"
-EPSON_TAR="tmx-cups-2.0.0.0.tar.gz"
+EPSON_URL="https://pos.epson.com/developers/LicenseAgreement.htm?AssetId=28724"
+export DOWNLOAD_DIR="$HOME/Downloads"
+export EPSON_ARCHIVE="tmx-cups-2.0.0.0.zip"
 EPSON_DIR="tmx-cups"
+export PRG_NAME="Evergreen Staff Client Setup"
+TERM_SET="-bg white -fg blue -fn 10x20"
 
-DownloadExtract() {
-if [ ! -d "$CLIENT_DIR" ]; then
-    wget $CLIENT_URL_BASE/$CLIENT
-    mkdir -p "$CLIENT_DIR"
-    cd $CLIENT_DIR || {
-    echo "Could not change to $CLIENT_DIR."
-    exit 1;
+zenity --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="This program will install and configure \n the Evergreen Staff Client on Ubuntu Linux." 
+
+GetClient () { ### Run the process to download and extract the Evergreen Staff Client.
+wget --progress=bar:force  "$CLIENT_URL_BASE/$CLIENT" 2>&1 | zenity --width=350 --title="Downloading staff client..." --progress --auto-close --auto-kill
+mkdir -p "$CLIENT_DIR"
+cd $CLIENT_DIR || {
+zenity --title="$PRG_NAME" --height="50" --width="350" --no-wrap --error --text="Could not change to $CLIENT_DIR."
+exit 1;
+cd $WORKDIR
+}
+xterm $TERM_SET -e "echo extracting client...; tar jxvf $WORKDIR/$CLIENT"
 }
-    tar xjf $WORKDIR/$CLIENT
+
+
+DownloadExtract() { ### Download and extract the Evergreen Staff Client.
+if [ ! -d "$CLIENT_DIR" ]; then
+    GetClient
 else
-    echo "Client Directory Exists, skipping Download"
+    zenity --title="$PRG_NAME" --height="50" --width="350" --no-wrap --question --text="Client Directory Exists, Would you like Setup to download and extract the client again?";RE_DOWNLOAD="$?"
+    if [ "$RE_DOWNLOAD" = "0" ]; then
+       rm -rf "$CLIENT_DIR"
+       rm $CLIENT
+       GetClient
+    fi
 fi
 }
 
-ConfigureLubuntu() {
-echo "Configuring for Lubuntu..."
-sleep 2
-sudo apt-get update && sudo apt-get -y install imagemagick
+ConfigureLubuntu() { ### Install Imagemagick and configure client desktop icon.
+zenity --title="$PRG_NAME" --height="50" --width="350" --timeout="2" --no-wrap --info --text="Configuring for Lubuntu..."
+
+if dpkg -l | grep 'imagemagick[[:blank:]]' | grep -q ii ; then
+    zenity --title="$PRG_NAME" --height="50" --width="350" --no-wrap --timeout="3" --info --text="ImageMagick is already installed"
+else
+    xterm $TERM_SET -e "echo;echo Installing Imagemagick.;echo;echo;echo;echo Keystrokes will not be displayed when typing your password;sudo apt-get update && sudo apt-get -y install imagemagick"
+fi
+
 convert $CLIENT_DIR/evergreen.ico $CLIENT_DIR/evergreen.png
+
 cat <<EOF > $DESKTOP/Evergreen
 [Desktop Entry]
 Encoding=UTF-8
@@ -64,40 +86,38 @@ StartupNotify=false
 EOF
 }
 
-DownloadEpson() {
-clear
-echo
-echo "This will now open a browser window where you can download"
-echo "the Epson TM-V receipt printer driver.  Please choose to save"
-echo "the file, then close the browser to continue."
+DownloadEpson() { ### Download and install the Epson TM-V receipt printer driver.
+zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME Epson Driver Download" --height="50" --width="360" --no-wrap --info --text="Epson *requires* you to accept a license agreement to download the TM88-V printer driver."
+zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="Setup will now open a browser window where you can download\nthe Epson TM88-V receipt printer driver.  Please choose to save\nthe file, then close the browser to continue."
 sensible-browser $EPSON_URL
-if [ -e $DOWNLOAD_DIR/$EPSON_TAR ]; then
+if [ -e $DOWNLOAD_DIR/$EPSON_ARCHIVE ]; then
     cd $HOME
-    tar xzf $DOWNLOAD_DIR/$EPSON_TAR
+    xterm $TERM_SET -e "tar zxvf $DOWNLOAD_DIR/$EPSON_ARCHIVE"
     cd $EPSON_DIR || {
-    echo "Could not change to $EPSON_DIR."
+    zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --error --text="Could not change to $EPSON_DIR."
+    zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --timeout="3" --no-wrap --error --text="Exiting Setup..."
     exit 1;
     }
     echo
     echo
-    echo "Starting Epson installer."
+    zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --timeout="2" --no-wrap --info --text="Starting Epson installer."
     if [ "$ARCH" = "i386" ]; then
-        echo "Choose Ubuntu 12.04 (32-bit) when prompted by the installer script."
+       zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="Choose Ubuntu 12.04 (32-bit) when prompted by the installer script."
     elif [ "$ARCH" = "x86_64" ]; then
-        echo "Choose Ubuntu 12.04 (64-bit) when prompted by the installer script."
+       zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="Choose Ubuntu 12.04 (64-bit) when prompted by the installer script."
     else
-        echo "System architecture not detected.  Please choose Ubuntu 12.04 for"
-        echo "your system's architecture when prompted by the installer script"
+       zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="System architecture not detected.  Please choose Ubuntu 12.04 for\nyour system's architecture when prompted by the installer script"
     fi
-    ./install.sh && echo "Epson installation complete."
+    xterm $TERM_SET "./install.sh && zenity --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="Epson installation complete.""
 else
-    echo "Epson driver package not downloaded to expected location."
-    echo "Please download and install the Epson driver manually."
+    zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --error --text="Epson driver package not downloaded to expected location.\nPlease download and install the Epson driver manually."
+    zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --timeout="3" --no-wrap --info --text="Exiting Setup..."
     exit 0;
 fi
 }
 
 DownloadExtract
+
 if [ "$DE" = "Lubuntu" ]; then
     ConfigureLubuntu
 fi