]> git.evergreen-ils.org Git - contrib/pines.git/blob - pines-ubuntu.sh
add local git tar script
[contrib/pines.git] / pines-ubuntu.sh
1 #!/bin/bash
2
3 # Copyright (C) 2014-2016 Georgia Public Library Service
4 # Chris Sharp <csharp@georgialibraries.org>
5 # Andy Witter <awitter@georgialibraries.org>
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU General Public License as published by
9 #    the Free Software Foundation, either version 3 of the License, or
10 #    (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU General Public License for more details.
16 #
17 #    You should have received a copy of the GNU General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 # A program to install and configure the Evergreen Staff Client on Ubuntu Linux.
21
22 # http://gapines.org/updates/clients/2.5.1pines.0_i686.tar.bz2
23 _VERSION="0.08"
24 export WORKDIR=`pwd`
25 ARCH=`uname -p`
26 export CLIENT="2.7.2pines.0_$ARCH.tar.bz2"
27 export CLIENT_URL_BASE="http://gapines.org/updates/clients"
28 export CLIENT_DIR="$HOME/Evergreen_Staff_Client"
29 UBUNTU_VERSION=`lsb_release -r | cut -d':' -f2 | sed 's/\t//g'`
30 DESKTOP="$HOME/Desktop"
31 DE="$DESKTOP_SESSION"
32 EPSON_URL="https://ftp.epson.com/drivers/pos/tmx-cups-2.0.0.0.zip"
33 export DOWNLOAD_DIR="$HOME/Downloads"
34 export EPSON_ARCHIVE="tmx-cups-2.0.0.0.zip"
35 export EPSON_UNZIP_DIR="tmx-cups-2.0.0.0"
36 EPSON_DIR="tmx-cups"
37 export PRG_NAME="Evergreen Staff Client Setup"
38 TERM_SET="-bg white -fg blue -fn 10x20"
39
40 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." 
41
42 GetClient () { ### Run the process to download and extract the Evergreen Staff Client.
43 wget --progress=bar:force  "$CLIENT_URL_BASE/$CLIENT" 2>&1 | zenity --width=350 --title="Downloading staff client..." --progress --auto-close --auto-kill
44 mkdir -p "$CLIENT_DIR"
45 cd $CLIENT_DIR || {
46 zenity --title="$PRG_NAME" --height="50" --width="350" --no-wrap --error --text="Could not change to $CLIENT_DIR."
47 cd $WORKDIR
48 exit 1;
49 }
50 xterm $TERM_SET -e "echo extracting client...; tar jxvf $WORKDIR/$CLIENT"
51 }
52
53
54 DownloadExtract() { ### Download and extract the Evergreen Staff Client.
55 if [ ! -d "$CLIENT_DIR" ]; then
56     GetClient
57 else
58     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="$?"
59     if [ "$RE_DOWNLOAD" = "0" ]; then
60         rm -rf "$CLIENT_DIR"
61         rm $CLIENT
62         GetClient
63     fi
64 fi
65 }
66
67 ConfigureLubuntu() { ### Install Imagemagick and configure client desktop icon.
68 zenity --title="$PRG_NAME" --height="50" --width="350" --timeout="2" --no-wrap --info --text="Configuring for Lubuntu..."
69
70 if dpkg -l | grep 'imagemagick[[:blank:]]' | grep -q ii ; then
71     zenity --title="$PRG_NAME" --height="50" --width="350" --no-wrap --timeout="3" --info --text="ImageMagick is already installed"
72 else
73     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"
74 fi
75
76 convert $CLIENT_DIR/evergreen.ico $CLIENT_DIR/evergreen.png
77
78 cat <<EOF > $DESKTOP/Evergreen
79 [Desktop Entry]
80 Encoding=UTF-8
81 Type=Application
82 Name=Evergreen Staff Client
83 Name[en_US]=Evergreen Staff Client
84 Icon=$CLIENT_DIR/evergreen-0.png
85 Exec=$CLIENT_DIR/evergreen
86 Comment[en_US]=Evergreen Staff Client
87 StartupNotify=false
88 EOF
89 }
90
91 Download_Driver () { ### Prompt about driver download and open a web browser with URL of driver download.
92 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."
93 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."
94 if pgrep firefox; then
95     zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="Setup detected an open web browser.  Please close \n all your broswer windows then press OK"
96     while pgrep firefox; do
97         zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="A web browser is still running.  Please close \n all your broswer windows then press OK"
98     done
99 fi
100 sensible-browser $EPSON_URL
101 }
102
103 DownloadEpson() { ### Download and install the Epson TM-V receipt printer driver.
104 if [ -e $DOWNLOAD_DIR/$EPSON_ARCHIVE ]; then
105     zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --question --text="Epson driver exists in $DOWNLOAD_DIR/$EPSON_ARCHIVE, \n would you like to download the driver again?";RE_DOWNLOAD_DRIVER="$?"
106     if [ "$RE_DOWNLOAD_DRIVER" = "0" ]; then
107         rm "$DOWNLOAD_DIR/$EPSON_ARCHIVE"
108         Download_Driver
109     fi
110 else
111     Download_Driver
112 fi
113
114 if [ -e $DOWNLOAD_DIR/$EPSON_ARCHIVE ]; then
115     cd $HOME
116     [ -e "$EPSON_DIR" ] && rm -rf "$EPSON_DIR"
117     xterm $TERM_SET -e "echo;echo Unzipping Epson Driver $DOWNLOAD_DIR/$EPSON_ARCHIVE;echo;sleep 2;unzip $DOWNLOAD_DIR/$EPSON_ARCHIVE && mv $EPSON_UNZIP_DIR/$EPSON_DIR . "
118     cd $EPSON_DIR || {
119     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."
120     zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --timeout="3" --no-wrap --error --text="Exiting Setup..."
121     exit 1;
122     }
123     echo
124     echo
125     zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --timeout="2" --no-wrap --info --text="Starting Epson installer."
126     if [ "$ARCH" = "i386" ] || [ "$ARCH" = "i686" ]; then
127         zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="Choose Ubuntu 14.04 (32-bit) when prompted by the installer script."
128     elif [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then
129         zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --no-wrap --info --text="Choose Ubuntu 14.04 (64-bit) when prompted by the installer script."
130     else
131         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 14.04 for\nyour system's architecture when prompted by the installer script"
132     fi
133     chmod 755 $HOME/$EPSON_DIR/install.sh
134     xterm $TERM_SET -e "echo Installing Epson Driver;echo;echo;echo Keystrokes will not be displayed when typing your password;./install.sh && echo Installation Complete;sleep 2"
135     zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --timeout="3" --no-wrap --info --text="Exiting Setup..."
136 else
137     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."
138     zenity --window-icon="$CLIENT_DIR/evergreen-0.png" --title="$PRG_NAME" --height="50" --width="350" --timeout="3" --no-wrap --info --text="Exiting Setup..."
139     exit 0;
140 fi
141 }
142
143 DownloadExtract
144
145 if [ "$DE" = "Lubuntu" ]; then
146     ConfigureLubuntu
147 fi
148
149 DownloadEpson