#paste one line
apt update; apt-get -y install joe tree unzip fastjar tomcat8 tomcat8-admin postgresql postgis
#paste one line
apt-get -y dist-upgrade; apt-get -y autoremove; sync; reboot
#log in again, then paste the following all the way to starting tomcat again
systemctl stop tomcat8
ed /etc/default/tomcat8 <<EOF
/^TOMCAT8_USER
s/tomcat8/root
/^JAVA_OPTS
s/-Xmx128m/
wq
EOF
ed /etc/tomcat8/tomcat-users.xml <<EOF
/manager-gui
/-->
a
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui,admin-gui"/>
.
wq
EOF
wget https://downloads.sourceforge.net/project/cmdbuild/2.5.1/cmdbuild-2.5.1.zip
unzip cmdbuild-2.5.1.zip
cp cmdbuild-2.5.1/extras/tomcat-libs/6.0\ or\ higher/postgresql-9.4.1207.jar /usr/share/tomcat8/lib/
wget https://sourceforge.net/projects/openmaint/files/1.1/Core%20updates/openmaint-1.1-2.5.1.zip
unzip openmaint-1.1-2.5.1.zip
mkdir shark; ( cd shark; jar -xf ../cmdbuild-shark-server-openmaint-2.5.1.war )
mkdir openmaint; ( cd openmaint; jar -xf ../cmdbuild-openmaint-2.5.1.war )
mv shark openmaint /var/lib/tomcat8/webapps/
ed /var/lib/tomcat8/webapps/shark/META-INF/context.xml <<EOF
/url
s/\${cmdbuild}/openmaint
wq
EOF
ed /var/lib/tomcat8/webapps/shark/conf/Shark.conf <<EOF
/cmdbuild.ws.url
s/cmdbuild/openmaint
/cmdbuild.ws.username
s/workflow/postgres
/cmdbuild.ws.password
s/changeme/postgres
wq
EOF
su - postgres -c psql <<EOF
alter role postgres password 'postgres' login;
create role shark password 'shark' login;
EOF
rm /var/log/tomcat8/*
systemctl start tomcat8
# end paste, now...
# Log in, select Demo database, name openmaint, localhost 5432 postgres postgres
# It takes a while but all should come up. Then click through to Administration
#Download ~/cmdbuild-2.5.1/extras/workflow/RFC/RequestForChange.xpdl and upload into administration, processes, XPDL.
cd /var/log/tomcat8
#check for error messages. Should not be any errors.