Install Dcm4chee5
Install Dcm4chee5
Install Dcm4chee5
/bin/bash
# This script will help you install dcm4chee-arc-light and related software
# Please read through the script first and customize it
# Colors
SR="\e[31m"
SY="\e[33m"
SG="\e[32m"
SD="\e[39m"
STARTDIR=`pwd`
WILDFLYDIR=$DCM4CHEEDIR/wildfly
APTINSTALL="apt-get --assume-yes -qq install"
WGET="wget -q --show-progress"
# Get the IP address of the interface it's going to be used for the server
ETHFOUND=`grep "$ETHINTERFACE" /proc/net/dev`
if [ -n "$ETHFOUND" ]
then
IPADDR=`ifconfig $ETHINTERFACE | awk '/inet addr/{print substr($2,6)}'`
else
echo -e "\n $SY Could not find network interface $ETHINTERFACE, please add
correct interface in the Configuration part of this script\n $SD"
exit
fi
echo -e "\n $SR Warning!! Warning!! This script will now remove all previous
install dirs, drop database in MySQL and LDAP"
echo -e " $SR Warning!! Press Enter to continue or Ctrl-C to abort $SD "
read dummy
echo -e " Warning!! Shutting down running instance"
$WILDFLYDIR/bin/jboss-cli.sh --connect command=:shutdown 2>&1 > $INSTALLOG
sleep 5
for p in `ps -ef | grep wildfly | awk '{print $2}' | tr '\n' ' '`
do
kill -9 $p >> $INSTALLOG 2>&1
done
echo -e " Warning!! Dropping $PACSDB database"
mysqladmin -p"$MYSQLROOTPW" -f drop $PACSDB >> $INSTALLOG 2>&1
echo -e " Warning!! Removing install dirs"
rm $DCM4CHEEDIR
rm -rf $INSTALLDIR/dcm4chee* >> $INSTALLOG 2>&1
echo -e " Warning!! Removing LDAP"
/etc/init.d/slapd stop
apt-get --assume-yes -qq purge slapd ldap-utils >> $INSTALLOG 2>&1
rm -rf /var/lib/ldap/ >> $INSTALLOG 2>&1
rm -rf /etc/ldap >> $INSTALLOG 2>&1
if [ -e "/usr/bin/java" ]; then
JAVAVERSION=`java -version 2>&1 | head -1 | sed -e 's/^.* \"//' -e
's/\./____/2' -e 's/____.*//'`
if [[ "$JAVAVERSION" > "1.7" ]]
then
echo -e " $SY Java already installed, skipping... $SD"
else
echo -e " $SR Java is version $JAVAVERSION. Please install java 8, exiting
$SD"
exit 1
fi
else
echo -e " $SG Java not installed, installing... $SD"
$APTINSTALL --no-install-recommends default-jre > /dev/null
fi
if [ -e "/usr/bin/lynx" ]; then
echo -e " $SY Lynx already installed, skipping... $SD"
else
echo -e " $SG Lynx not installed, installing... $SD"
$APTINSTALL lynx > /dev/null
fi
if [ -e "/usr/bin/mysql" ]; then
echo -e " $SY MySQL already installed, skipping... $SD"
else
echo -e " $SG MySQL not installed, installing... $SD"
DEBIAN_FRONTEND=noninteractive $APTINSTALL mysql-server > /dev/null
#$APTINSTALL mysql-server > /dev/null
mysqladmin -u root password "$MYSQLROOTPW"
fi
if [ -e "/usr/share/java/mysql-connector-java.jar" ]; then
echo -e " $SY MySQL JAVA connector already installed, skipping... $SD"
else
echo -e " $SG MySQL JAVA connector not installed, installing... $SD"
$APTINSTALL libmysql-java > /dev/null
fi
#echo -e "\n $SG LDAP will be installed with the following parameters $SD"
#echo -e "\nLDAPSERVER: $SERVER \nLDAPDOMAIN: $DOMAIN \nLDAPREALM: $REALM \
nLDAPROOT: $LDAPROOT \n"
if [ -e "/usr/sbin/slapd" ]; then
echo -e " $SY OpenLDAP already installed, skipping... $SD"
else
echo -e " $SG OpenLDAP not installed, installing... $SD"
DEBIAN_FRONTEND=noninteractive $APTINSTALL slapd ldap-utils > /dev/null
fi
cd $DOWNLOADSDIR
# Find latest version available of dcm4chee arc light #
echo -ne "\n $SG Looking for latest version of dcm4chee arc light... $SD"
DCMARCVER=`lynx -dump https://sourceforge.net/projects/dcm4che/files/dcm4chee-arc-
light5/ | grep files | grep -v timeline | grep 5. | sed -e 's/^.*dcm4chee-arc-
light5\///' -e 's/\/.*//' | head -1`
#DCMARCVER="5.10.1"
echo -e "(Found dcm4chee-arc-light $DCMARCVER)"
DCMARCURL=`lynx -dump https://sourceforge.net/projects/dcm4che/files/dcm4chee-arc-
light5/$DCMARCVER/ | grep mysql.zip | grep download | sed -e 's/^.*https/https/'`
# Install dcm4chee-arc-light
if [ -e "dcm4chee-arc-$DCMARCVER-mysql.zip" ]; then
echo -e " $SY dcm4chee already downloaded, skipping download... $SD"
echo -e " Unpacking dcm4chee dcm4chee-arc-light $DCMARCVER ..."
unzip -q dcm4chee-arc-$DCMARCVER-mysql.zip
mv dcm4chee-arc-$DCMARCVER-mysql $INSTALLDIR/
ln -s $INSTALLDIR/dcm4chee-arc-$DCMARCVER-mysql $INSTALLDIR/dcm4chee-arc-light
else
echo -e " $SG Downloading dcm4chee-arc-light $DCMARCVER ... $SD"
$WGET $DCMARCURL
mv download dcm4chee-arc-$DCMARCVER-mysql.zip
echo -e " Unpacking dcm4chee dcm4chee-arc-light $DCMARCVER ..."
unzip -q dcm4chee-arc-$DCMARCVER-mysql.zip
mv dcm4chee-arc-$DCMARCVER-mysql $INSTALLDIR/
ln -s $INSTALLDIR/dcm4chee-arc-$DCMARCVER-mysql $INSTALLDIR/dcm4chee-arc-light
fi
# Install Weasis
if [ -e "weasis.war" ]; then
echo -e "$SY Weasis already downloaded, skipping download... $SD"
echo -e " Installing Weasis $WEASISVER"
#cp weasis.war $WILDFLYDIR/standalone/deployments/
cp weasis.war $DCM4CHEEDIR/deploy/
echo -e "$SG Downloading latest version of weasis.ldif $SD"
rm weasis.ldif
$WGET
"https://dcm4che.atlassian.net/wiki/download/attachments/3670023/weasis.ldif"
else
echo -e "$SG Downloading Weasis $WEASISVER ... $SD"
$WGET
https://sourceforge.net/projects/dcm4che/files/Weasis/$WEASISVER/weasis.war/
download
mv download weasis.war
echo -e " Installing Weasis $WEASISVER"
#cp weasis.war $WILDFLYDIR/standalone/deployments/
cp weasis.war $DCM4CHEEDIR/deploy/
echo -e "$SG Downloading latest version of weasis.ldif $SG"
rm weasis.ldif
$WGET
"https://dcm4che.atlassian.net/wiki/download/attachments/3670023/weasis.ldif"
fi
# Install weasis-pacs-connector
if [ -e "weasis-pacs-connector.war" ]; then
echo -e " $SY Weasis pacs connector already downloaded, skipping download...
$SD"
#echo "Installing Weasis pacs connector $PACSCONVER"
#echo -e " Copying weasis-pacs-connector.war to $DCM4CHEEDIR/deploy/"
#cp weasis-pacs-connector.war $WILDFLYDIR/standalone/deployments/
cp weasis-pacs-connector.war $DCM4CHEEDIR/deploy/
else
echo -e "$SG Downloading Weasis pacs connector $PACSCONVER ... $SD"
$WGET https://sourceforge.net/projects/dcm4che/files/Weasis/weasis-pacs-
connector/$PACSCONVER/weasis-pacs-connector.war/download
mv download weasis-pacs-connector.war
#echo "Installing Weasis pacs connector $PACSCONVER"
#echo -e "Copying weasis-pacs-connector.war to $DCM4CHEEDIR/deploy/"
#cp weasis-pacs-connector.war $WILDFLYDIR/standalone/deployments/
cp weasis-pacs-connector.war $DCM4CHEEDIR/deploy/
fi
# Configure LDAP
echo -e "\n $SG Creating LDAP database... $SD"
cat <<EOF >/etc/ldap/ldap.conf
BASE ${LDAPROOT}
URI ldapi://
EOF
echo -e " Importing LDAP schema files for OpenLDAP runtime configuration"
cd $DCM4CHEEDIR/ldap/
cat <<EOF >modify-baseDN.ldif
dn: olcDatabase={1}mdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: ${LDAPROOT}
-
replace: olcRootDN
olcRootDN: cn=admin,${LDAPROOT}
-
EOF
ldapmodify -Y EXTERNAL -H ldapi:/// -f ./modify-baseDN.ldif >> $INSTALLOG 2>&1
#cp init-baseDN.ldif init-baseDN.ldif.orig
cp init-config.ldif init-config.ldif.orig
cp default-config.ldif default-config.ldif.orig
cp add-vendor-data.ldif add-vendor-data.ldif.orig
#sed -i s/dc=dcm4che,dc=org/$LDAPROOT/ init-baseDN.ldif
sed -i s/dc=dcm4che,dc=org/$LDAPROOT/ init-config.ldif
sed -i s/dc=dcm4che,dc=org/$LDAPROOT/ default-config.ldif
sed -i s/dc=dcm4che,dc=org/$LDAPROOT/ add-vendor-data.ldif
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f $DCM4CHEEDIR/ldap/slapd/dicom.ldif >>
$INSTALLOG 2>&1
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f $DCM4CHEEDIR/ldap/slapd/dcm4che.ldif >>
$INSTALLOG 2>&1
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f $DCM4CHEEDIR/ldap/slapd/dcm4chee-
archive.ldif >> $INSTALLOG 2>&1
#ldapadd -x -D cn=admin,$LDAPROOT -w $LDAPADMINPW -f $DCM4CHEEDIR/ldap/init-
baseDN.ldif >> $INSTALLOG
ldapadd -x -D cn=admin,$LDAPROOT -w $LDAPADMINPW -f $DCM4CHEEDIR/ldap/init-
config.ldif >> $INSTALLOG 2>&1
cp default-config.ldif default-config.ldif.tmp
cat default-config.ldif.tmp | sed -e 's/DCM4CHEE_ADMIN/'$AET'_ADMIN/g' -e
's/DCM4CHEE_TRASH/'$AET'_TRASH/g' -e 's/DCM4CHEE/'$AET'/g' > default-config.ldif
rm default-config.ldif.tmp
ldapadd -x -D cn=admin,$LDAPROOT -w $LDAPADMINPW -f $DCM4CHEEDIR/ldap/default-
config.ldif >> $INSTALLOG 2>&1
ldapadd -x -D cn=admin,$LDAPROOT -w $LDAPADMINPW -f $DCM4CHEEDIR/ldap/add-vendor-
data.ldif >> $INSTALLOG 2>&1
# Restart LDAP-server
echo -e " Restarting LDAP"
/etc/init.d/slapd restart
# Configure Wildfly
echo -e "\n $SG Configuring Wildfly... $SD"
cp -r $DCM4CHEEDIR/configuration/dcm4chee-arc $WILDFLYDIR/standalone/configuration
cd $WILDFLYDIR/standalone/configuration
cp standalone-full.xml dcm4chee-arc.xml
cd $WILDFLYDIR
for f in `find $DCM4CHEEDIR/jboss-modules -name *.zip`; do unzip -q $f; done
cp modules/com/mysql/main/module.xml modules/com/mysql/main/module.xml.orig
cat modules/com/mysql/main/module.xml.orig | sed -e 's/<resource-root
path=".*/<resource-root path="\/usr\/share\/java\/mysql-connector-java.jar"\/>/' >
modules/com/mysql/main/module.xml
cat <<EOF >$DCM4CHEEDIR/cli/add-data-source-mysql.cli
/subsystem=datasources/jdbc-driver=mysql:add(driver-module-name=com.mysql,driver-
name=mysql)
data-source add --name=pacsds --driver-name=mysql --jndi-name=java:/PacsDS \
--connection-url=jdbc:mysql://localhost:3306/pacsdb \
--user-name=pacs --password=pacs
EOF
cat <<EOF >$WILDFLYDIR/standalone/configuration/dcm4chee-arc/ldap.properties
java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory
java.naming.ldap.attributes.binary=dicomVendorData
java.naming.provider.url=ldap://localhost:389/$LDAPROOT
java.naming.security.principal=cn=admin,$LDAPROOT
java.naming.security.credentials=$LDAPADMINPW
EOF
fi
EOF
chmod +x /usr/local/bin/pacs_stop.sh