-
Notifications
You must be signed in to change notification settings - Fork 31
metalims.sh
#! /bin/bash/
#Usage: source metalims.sh
#Installs MetaLIMS from github repository. Installs sendmail
#Assumes a version of Ubuntu.
#Platform options ubuntu14 and ubunt16 assume you have php5 and php7 respectively
#Requires git --version 1.8 or greater
#Install sendmail
sudo apt-get install sendmail
sudo apt-get install mailutils
read -p "What platform are you using? [ubuntu14,ubuntu16,other] : " platform
if [ "$platform" = "ubuntu14" ]; then
sudo echo "sendmail_path = "env -i /usr/sbin/sendmail -t -i"" | sudo tee -a /etc/php5.0/apache2/php.ini > /dev null
outside_webroot="/var/www"
webroot="/var/www/html"
#Restart all the installed services to verify that everything is installed properly
sudo service apache2 restart
sudo service mysql restart
elif [ "$platform" = "ubuntu16" ]; then
sudo echo "sendmail_path = "env -i /usr/sbin/sendmail -t -i"" | sudo tee -a /etc/php/7.0/apache2/php.ini > /dev/null
outside_webroot="/var/www"
webroot="/var/www/html"
#Restart all the installed services to verify that everything is installed properly
sudo systemctl restart apache2
sudo systemctl restart mysql
else
read -p "What is the path to your php.ini file? [ex:/etc/php[#]/apache2/php.ini] : " php_ini_path
sudo echo "sendmail_path = "env -i /usr/sbin/sendmail -t -i"" | sudo tee -a $php_ini_path > /dev/null
read -p "What is the path to your webroot? [ex:/var/www/html] : " webroot
read -p "What is the path to one directory outside webroot? [ex:/var/html] : " outside_webroot
#Restart all the installed services to verify that everything is installed properly
sudo apache2ctl restart
sudo systemctl restart mysql
fi
#Change directory to web root
cd $webroot
#Get MetaLIMS2.0 from github
sudo apt-get install git
#Store git files in separate directory (One level up from webroot). Only download desired branch
sudo git clone --single-branch https://github.com/cheinle/MetaLIMS.git --separate-git-dir=../separate_git_directory
cd MetaLIMS
sudo git checkout v2.1
#Change folder permissions for download files.Change file ownership to apache/php user for ubuntu
sudo chown -R www-data:www-data $webroot/MetaLIMS/sequencing/sequencing_form.xlsx
sudo chown -R www-data:www-data $webroot/MetaLIMS/query_samples/metalims_export.txt
sudo chown -R www-data:www-data $webroot/MetaLIMS/query_samples/metalims_user_created_export.txt
sudo chown -R www-data:www-data $webroot/MetaLIMS/labels/metalims_labels.txt
sudo chown -R www-data:www-data $webroot/MetaLIMS/admin_tools/uploads/
#Move Important_Accessories.zip outside of web root
cd $outside_webroot/
sudo mkdir metalims_config
cd metalims_config/
sudo mv $webroot/MetaLIMS/Important_Accessories.zip $outside_webroot/metalims_config/.
sudo apt-get install unzip
sudo unzip Important_Accessories.zip
sudo rm Important_Accessories.zip
#Get bitnami password or prompt user for mysql password
if [ "$platform" = "bitnami" ]; then
password=$(cat $outside_webroot/bitnami_application_password)
else
read -s -p "Please enter your mysql root password : " password
fi
#Check if installing demo version or regular
read -p "Would you like to install MetaLIMS Demo?[Y/N]: " demo
if [ "$demo" = "Y" ]; then
#Create MetaLIMS db and user for demo
mysql --user="root" --password="$password" --execute="source metalims_demo.sql"
#Change MetaLIMS db password
read -s -p "Please enter a new metalims mysql db password : " new_password
mysql --user="root" --password="$password" --execute="SET PASSWORD FOR 'metalims_test'@'localhost' = PASSWORD('$new_password');FLUSH PRIVILEGES;"
#Create connection.php and edit database_connection.php. Remove strict mode. Change permissions on connection.php
config_path=$(pwd)
echo "<?php \$dbc =@mysqli_connect('localhost','metalims_test','$new_password','metalims_demo') or die ('Could not connect to the database because:'.mysqli_connect_error()); mysqli_query(\$dbc, \"SET SESSION sql_mode = ''\"); ?>" | sudo tee connection.php > /dev/null
echo "<?php include('$config_path/connection.php');?>" | sudo tee $webroot/MetaLIMS/database_connection.php > /dev/null
else
#Create MetaLIMS db and user
mysql --user="root" --password="$password" --execute="source metalims_empty.sql"
#Change MetaLIMS db password
read -s -p "Please enter a new metalims mysql db password : " new_password
mysql --user="root" --password="$password" --execute="SET PASSWORD FOR 'metalims'@'localhost' = PASSWORD('$new_password');FLUSH PRIVILEGES;"
#Create connection.php and edit database_connection.php. Remove strict mode
config_path=$(pwd)
echo "<?php \$dbc =@mysqli_connect('localhost','metalims','$new_password','metalims_empty') or die ('Could not connect to the database because:'.mysqli_connect_error()); mysqli_query(\$dbc, \"SET SESSION sql_mode = ''\"); ?>" | sudo tee connection.php > /dev/null
echo "<?php include('$config_path/connection.php');?>" | sudo tee $webroot/MetaLIMS/database_connection.php > /dev/null
fi