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

From MircWiki
Jump to navigation Jump to search
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== How to install MIRC-Zn on Ubuntu Linux ==
+
=== A word on Linux ===
* Download the script
 
wget http://timphillips.net/mirc/install-MIRC-Zn.txt
 
* Make it executable
 
mv ./install-MIRC-Zn.txt ./install-MIRC-Zn
 
chmod 777 ./install-MIRC-Zn
 
* Run the script
 
./install-MIRC-Zn
 
  
===What the script does===
+
To be accurate, the term Linux properly only refers to the Operating System kernel developed by Linus Torvalds. Linux ''distributions'' are then built on that kernel. Not all distrbutions are built the same way. There are two main families: those that use the RPM package system (Redhat, Fedora, CentOS, Scientific Linux, Suse, etc) and those that use the .Deb package systems (Debian, Ubuntu, Kubuntu, etc).
  
* Checks you're running it as root or using sudo.
+
Those families further differ in how they manage system services. The .Deb family largely follows BSD style init scripts. The RPM family follows AT&T System V init scripts. To control CTP as a service (start, stop, get status) on your Linux distribution you must choose the proper tool from the two options below.
* Stops the MIRC-Zn service if its running.
 
* 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 files 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.
 
  
===The script itself (in case you don't trust the download)===
+
=== Init Scripts for Redhat (or similar) System V systems ===
  
  #!/bin/bash
+
The <b><tt>CTP/linux</tt></b> folder of the CTP installation now includes a new file called <b><tt>ctpService-red.sh</tt></b>. This file is internally documented, but in brief you must confirm that the variable settings in it match your environment settings. The simplest way to to this is the following. From the command line verify that the following will start CTP:
 +
 
 +
<pre>
 +
java -jar Runner.jar
 +
</pre>
 +
 
 +
If the above works, then we need only assure that the JAVA_HOME, JAVA_BIN, CLASSPATH and CTP_HOME settings in the script match the output of the "env" command. Once that is confirmed, do the following steps (where CTP_HOME is the true location of the CTP root folder):
 +
 
 +
<pre>
 +
ln -s /CTP_HOME/linux/ctpService-red.sh /etc/init.d/ctpService
 +
chkconfig --add /etc/init.d/ctpService
 +
</pre>
 +
 
 +
This will install CTP as a service and it will autostart when the Linux distribution boots. All the normal service commands are now available:
 +
 
 +
<pre>
 +
/sbin/service ctpService start/stop/restart/status
 +
</pre>
 +
 
 +
''Any questions or comments please email langer.steve@mayo.edu - Steve Langer.''
 +
 
 +
=== Init scripts for Ubunutu (or similar) BSD systems ===
 +
 
 +
* This is a small part of what the script described in [[Install or upgrade RSNA TFS (previously known as MIRC) on Ubuntu Linux]] will do automatically for you.
 +
* If you want to install MIRC on a Linux machine it is recommended you read the article above.
 +
* If you are here because you want to run an existing Linux installation of CTP or MIRC as a service, continue reading.
 +
 
 +
 
 +
''' 3.1 Using an UpStart script
 +
 
 +
Ubuntu and many other Linux distros use UpStart to run services.
 +
The below example assumes CTP is installed at
 +
 
 +
  /usr/share/CTP/
 +
 
 +
You can modify it to suit a different locations.
 
   
 
   
# Make sure only root can run our script
+
Cut and paste the below code
if [[ $EUID -ne 0 ]]; then
+
 
echo "This script must be run as root or using sudo" 1>&2
+
  description "CTP Service on Linux"
exit 1
 
fi
 
 
# Stop MIRC-Zn if it is running
 
if [ -f /etc/init/MIRC-Zn.conf ]
 
then
 
if [[ $(stop -q MIRC-Zn 2>&1 | grep Unknown) ]]
 
then
 
echo 'MIRC-Zn service not currently running ...'
 
echo 'MIRC-Zn will be upgraded with the latest version from the RSNA site ...'
 
else
 
echo 'Stopping current MIRC-Zn service ...'
 
echo 'MIRC-Zn will be upgraded with the latest version from the RSNA site ...'
 
fi
 
fi
 
 
#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
 
 
# if a previous version is here - get rid of it
 
cd /usr/lib/jvm/java-6-sun/
 
if [ -f UNINSTALL-jai_imageio ]; then
 
echo 'Removing previous install of JAI ImageIO ...'
 
bash UNINSTALL-jai_imageio
 
fi
 
 
#work in the temp folder
 
cd /var/tmp
 
 
#check which chipset we're using
 
case $(arch) in
 
i686)
 
CHIP=i586
 
CHIP2=i386
 
;;
 
x86_64)
 
CHIP=amd64
 
CHIP2=amd64
 
;;
 
*)
 
;;
 
esac
 
 
#reassure the user something is happening
 
echo 'Downloading JAI Image IO ...'
 
 
#download the JAI tgz file
 
# get jai binary
 
if [ -f ./jai_imageio-1_1-lib-linux-$CHIP.tar.gz ]; then
 
rm ./jai_imageio-1_1-lib-linux-$CHIP.tar.gz
 
fi
 
wget -q http://download.java.net/media/jai-imageio/builds/release/1.1/jai_imageio-1_1-lib-linux-$CHIP.tar.gz
 
 
#reassure the user something is happening
 
echo 'Installing JAI Image IO ...'
 
 
#expand the tgz and put the files where they should go (excluding UNINSTALL)
 
tar xzf ./jai_imageio-1_1-lib-linux-$CHIP.tar.gz
 
mv ./jai_imageio-1_1/*.txt /usr/lib/jvm/java-6-sun/
 
mv ./jai_imageio-1_1/lib/libclib_jiio.so /usr/lib/jvm/java-6-sun/jre/lib/$CHIP2/
 
mv ./jai_imageio-1_1/lib/*.jar /usr/lib/jvm/java-6-sun/jre/lib/ext/
 
 
#generate the UNINSTALL file - using the version that comes in the binary install
 
cat > /usr/lib/jvm/java-6-sun/UNINSTALL-jai_imageio <<DELIM
 
#!/bin/sh
 
# @(#)UNINSTALL-jai_imageio-jdk 3.1 06/05/12 16:18:39
 
# usage: UNINSTALL-jai_imageio
 
 
echo "Uninstalling Java Advanced Imaging Image I/O Tools"
 
 
rm -f *jai_imageio.txt
 
rm -f jre/lib/ext/jai_imageio.jar
 
rm -f jre/lib/ext/clibwrapper_jiio.jar
 
if [ ( `uname` = "SunOS" ) -a ( `uname -p` = "sparc" ) ]; then
 
rm -f jre/lib/sparc/libclib_jiio.so
 
rm -f jre/lib/sparc/libclib_jiio_vis.so
 
rm -f jre/lib/sparc/libclib_jiio_vis2.so
 
 
if [ -f jre/lib/sparcv9/libclib_jiio.so ]; then
 
rm -f jre/lib/sparcv9/libclib_jiio.so
 
rm -f jre/lib/sparcv9/libclib_jiio_vis.so
 
rm -f jre/lib/sparcv9/libclib_jiio_vis2.so
 
fi
 
fi
 
if [ -f jre/lib/amd64/libclib_jiio.so ]; then
 
rm -f jre/lib/amd64/libclib_jiio.so
 
fi
 
if [ -f jre/lib/i386/libclib_jiio.so ]; then
 
rm -f jre/lib/i386/libclib_jiio.so
 
fi
 
rm -f UNINSTALL-jai_imageio
 
 
echo "Done"
 
DELIM
 
 
#reassure the user something is happening
 
echo 'Downloading RSNA MIRC Installer ...'
 
 
# go to the target folder
 
cd /usr/share
 
 
# 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 <timothy.john.phillips@gmail.com>"
 
  author "Tim Phillips <timothy.john.phillips@gmail.com>"
 
   
 
   
Line 186: Line 60:
 
  java -jar ./CTP-runner.jar
 
  java -jar ./CTP-runner.jar
 
  end script
 
  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 should be /usr/share or the startup script wont work'
 
echo -e
 
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 -e
 
echo 'Here is what you have to do'
 
echo ' - logout'
 
echo ' - login again from a machine with a GUI and a display....'
 
echo ' - using the switch to enable X forwarding'
 
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 ' - When you are logged in again re-run this script'
 
else
 
cd ~
 
echo 'Starting MIRC web service (this will also happen automatically at boot) ...'
 
start MIRC-Zn
 
echo -e
 
echo 'finished - it should all be running'
 
echo 'point your browser to this server and have a look'
 
fi
 
 
  
==Choosing between Ubuntu Desktop and Ubuntu Server==
+
into a file named
 +
 
 +
/etc/init/CTP.conf
 +
 
 +
 
 +
''' 3.2 Commands to control the CTP service
  
* Ubuntu Desktop
+
To start CTP (it will start automatically when the machine boots)
** Easier (very easy) if you're new to Linux.
+
start CTP
** May be very slightly slower but on modern hardware you are unlikely to notice the difference.
+
To stop CTP:
* Ubuntu Server
+
stop CTP
** Makes more sense - MIRC is a web service after all.
+
To check if CTP is running:
** Will be leaner and faster.
+
status CTP
** Can run on a headless server or virtual machine.
+
To restart CTP:
** [ http://turnkeylinux.org TurnkeyLinux ] is a very good Ubuntu install for this purpose.
+
restart CTP
  
<div align="right">''Any questions or comments please email me at timothy.john.phillips@gmail.com - Tim Phillips.''</div>
+
''Any questions or comments please email timothy.john.phillips@gmail.com - Tim Phillips.''

Latest revision as of 12:21, 13 August 2013

1 A word on Linux

To be accurate, the term Linux properly only refers to the Operating System kernel developed by Linus Torvalds. Linux distributions are then built on that kernel. Not all distrbutions are built the same way. There are two main families: those that use the RPM package system (Redhat, Fedora, CentOS, Scientific Linux, Suse, etc) and those that use the .Deb package systems (Debian, Ubuntu, Kubuntu, etc).

Those families further differ in how they manage system services. The .Deb family largely follows BSD style init scripts. The RPM family follows AT&T System V init scripts. To control CTP as a service (start, stop, get status) on your Linux distribution you must choose the proper tool from the two options below.

2 Init Scripts for Redhat (or similar) System V systems

The CTP/linux folder of the CTP installation now includes a new file called ctpService-red.sh. This file is internally documented, but in brief you must confirm that the variable settings in it match your environment settings. The simplest way to to this is the following. From the command line verify that the following will start CTP:

java -jar Runner.jar

If the above works, then we need only assure that the JAVA_HOME, JAVA_BIN, CLASSPATH and CTP_HOME settings in the script match the output of the "env" command. Once that is confirmed, do the following steps (where CTP_HOME is the true location of the CTP root folder):

ln -s /CTP_HOME/linux/ctpService-red.sh /etc/init.d/ctpService
chkconfig --add /etc/init.d/ctpService

This will install CTP as a service and it will autostart when the Linux distribution boots. All the normal service commands are now available:

/sbin/service ctpService start/stop/restart/status

Any questions or comments please email langer.steve@mayo.edu - Steve Langer.

3 Init scripts for Ubunutu (or similar) BSD systems

  • This is a small part of what the script described in Install or upgrade RSNA TFS (previously known as MIRC) on Ubuntu Linux will do automatically for you.
  • If you want to install MIRC on a Linux machine it is recommended you read the article above.
  • If you are here because you want to run an existing Linux installation of CTP or MIRC as a service, continue reading.


3.1 Using an UpStart script

Ubuntu and many other Linux distros use UpStart to run services. The below example assumes CTP is installed at

/usr/share/CTP/

You can modify it to suit a different locations.

Cut and paste the below code

description "CTP Service on Linux"
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

into a file named

/etc/init/CTP.conf


3.2 Commands to control the CTP service

To start CTP (it will start automatically when the machine boots)

start CTP

To stop CTP:

stop CTP

To check if CTP is running:

status CTP

To restart CTP:

restart CTP

Any questions or comments please email timothy.john.phillips@gmail.com - Tim Phillips.