Running CTP as a Linux Service
1 Choice: Ubuntu Desktop or Server?
- Ubuntu Server
- Makes more sense - MIRC is a web service after all.
- Will be leaner and faster.
- Can run on a headless server or virtual machine.
- Ubuntu Desktop
- Easier (very easy) if you're new to Linux.
- May be very slightly slower but on modern hardware you are unlikely to notice the difference.
2 Instructions / script for installing the latest CTP/MIRC-Zn in Ubuntu
2.1 (If you're new to Linux) How to cut and paste the script below into a file and execute it
- Open an editor
- Cut and paste the code from the big box at the bottom of the page
- Save the file and exit
ctrl-O and then hit enter ctrl-X
- Make it executable
chmod 777 ./install-MIRCn.sh
- Run it
2.2 What the script does
- Checks which chipset you're running
- Enables the ubuntu partner repo (to get Oracle Java)
- Answers the Java installation questions in advance
- Installs SunJava and a few other necessary applications
- Downloads the appropriate JAI ImageIO and fixes the inherent problem in the Linux release
- Installs JAI ImageIO
- Downloads the latest version of MIRC-Zn
- Writes an upstart script (so that CTP/MIRC will be run as a service automatically)
- Installs RSNA MIRC
- If you have x-forwarding or are installing from Ubuntu Desktop ignore the below points
- If you are logged in without X11 or X-forwarding this script will tell you and help you fix it.
- By the time it gets to the part that needs X-forwarding it has installed the necessary libraries
- You will need to exit and re login (ssh) in to the server with X-fowarding and run the MIRC-Installer.jar file
- The script below will talk you through it.
- From a linux desktop to a linux server this is ssh -x username@host
- From a mac to a linux server this is ssh -Y username@host
- From a windows box you will need Putty and Xming X Server for MS Windows (google them).
2.3 The script
#!/bin/bash #reassure the user something is happening echo 'Updating Ubuntu repositories ...' #work in the temp folder cd /var/tmp #check which chipset we're using case $(arch) in i686) CHIP=i586 ;; x86_64) CHIP=amd64 ;; *) ;; esac # partner repo echo deb http://archive.canonical.com/ lucid partner >>/etc/apt/sources.list.d/partner.list apt-get -qq update # preset the java answers: debconf-set-selections << END sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true END #reassure the user something is happening echo 'Downloading and installing required ubuntu packages ...' # packages installed: apt-get install -y -qq acpid htop unzip xauth libxtst6 sun-java6-jdk #reassure the user something is happening echo 'Downloading JAI Image IO ...' # get jai binary if [ -f ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin ]; then rm ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin fi wget -q http://download.java.net/media/jai-imageio/builds/release/1.1/jai_imageio-1_1-lib-linux-$CHIP-jdk.bin #reassure the user something is happening echo 'Fixing the bug in JAI Image IO ...' # make it executable chmod 777 ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin # fix an inherent flaw in the file (thanks to JGrass for this) sed -i 's/+215/-n+215/' ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin # put it in the jdk folder mv ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin /usr/lib/jvm/java-6-sun/ # execute the installer cd /usr/lib/jvm/java-6-sun/ # if a previous version is here - get rid of it if [ -f UNINSTALL-jai_imageio ]; then echo 'Removing previous install of JAI ImageIO ...' bash UNINSTALL-jai_imageio echo -e echo 'Installing JAI ImageIO' fi echo -e echo 'You will be forced to wade through a long copyright' echo 'and asked to type in yes to agree at the end' echo 'Press enter ...' read dummy ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin #reassure the user something is happening echo 'Downloading RSNA MIRC Installer ...' # go back to the temp folder cd /var/tmp # get MIRC installer if [ -f ./MIRC-installer.jar ]; then rm ./MIRC-installer.jar fi wget -q http://mirc.rsna.org/MIRC2/MIRC-installer.jar #reassure the user something is happening echo 'Writing an upstart script and putting it in /etc/init ...' # make an upstart script cat > /etc/init/MIRC-Zn.conf <<DELIM description "MIRC Zn (CTP plugin not Tomcat)" author "Tim Phillips <email@example.com>" start on (local-filesystems and net-device-up IFACE!=lo) stop on stopping network-services respawn expect fork script cd /usr/share/CTP/ java -jar ./CTP-runner.jar end script DELIM echo -e echo -e echo -e echo 'Now the RSNA installer will run' echo 'You will be asked to choose a folder to install CTP/MIRC into' echo 'It is very important that you type in /usr/share' echo 'Do not accept the default folder that it will offer you' echo 'hit enter to continue' read dummy echo -e echo -e if [[ $(java -jar ./MIRC-installer.jar 2>&1 | grep X11) ]] then # have to re-login with X forwarding echo -e echo '================================================' echo 'NOT FINISHED YET!!!!' echo '================================================' echo -e echo 'X-forwarding is required for the MIRC installer' echo 'logout, type in exit and hit enter' echo 'and then login again from a machine with a screen....' echo 'From a mac: ssh -Y user@host' echo 'From a linux desktop: ssh -X user@host' echo 'If you are using windows you will need PuTTy and Xming (google them)' echo -e echo 'When you have logged in again type in:' echo 'java -jar ./MIRC-installer.jar' echo 'when prompted remember to install CTP/MIRC into /usr/share' echo 'when its finished - reboot and it should all be running' else echo 'finished - reboot and it should all be running' echo 'point your browser to this server and have a look'
Any questions or comments please email me at firstname.lastname@example.org - Tim Phillips.