Skip to content

Instantly share code, notes, and snippets.

@mwoodbri
Last active March 13, 2018 17:53
Show Gist options
  • Save mwoodbri/38e0f2c32826156985b165a2d56831ba to your computer and use it in GitHub Desktop.
Save mwoodbri/38e0f2c32826156985b165a2d56831ba to your computer and use it in GitHub Desktop.
MRIdb installation script for EL7
#!/bin/sh
set -exo pipefail
curl -L https://imperialcollegelondon.box.com/shared/static/wm84f86ikub5mceibprp61cd7jxwanzp.gz | tar xz -C /opt
if [ -f /opt/mridb/conf/application-site.conf ]; then
echo "Updated MRIdb: $(cat /opt/mridb/VERSION)"
exit
fi
DEPS=/tmp/mridb-deps
if [ ! -d "$DEPS" ]; then
curl -L https://imperialcollegelondon.box.com/shared/static/gjuidrfqu3n7vvsltdp948ykbqcynwux.tar | tar x -C /tmp
fi
yum upgrade -y
yum install -y unzip patch postgresql-server policycoreutils-python gcc java-1.7.0-openjdk bzip2
yum install -y epel-release
yum install -y p7zip
yum install -y centos-release-scl
yum install -y python27-python-devel python27-numpy
firewall-cmd --zone=public --add-port=80/tcp --add-port=8080/tcp --add-port=11112/tcp --permanent
unzip -d /opt $DEPS/dcm4che-2.0.28-bin.zip
unzip -d /opt $DEPS/dcm4chee-2.17.3-psql.zip
unzip -d /opt $DEPS/lx64.zip
unzip -d /opt $DEPS/play-1.2.x.zip
unzip -d /opt $DEPS/ISD_dicom_tool.zip
yum install -y $DEPS/xmedcon-0.14.1-1.x86_64.rpm
sed -i 's#/opt/xmedcon-0.13.0#/usr#' /opt/mridb/conf/application.conf
tar xf $DEPS/dcmtk-3.6.0-linux-i686-static.tar.bz2 -C /opt
unzip -d /tmp $DEPS/jboss-4.2.3.GA-jdk6.zip
ln -s /opt/dcm4chee-2.17.3-psql /opt/dcm4chee
tar xf $DEPS/jai_imageio-1_1-lib-linux-amd64.tar.gz --strip-components=2 -C /opt/dcm4chee/bin/native jai_imageio-1_1/lib/libclib_jiio.so
/opt/dcm4chee/bin/install_jboss.sh /tmp/jboss-4.2.3.GA
cp $DEPS/weasis.war /opt/dcm4chee/server/default/deploy
cp $DEPS/weasis-pacs-connector.war /opt/dcm4chee/server/default/deploy
patch /opt/dcm4chee/server/default/conf/dcm4chee-attribute-filter.xml <$DEPS/dcm4chee-attribute-filter.patch
patch /opt/dcm4chee/bin/dcm4chee_init_redhat.sh <$DEPS/dcm4chee_init_redhat.patch
mkdir -p /mnt/dcm4chee/archive
ln -s /mnt/dcm4chee/archive /opt/dcm4chee/server/default/archive
echo JBOSS_USER=RUNASIS >/etc/sysconfig/dcm4chee
echo JBOSS_HOME=$(readlink -f /opt/dcm4chee) >>/etc/sysconfig/dcm4chee
ln -s /opt/dcm4chee/bin/dcm4chee_init_redhat.sh /etc/init.d/dcm4chee
chkconfig --add dcm4chee
chkconfig dcm4chee on
chkconfig postgresql on
PGDATA=/mnt/pgsql/data
mkdir -p $PGDATA
chown postgres.postgres $PGDATA
cat >/etc/systemd/system/postgresql.service <<EOF
.include /usr/lib/systemd/system/postgresql.service
[Service]
Environment=PGDATA=$PGDATA
EOF
systemctl daemon-reload
semanage fcontext -a -t postgresql_db_t "$PGDATA(/.*)?"
restorecon -R $PGDATA
service postgresql initdb
sed -i 's/ident$/trust/' $PGDATA/pg_hba.conf
service postgresql start
sleep 1
export PGHOST=localhost PGUSER=postgres
createdb pacsdb
psql pacsdb -f /opt/dcm4chee/sql/create.psql
touch /usr/share/pgsql/tsearch_data/empty.stop
psql pacsdb <<EOF
CREATE TEXT SEARCH CONFIGURATION english_nostop (COPY = english);
CREATE TEXT SEARCH DICTIONARY english_nostop (TEMPLATE = simple, STOPWORDS = empty);
ALTER TEXT SEARCH CONFIGURATION english_nostop ALTER MAPPING FOR asciihword, asciiword, hword, hword_asciipart, hword_part, word WITH english_nostop;
EOF
. /opt/rh/python27/enable
(cd $DEPS/pydicom-0.9.7 && python setup.py install)
easy_install -i https://pypi.python.org/simple/ nibabel
/opt/mricron/dcm2nii
sed -i 's/MinReorientMatrix=200/MinReorientMatrix=2000/' ~/.dcm2nii/dcm2nii.ini
touch /opt/mridb/conf/application-site.conf
/opt/play-1.2.x/play secret /opt/mridb
grep -F application.secret /opt/mridb/conf/application.conf >/opt/mridb/conf/application-site.conf
echo xmedcon=/usr >>/opt/mridb/conf/application-site.conf
ln -s /opt/mridb/bin/mridb /etc/init.d/mridb
chkconfig --add mridb
chkconfig mridb on
echo "Installed MRIdb: $(cat /opt/mridb/VERSION)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment