Ubuntu 12.04 setup script
We have just setup for the first time using Ubuntu 12.04. Having had some difficulties with setup/installation we engaged the services of a gentleman who was far more experienced with linux. He has provided us with a setup script, so we thought we would share this. I hope this may be of assistance to someone, it certainly was to us.
*I could not attach it as a file, so here are the contents.
#!/bin/sh
#
# Script to install OpenVPMS
# Put the current version of VPMS here :
VERSION=1.5.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 <enter> to continue..."
read my_dummy_value
fi
if apt-get -y install mysql-server phpmyadmin tomcat6 tomcat6-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/tomcat6/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/tomcat6
# 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@#TOMCAT6_SECURITY=no@TOMCAT6_SECURITY=yes@' /etc/default/tomcat6
# ln -s /etc/java-6-openjdk/security/java.policy /etc/tomcat6/policy.d/
if grep 'role rolename="manager"' /etc/tomcat6/tomcat-users.xml; then
echo "tomcat-users.xml already has a manager user. Is this OK?"
else
sed -i 's@<tomcat-users>@<tomcat-users>\
<role rolename="manager"/>\
<role rolename="admin"/>\
<user username="admin" password="admin" roles="manager,admin"/>@' /etc/tomcat6/tomcat-users.xml
fi
/etc/init.d/apache2 restart
/etc/init.d/tomcat6 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-1.5.1/webapps/openvpms.war /var/lib/tomcat6/webapps
chown tomcat6.tomcat6 /usr/local/openvpms-release-1.5.1/webapps/openvpms.war
/etc/init.d/tomcat6 restart
#FIXME: For some reason this is required... why?
rm -R /var/lib/tomcat6/webapps/openvpms
/etc/init.d/tomcat6 restart
sed -i 's[at]log4j.appender.fileout[dot]File=openvpms.log[at]log4j.appender.fileout[dot]File=/var/lib/tomcat6/webapps/openvpms.log@' /var/lib/tomcat6/webapps/openvpms/WEB-INF/classes/log4j.properties
sed -i 's[at]log4j.appender.fullout[dot]File=openvpms-full.log[at]log4j.appender.fullout[dot]File=/var/lib/tomcat6/webapps/openvpms-full.log@' /var/lib/tomcat6/webapps/openvpms/WEB-INF/classes/log4j.properties
/etc/init.d/tomcat6 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/tomcat6/tomcat-users.xml"
# NOTE: While testing this script I had some stuck settings. I deleted my
# <tomcat6>/webapps/openvpms directory to reset things.
Re: Ubuntu 12.04 setup script
This post is a smidge old, but I just wanted to say THANK YOU as it helped me get OpenVPMS up and running on Ubuntu Server. I didn't actually use the script but basically used it as a "checklist." So, if you're looking to get up and running successfully on Ubuntu, this script appears to be a great guide.