Difference between revisions of "Running CTP as a Linux Service"

From MircWiki
Jump to navigation Jump to search
Line 29: Line 29:
 
# Downloads the latest version of MIRC-Zn
 
# Downloads the latest version of MIRC-Zn
 
# Writes an upstart script (so that CTP/MIRC will be run as a service automatically)
 
# Writes an upstart script (so that CTP/MIRC will be run as a service automatically)
 +
# Installs RSNA MIRC
 +
# If you are logged in without X11 or X-forwarding this script will tell you and help you fix it.
 +
## Lightweight installations of Ubutnu (eg jeos or TurnkeyLinux core) don't have the libraries for X-forwarding. This script will install them.
 
   
 
   
#!/bin/bash
+
  #!/bin/bash
 
   
 
   
#check which chipset we're using
+
  #check which chipset we're using
case $(arch) in
+
  case $(arch) in
        i686)
+
  i686)
                CHIP=i586
+
  CHIP=i586
        ;;
+
  ;;
        x86_64)
+
  x86_64)
                CHIP=amd64
+
  CHIP=amd64
        ;;
+
  ;;
        *)
+
  *)
        ;;
+
  ;;
esac
+
  esac
 
   
 
   
# partner repo
+
  # partner repo
echo deb http://archive.canonical.com/ lucid partner >>/etc/apt/sources.list.d/partner.list
+
  echo deb http://archive.canonical.com/ lucid partner >>/etc/apt/sources.list.d/partner.list
apt-get update
+
  apt-get update
 
   
 
   
# preset the java answers:
+
  # preset the java answers:
debconf-set-selections << END
+
  debconf-set-selections << END
sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true
+
  sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true
sun-java6-jre 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
+
  sun-java6-bin shared/accepted-sun-dlj-v1-1 boolean true
END
+
  END
 
   
 
   
# packages installed:
+
  # packages installed:
apt-get install -y acpid htop unzip xauth libxtst6 sun-java6-jdk
+
  apt-get install -y acpid htop unzip xauth libxtst6 sun-java6-jdk
 
   
 
   
# get jai binary
+
  # get jai binary
wget http://download.java.net/media/jai-imageio/builds/release/1.1/jai_imageio-1_1-lib-linux-$CHIP-jdk.bin  
+
  wget http://download.java.net/media/jai-imageio/builds/release/1.1/jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
 
   
 
   
# make it executable
+
  # make it executable
chmod 777 ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
+
  chmod 777 ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
 
   
 
   
# fix an inherent flaw in the file (thanks to JGrass for this)
+
  # 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
+
  sed -i 's/+215/-n+215/' ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
 
   
 
   
# put it in the jdk folder
+
  # put it in the jdk folder
mv ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin /usr/lib/jvm/java-6-sun/
+
  mv ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin /usr/lib/jvm/java-6-sun/
 
   
 
   
# execute the installer
+
  # execute the installer
cd /usr/lib/jvm/java-6-sun/
+
  cd /usr/lib/jvm/java-6-sun/
./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
+
  ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin
 
   
 
   
# go back to the home folder
+
  # go back to the home folder
cd -
+
  cd -
 
   
 
   
# get MIRC installer
+
  # get MIRC installer
wget http://mirc.rsna.org/MIRC2/MIRC-installer.jar  
+
  wget http://mirc.rsna.org/MIRC2/MIRC-installer.jar
 
   
 
   
# have to re-login with X forwarding
+
  # make an upstart script
echo 'type exit to logout and then log back in with ssh -Y root@host (from a mac) '
+
  cat > /etc/init/MIRC-Zn.conf <<DELIM
 +
  description "MIRC Zn (CTP plugin not Tomcat)"
 +
  author "Tim Phillips <timothy.john.phillips@gmail.com>"
 
   
 
   
# make an upstart script
+
  start on (local-filesystems and net-device-up IFACE!=lo)
cat > /etc/init/MIRC-Zn.conf <<DELIM
+
  stop on stopping network-services
description "MIRC Zn (CTP plugin not Tomcat)"
 
author "Tim Phillips <timothy.john.phillips@gmail.com>"
 
 
   
 
   
start on (local-filesystems and net-device-up IFACE!=lo)
+
  respawn
stop on stopping network-services
 
 
   
 
   
respawn
+
  expect fork
 
   
 
   
expect fork
+
  script
 +
  cd /usr/share/CTP/
 +
  java -jar ./CTP-runner.jar
 +
  end script
 +
  DELIM
 
   
 
   
script
+
  echo 'Now the RSNA installer will run'
cd /usr/share/CTP/
+
  echo 'You will be asked to choose a folder to install CTP/MIRC into'
java -jar ./CTP-runner.jar
+
  echo 'It is very important that you type in /usr/share'
end script
+
  echo 'Do not accept the default folder that it will offer you'
DELIM
+
  echo 'hit enter to continue'
 +
  read dummy
 +
 +
  if [[ $(java -jar ./MIRC-installer.jar 2>&1 | grep X11) ]]
 +
  then
 +
  # have to re-login with X forwarding
 +
  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'

Revision as of 13:53, 9 September 2011

This is most easily done using Ubuntu If you are using virtual machines I recommend [http://turnkeylinux


1 Instructions for installing the latest CTP/MIRC-Zn in Ubuntu

1.1 Desktop or Server?

  • Ubuntu Server
    • Makes more sense - MIRC is a web service after all
    • Will be leaner and faster
    • You will need to ssh in to the server with X-fowarding when you run the MIRC-Installer.jar file
      • 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).
  • 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.
    • You can just do part 1 and then part 2 straight away (X-forwarding is not an issue).

1.2 The script

You can cut and paste each line to the command prompt or just put the whole thing into a file and execute it. This script does the following things:

  1. Check which chipset you're running
  2. Enable the ubuntu partner repo (to get Oracle Java)
  3. Answers the Java installation questions in advance
  4. Installs SunJava and a few other necessary applications
  5. Downloads the appropriate JAI ImageIO and fixes the inherent problem in the Linux release
  6. Installs JAI ImageIO
  7. Downloads the latest version of MIRC-Zn
  8. Writes an upstart script (so that CTP/MIRC will be run as a service automatically)
  9. Installs RSNA MIRC
  10. If you are logged in without X11 or X-forwarding this script will tell you and help you fix it.
    1. Lightweight installations of Ubutnu (eg jeos or TurnkeyLinux core) don't have the libraries for X-forwarding. This script will install them.
 #!/bin/bash

 #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 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

 # packages installed:
 apt-get install -y acpid htop unzip xauth libxtst6 sun-java6-jdk

 # get jai binary
 wget http://download.java.net/media/jai-imageio/builds/release/1.1/jai_imageio-1_1-lib-linux-$CHIP-jdk.bin

 # 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/
 ./jai_imageio-1_1-lib-linux-$CHIP-jdk.bin

 # go back to the home folder
 cd -

 # get MIRC installer
 wget http://mirc.rsna.org/MIRC2/MIRC-installer.jar

 # make an upstart script
 cat > /etc/init/MIRC-Zn.conf <<DELIM
 description "MIRC Zn (CTP plugin not Tomcat)"
 author "Tim Phillips <timothy.john.phillips@gmail.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 '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

 if [[ $(java -jar ./MIRC-installer.jar 2>&1 | grep X11) ]]
 then
 # have to re-login with X forwarding
 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'