#!/bin/sh # # Script to install OpenVPMS # Put the current version of VPMS here : VERSION=1.7.1 # We must run this script as root if [ "$USER" != "root" ]; then echo "Must be root to execute script..." exit 1 fi # Check for valid IP. Warn if only configured to 127.0.x.x my_fqdn=`hostname -f` my_host_ip=`grep $my_fqdn /etc/hosts | awk '{ print $1 }'` echo "" echo "Your fully qualified hostname is "$my_fqdn echo "and your IP is "$my_host_ip if [ "$my_host_ip" = "127.0.1.1" ] || [ "$my_host_ip" = "127.0.0.1" ]; then echo "" echo "You should really make your hostname resolve to a valid network IP." echo "This is required for plugins such as OPSI and is generally a good idea." echo "To do this edit your /etc/hosts file and make sure your hostname" echo "(printed above) resolves to an IP other than 127.x.x.x" echo "Your /etc/network/interfaces will also need to match. eg. :" echo "iface eth0 inet static" echo " address 192.168.1.120" echo " netmask 255.255.255.0" echo " gateway 192.168.1.1" echo "To make this take effect : killall dhclient;ifdown eth0;ifup eth0" echo "'Ctrl-C' to exit or hit to continue..." read my_dummy_value fi if apt-get -y install mysql-server phpmyadmin tomcat7 tomcat7-admin libmysql-java libreoffice-writer libreoffice-draw; then echo "Installation of OpenVPMS prerequisite packages successful..." else echo "Installation of OpenVPMS prerequisite packages failed. Exiting..." exit 1 fi # FIXME: This script kills all soffice instances running on the computer. # This will also kill any GUI sessions, which is not a good thing. # Perhaps the following script could provide a better base : # https://bbs.archlinux.org/viewtopic.php?id=132542 cat > /etc/init.d/libreoffice <<-\EOF #!/bin/bash # LibreOffice headless server script # # chkconfig: 2345 80 30 # description: headless openoffice server script # processname: libreoffice # # Author: Vic Vijayakumar # Modified by Federico Ch. Tomasczik # and then by Mark Pavlichuk # LIBRE_HOME=/usr/bin LIBREOFFICE_PATH=$LIBRE_HOME/soffice PIDFILE=/var/run/libreoffice-server.pid set -e case "$1" in start) if [ -f $PIDFILE ]; then echo "LibreOffice headless server has already started." sleep 5 exit fi echo "Starting LibreOffice headless server" $LIBREOFFICE_PATH --headless --nologo --nofirststartwizard --accept="socket,host=127.0.0.1,port=8100;urp" & > /dev/null 2>&1 touch $PIDFILE ;; stop) if [ -f $PIDFILE ]; then echo "Stopping LibreOffice headless server." killall -9 soffice killall -9 soffice.bin rm -f $PIDFILE exit fi echo "LibreOffice headless server is not running." exit ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0 EOF chmod 0755 /etc/init.d/libreoffice update-rc.d libreoffice defaults /etc/init.d/libreoffice start sed -i 's@upload_max_filesize = 2M@upload_max_filesize = 20M@' /etc/php5/apache2/php.ini ln -s /usr/share/java/mysql* /usr/share/tomcat7/lib/ sed -i 's@JAVA_OPTS="-Djava.awt.headless=true -Xmx128m -XX:+UseConcMarkSweepGC"@JAVA_OPTS="-Djava.awt.headless=true -Xms128m -Xmx512m -XX:+UseConcMarkSweepGC"@' /etc/default/tomcat7 # FIXME: Perhaps this information on security has some bearing # here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=649046 # If we can enable security uncomment the following lines perhaps # sed -i 's@#TOMCAT7_SECURITY=no@TOMCAT7_SECURITY=yes@' /etc/default/tomcat7 # ln -s /etc/java-6-openjdk/security/java.policy /etc/tomcat7/policy.d/ if grep 'role rolename="manager"' /etc/tomcat7/tomcat-users.xml; then echo "tomcat-users.xml already has a manager user. Is this OK?" else sed -i 's@@\ \ \ @' /etc/tomcat7/tomcat-users.xml fi /etc/init.d/apache2 restart /etc/init.d/tomcat7 restart cd /usr/local if [ ! -f /usr/local/openvpms-release-$VERSION.zip ]; then wget http://repository.openvpms.org/releases/org/openvpms/openvpms-release/$VERSION/openvpms-release-$VERSION.zip fi unzip openvpms-release-$VERSION.zip ln -s /usr/share/java/mysql* /usr/local/openvpms-release-$VERSION/lib cd openvpms-release-$VERSION/db sed -i 's@\[client]@[client]\ default-character-set=utf8@' /etc/mysql/my.cnf sed -i 's@\[mysqld]@[mysqld]\ character-set-server=utf8\ collation-server=utf8_unicode_ci@' /etc/mysql/my.cnf /etc/init.d/mysql restart echo "" echo "Enter the root password for the MySQL server..." mysql -u root -p < createdb.sql mysql -u openvpms -popenvpms -D openvpms < db.sql cd /usr/local/openvpms-release-$VERSION/bin ./dataload.sh setup cat > /etc/cron.hourly/openvpms-docimport.sh <<-EOF cd /usr/local/openvpms-release-$VERSION/bin/ ./docload.sh --byid --source /usr/local/openvpms-release-$VERSION/docimport --dest /usr/local/openvpms-release-$VERSION/docarchive --verbose EOF mkdir /usr/local/openvpms-release-$VERSION/docarchive /usr/local/openvpms-release-$VERSION/docimport chmod 755 /etc/cron.hourly/openvpms-docimport.sh ln -s /usr/local/openvpms-release-$VERSION/webapps/openvpms.war /var/lib/tomcat7/webapps chown tomcat7.tomcat7 /usr/local/openvpms-release-$VERSION/webapps/openvpms.war /etc/init.d/tomcat7 restart #FIXME: For some reason this is required... why? rm -R /var/lib/tomcat7/webapps/openvpms /etc/init.d/tomcat7 restart #FIXME: No longer required? #sed -i 's@log4j.appender.fileout.File=openvpms.log@log4j.appender.fileout.File=/var/lib/tomcat7/webapps/openvpms.log@' /var/lib/tomcat7/webapps/openvpms/WEB-INF/classes/log4j.properties #sed -i 's@log4j.appender.fullout.File=openvpms-full.log@log4j.appender.fullout.File=/var/lib/tomcat7/webapps/openvpms-full.log@' /var/lib/tomcat7/webapps/openvpms/WEB-INF/classes/log4j.properties #/etc/init.d/tomcat7 restart echo "Log onto your server at http://"`hostname --fqdn`":8080/openvpms" echo "Username: admin" echo "Password: admin" echo "" echo "...also, to secure the Tomcat management interface change the" echo "password for the admin user in this file :" echo "/etc/tomcat7/tomcat-users.xml" # NOTE: While testing this script I had some stuck settings. I deleted my # /webapps/openvpms directory to reset things.