-
-
Save avenda/9b88c3fc492bb32a6fea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function usage() | |
{ | |
echo "Usage: $0 -u <MySQL_Username> -p <Password>" | |
} | |
USER="" | |
PASSWORD="" | |
while getopts "hu:p:" opt; do | |
case "$opt" in | |
h) | |
usage | |
exit 1 | |
;; | |
u) | |
USER=$OPTARG | |
;; | |
p) | |
PASSWORD=$OPTARG | |
;; | |
esac | |
done | |
if [ -z "$USER" ] || [ -z "$PASSWORD" ]; then | |
usage | |
exit 1 | |
fi | |
ROOT_DIR="/home/${USER}" | |
INSTALL=$ROOT_DIR/dcm4chee | |
INSTALL_VERSION=2.18.0 | |
INSTALL_DB_TYPE=mysql | |
DCM4CHEE_NAME=dcm4chee-$INSTALL_VERSION-$INSTALL_DB_TYPE | |
DCM4CHEE_LIB=$INSTALL/server/default/lib | |
JBOSS=jboss-4.2.3.GA | |
JAI_IMAGEIO_64=jai_imageio-1_1-lib-linux-amd64.tar.gz | |
# We need zip, postgres, htop, glances | |
echo "Upgrading system..." | |
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade > /dev/null | |
DEBIAN_FRONTEND=noninteractive apt-get -y install unzip zip > /dev/null | |
DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server \ | |
htop execstack > /dev/null | |
DEBIAN_FRONTEND=noninteractive apt-get -y install execstack > /dev/null # used to "fix" /dcm4chee/bin/native libclib_jiio.so | |
# install Java | |
echo "Installing JAVA..." | |
wget -nv "https://gist.githubusercontent.com/gunlock/aa6729dcb386a85a99cb/raw/c4ccf541351260a9235088024470270a27f4f03d/java_install.sh" | |
chmod 700 java_install.sh | |
./java_install.sh | |
export JAVA_HOME=/usr/local/java | |
export PATH=$PATH:$JAVA_HOME/bin | |
export JRE_HOME=$JAVA_HOME/jre | |
# create dcm4chee user | |
echo "Creating $USER user..." | |
useradd --shell=/bin/bash --create-home $USER | |
# switch user (su) to $USER. All command between EOF are run as $USER user | |
echo "Switching to $USER user and copying dcm4chee/jboss files" | |
su - $USER <<EOF | |
cd ${ROOT_DIR} | |
echo "Downloading dcm4chee $DCM4CHEE_NAME..." | |
wget -nv "http://sourceforge.net/projects/dcm4che/files/dcm4chee/$INSTALL_VERSION/$DCM4CHEE_NAME.zip" | |
if [ -d "$INSTALL" ]; then | |
rm -rf $INSTALL | |
fi | |
unzip ${DCM4CHEE_NAME}.zip > /dev/null | |
rm ${DCM4CHEE_NAME}.zip | |
mv ${DCM4CHEE_NAME} dcm4chee | |
echo "Downloading JBoss 4.2.3..." | |
# Download JBoss (current version of dcm4chee as of Aug 2014 requires JBoss 4.2.3) | |
wget -nv "http://sourceforge.net/projects/jboss/files/JBoss/JBoss-4.2.3.GA/${JBOSS}.zip" | |
unzip ${JBOSS}.zip > /dev/null | |
rm ${JBOSS}.zip | |
# Copy files form JBoss to dcm4chee | |
${INSTALL}/bin/install_jboss.sh $ROOT_DIR/${JBOSS} > /dev/null | |
rm -rf ${JBOSS} | |
# correct the permission on directories recursively | |
find . -type d -exec chmod 755 {} + | |
# DCM4CHEE by default includes Sun's Advanced Imaging I/O Tools (JAI_IMAGEIO) for | |
# i586 platforms. If install in a 32 bit platform need to replace this with | |
# compatibile library | |
# see: http://www.dcm4che.org/confluence/display/ee2/Installation#Installation-CompressionNotes | |
if [ `getconf LONG_BIT` == 64 ]; then | |
echo "Must change libclib_jiio.so to 64 bit version..." | |
wget -nv "http://download.java.net/media/jai-imageio/builds/release/1.1/$JAI_IMAGEIO_64" -O $JAI_IMAGEIO_64 | |
tar xfz $JAI_IMAGEIO_64 | |
rm $JAI_IMAGEIO_64 | |
rm $INSTALL/bin/native/libclib_jiio.so | |
cp -v jai_imageio-1_1/lib/libclib_jiio.so $INSTALL/bin/native/libclib_jiio.so | |
rm -rf jai_imageio-1_1 | |
fi | |
echo "Installing Weasis..." | |
wget -nv "http://sourceforge.net/projects/dcm4che/files/Weasis/2.0.2/weasis.war" | |
wget -nv "http://sourceforge.net/projects/dcm4che/files/Weasis/weasis-pacs-connector/4.0.0/weasis-pacs-connector.war" | |
wget -nv "http://sourceforge.net/projects/dcm4che/files/Weasis/weasis-pacs-connector/4.0.0/dcm4chee-web-weasis.jar" | |
mv weasis.war $INSTALL/server/default/deploy | |
mv weasis-pacs-connector.war $INSTALL/server/default/deploy | |
mv dcm4chee-web-weasis.jar $INSTALL/server/default/deploy | |
EOF | |
echo "Creating DB and DB users..." | |
mysql -uroot -e "create database pacsdb;" | |
mysql -uroot -e "grant all on pacsdb.* to '$USER'@'localhost' identified by '$PASSWORD';" | |
echo "Executing dcm4chee sql script" | |
mysql -upacs -ppacs pacsdb < ${INSTALL}/sql/create.mysql | |
#The following is reported as an erorr on JBoss startup, so lets fix it | |
echo "Running execstack on dcm4chee/bin/native/libclib_jiio..." | |
execstack -c $INSTALL/bin/native/libclib_jiio.so | |
# Modify config files with the new postgres user ($USER) we created | |
echo "Updating pacs-mysql-ds.xml with user and password information..." | |
sed -i.bak "s#<user-name>postgres</user-name>#<user-name>$USER</user-name>#g" \ | |
$INSTALL/server/default/deploy/pacs-mysql-ds.xml | |
sed -i.bak "s#<password></password>#<password>$PASSWORD</password>#g" \ | |
$INSTALL/server/default/deploy/pacs-mysql-ds.xml | |
# Modify permissions on pacs-postgres-ds.xml since we have password in there | |
echo "Locking down permissions on pacs-mysql-ds.xml.." | |
chmod 600 $INSTALL/server/default/deploy/pacs-mysql-ds.xml | |
chmod 600 $INSTALL/server/default/deploy/pacs-mysql-ds.xml.bak | |
# Insert this one line below search string, but first read this long line to STRING | |
echo "Adding connection permissions to pg_hba.conf..." | |
sed -i.bak \ | |
"/# Database administrative login by Unix domain socket/a local all $USER peer" \ | |
$PG_HBA_CONF_PATH | |
echo "Creating init.d script for dcm4chee..." | |
wget -nv "https://gist.githubusercontent.com/gunlock/a7c0cf36221d71f8792b/raw/10b8ea0cc9cf1e110ef06f2f5730b24f8f4291fd/dcm4chee_daemon.sh" \ | |
-O dcm4chee | |
chmod 755 dcm4chee | |
sed -i "s#DAEMON=/home/pacs/run.sh#DAEMON=$INSTALL/bin/run.sh#g" dcm4chee | |
sed -i "s#USER=pacs#USER=$USER#g" dcm4chee | |
mv dcm4chee /etc/init.d/dcm4chee | |
update-rc.d dcm4chee defaults | |
# We need to replace the stock run.sh script that ships with dcm4chee | |
wget -nv "https://gist.githubusercontent.com/gunlock/016dc201473851ba4441/raw/c92fe11d3e57d63925cfead458ddbdb2225f36fb/dcm4chee_run.sh" \ | |
-O run.sh | |
chmod 750 run.sh | |
chown $USER:$USER run.sh | |
sed -i "s#export JBOSS_HOME=/home/pacs/dcm4chee#export JBOSS_HOME=$INSTALL#g" run.sh | |
mv $INSTALL/bin/run.sh $INSTALL/bin/run.sh.bak | |
mv run.sh $INSTALL/bin | |
echo "To configure Weasis go to http://host_name_here/jmx-console" | |
echo "and set WebviewerNames = weasis and WebviewerBaseUrl = NONE" | |
echo "and click APPLY" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great install