#!/bin/bash

echo -n "Please enter a password for the root user for mysql. For security the characters will not show as you type."
echo

read -s psswd


#`mysql -uroot  -e "GRANT ALL PRIVILEGES ON *.* TO 'root@'localhost' IDENTIFIED BY '$psswd' WITH GRANT OPTION;"`

echo "Uncompressing eprints. This will cause a whole lot of writing to scroll past in this terminal."
tar -xvzf eprints-3.0.tar.gz

echo "Configuring eprints. More writing will flash past."
eprints-3.0/configure


echo "Installing eprints3. You will be asked for your eprints user password next. During the install process you will be given a warning about smtp server. Don't worry about this as we will set it up shortly."

sudo ./eprints-3.0/install.pl

cd /opt/eprints3

exit

echo -n "Creating your archive. If you want to have a look at the example answers for creating an archive type y and  firefox will be uncompressed so you can look at the "installer.html file."

read answer

echo

if [ "y" = "$answer" ]
	then 

	cd ~;
	tar -xzf ~firefox-2.0.0.1.tar.gz;
        firefox/firefox installer.html;

fi

cd /opt/eprints3

echo "You will now be asked some questions to set up your archive. "


bin/epadmin create

echo "Setting up the mail server. You will need to put in your eprints password when prompted"
sudo mv perl_lib/EPrints/SystemSettings.pm perl_lib/EPrints/SystemSettingsOld.pm
sed  -e "s/smtp_server=>''/smtp_server=>'127.0.0.1'/" perl_lib/EPrints/SystemSettingsOld.pm > perl_lib/EPrints/SystemSettings.pm


echo -n "Do you want to start the apache server now? y\n?
read answer1

if [ "y" = "$answer1" ]
echo "Enter your eprints password when prompted."       
sudo apache2 -k start

fi


