Difference between revisions of "SUNScholar/Rebuild DSpace"

From Libopedia
Jump to navigation Jump to search
m (Text replacement - "/home/dspace" to "$HOME")
Line 10: Line 10:
 
This is required because we chose to use the source code for our DSpace installation and then build the run-time WAR's after any major [[SUNScholar/Customisation|customisation]] in the source code, inclusive of the modules folder.
 
This is required because we chose to use the source code for our DSpace installation and then build the run-time WAR's after any major [[SUNScholar/Customisation|customisation]] in the source code, inclusive of the modules folder.
  
Changes can be made in the run-time folder '''/home/dspace/webapp''' but these will be overwritten with the next rebuild.
+
Changes can be made in the run-time folder '''$HOME/webapp''' but these will be overwritten with the next rebuild.
  
 
If you want changes in the run-time to be permanent, then copy them to source folder using the [[SUNScholar/Customisation#Advanced_Customisation_.28Modules_Overlay_Method.29|modules overlay method]], so that they are applied after the next rebuild.
 
If you want changes in the run-time to be permanent, then copy them to source folder using the [[SUNScholar/Customisation#Advanced_Customisation_.28Modules_Overlay_Method.29|modules overlay method]], so that they are applied after the next rebuild.
Line 24: Line 24:
 
===Step 2 - Create a scripts folder===
 
===Step 2 - Create a scripts folder===
 
Type the following:
 
Type the following:
  mkdir /home/dspace/scripts
+
  mkdir $HOME/scripts
  
 
===Step 3 - Create the script===
 
===Step 3 - Create the script===
 
Type the following:
 
Type the following:
  nano /home/dspace/scripts/build-webapps
+
  nano $HOME/scripts/build-webapps
  
 
Copy and paste the following into the open nano editor.
 
Copy and paste the following into the open nano editor.
Line 53: Line 53:
 
#Remove old webapps. Uncomment below to enable.
 
#Remove old webapps. Uncomment below to enable.
 
#echo "Clean out old webapps"
 
#echo "Clean out old webapps"
#sudo rm -rf /home/dspace/webapps/*
+
#sudo rm -rf $HOME/webapps/*
  
 
#### Optional ####
 
#### Optional ####
 
#Remove old config folder. Uncomment below to enable.
 
#Remove old config folder. Uncomment below to enable.
 
#echo "Clean out old configs"
 
#echo "Clean out old configs"
#sudo rm -rf /home/dspace/config/*
+
#sudo rm -rf $HOME/config/*
  
 
echo "Start MAVEN build"
 
echo "Start MAVEN build"
cd /home/dspace/source
+
cd $HOME/source
 
mvn -U clean package
 
mvn -U clean package
  
 
echo "Start ANT updates"
 
echo "Start ANT updates"
cd /home/dspace/source/dspace/target/dspace-XXX-build
+
cd $HOME/source/dspace/target/dspace-XXX-build
 
ant update
 
ant update
  
Line 88: Line 88:
 
#Fix file and folder permissions. Uncomment below to enable.
 
#Fix file and folder permissions. Uncomment below to enable.
 
#echo "Fixing file permissions. Please wait..."
 
#echo "Fixing file permissions. Please wait..."
#sudo chmod 0777 -R /home/dspace
+
#sudo chmod 0777 -R $HOME
 
#echo "Fixing file ownership. Please wait..."
 
#echo "Fixing file ownership. Please wait..."
#sudo chown dspace.dspace -R /home/dspace
+
#sudo chown dspace.dspace -R $HOME
  
 
echo "Rebuild complete."
 
echo "Rebuild complete."
Line 99: Line 99:
 
===Step 4 - Make the script executable===
 
===Step 4 - Make the script executable===
 
Type the following:
 
Type the following:
  chmod 0755 /home/dspace/scripts/build-webapps
+
  chmod 0755 $HOME/scripts/build-webapps
 
===Step 5 - Run the script===
 
===Step 5 - Run the script===
 
Now you can rebuild DSpace '''WHEN NEEDED''' by simply typing the following;
 
Now you can rebuild DSpace '''WHEN NEEDED''' by simply typing the following;
  /home/dspace/scripts/build-webapps
+
  $HOME/scripts/build-webapps
 
'''<font color="red">After the rebuild check that the config files have been copied over from the source folder correctly.</font>'''
 
'''<font color="red">After the rebuild check that the config files have been copied over from the source folder correctly.</font>'''
  

Revision as of 09:48, 23 January 2015

Back to After Installation Tasks

Rationale

To apply customisations, DSpace needs to rebuild the Java WAR's for re-deployment by the Tomcat webapp server.

For this to work, all permanent changes using the modules overlay method must be made in the [dspace-source] folder.

This is required because we chose to use the source code for our DSpace installation and then build the run-time WAR's after any major customisation in the source code, inclusive of the modules folder.

Changes can be made in the run-time folder $HOME/webapp but these will be overwritten with the next rebuild.

If you want changes in the run-time to be permanent, then copy them to source folder using the modules overlay method, so that they are applied after the next rebuild.

Requirements

Click here to setup the "source" folder first.

Procedure

Step 1 - Login to your server

Check the following wiki page, and then return.

http://wiki.lib.sun.ac.za/index.php/SUNScholar/Prepare_Ubuntu/S01

Step 2 - Create a scripts folder

Type the following:

mkdir $HOME/scripts

Step 3 - Create the script

Type the following:

nano $HOME/scripts/build-webapps

Copy and paste the following into the open nano editor.

Replace all instances of XXX with the DSpace version number selected for installation.
When using the Ubuntu 16.04 LTS server change all instances of tomcat to tomcat8.
When using the Ubuntu 14.04 LTS server change all instances of tomcat to tomcat7.
When using the Ubuntu 12.04 LTS server change all instances of tomcat to tomcat6.
#!/bin/bash

sudo service tomcat6 stop
sleep 3

#### Optional ####
#Remove old cache and log files. Uncomment below to enable.
#echo "Clean out old xmlui cache files"
#sudo rm /var/lib/tomcat6/work/Catalina/localhost/_/cache-dir/cocoon-ehcache.data
#sudo rm /var/lib/tomcat6/work/Catalina/localhost/_/cache-dir/cocoon-ehcache.index
#echo "Remove old catalina log file"
#sudo rm /var/log/tomcat6/catalina.out

#### Optional ####
#Remove old webapps. Uncomment below to enable.
#echo "Clean out old webapps"
#sudo rm -rf $HOME/webapps/*

#### Optional ####
#Remove old config folder. Uncomment below to enable.
#echo "Clean out old configs"
#sudo rm -rf $HOME/config/*

echo "Start MAVEN build"
cd $HOME/source
mvn -U clean package

echo "Start ANT updates"
cd $HOME/source/dspace/target/dspace-XXX-build
ant update

#### Optional ####
#Clean backups. Uncomment below to enable.
#ant clean_backups

#### Optional ####
#Overwrite configs. Uncomment below to enable.
#ant -Doverwrite=true update_configs

#### Optional ####
#Geolite database updates.
# !!!! Your server should be open on the internet before you do this !!!!
#Uncomment below to enable.
#sudo ant update_geolite

sleep 3
sudo service tomcat6 restart

#### Optional ####
#Fix file and folder permissions. Uncomment below to enable.
#echo "Fixing file permissions. Please wait..."
#sudo chmod 0777 -R $HOME
#echo "Fixing file ownership. Please wait..."
#sudo chown dspace.dspace -R $HOME

echo "Rebuild complete."

NANO Editor Help
CTL+O = Save the file and then press Enter
CTL+X = Exit "nano"
CTL+K = Delete line
CTL+U = Undelete line
CTL+W = Search for %%string%%
CTL+\ = Search for %%string%% and replace with $$string$$
CTL+C = Show line numbers

More info = http://en.wikipedia.org/wiki/Nano_(text_editor)


Step 4 - Make the script executable

Type the following:

chmod 0755 $HOME/scripts/build-webapps

Step 5 - Run the script

Now you can rebuild DSpace WHEN NEEDED by simply typing the following;

$HOME/scripts/build-webapps

After the rebuild check that the config files have been copied over from the source folder correctly.

References

"ant" target references

General references

Other Scripts

Rebuild Indexes

Click on the heading above.

Restart DSpace

Click on the heading above.