Skip to content

nanolims.sh

cheinle edited this page Feb 5, 2017 · 10 revisions

#! /bin/bash/

#Usage: source nanolims.sh
#Installs NanoLIMS from github repository. Installs sendmail
#Assumes a version of Ubuntu

#Install sendmail
sudo apt-get install sendmail
sudo apt-get install mailutils
read -p "What platform are you using? [bitnami,ubuntu16,other] : " platform

if [ "$platform" = "bitnami" ]; then
sudo echo "sendmail_path = "env -i /usr/sbin/sendmail -t -i"" >> /home/bitnami/stack/php/etc/php.ini
outside_webroot="/home/bitnami"
webroot="/home/bitnami/htdocs"
#Restart all the installed services to verify that everything is installed properly
sudo /opt/bitnami/ctlscript.sh 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 service mysqld restart
fi

#Change directory to web root
cd $webroot

#Get NanoLIMS from github
sudo apt-get install git
sudo git clone https://github.com/cheinle/NanoLIMS.git

#Chamge folder permissions for download files.Change file ownership to apache/php user for ubuntu
sudo chown -R www-data:www-data $webroot/NanoLIMS/sequencing/sequencing_form.xlsx
sudo chown -R www-data:www-data $webroot/NanoLIMS/query_samples/nanolims_export.txt
sudo chown -R www-data:www-data $webroot/NanoLIMS/query_samples/nanolims_user_created_export.txt
sudo chown -R www-data:www-data $webroot/NanoLIMS/labels/nanolims_labels.txt

#Move Important_Accessories.zip outside of web root
cd $outside_webroot/
sudo mkdir nanolims_config
cd nanolims_config/
sudo mv $webroot/NanoLIMS/Important_Accessories.zip $outside_webroot/nanolims_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 NanoLIMS Demo?[Y/N]: " demo
if [ "$demo" = "Y" ]; then
#Create Nanolims db and user
mysql --user="root" --password="$password" --execute="source nanolims_demo.sql"

#Change Nanolims db password
read -s -p "Please enter a new nanolims mysql db password : " new_password
mysql --user="root" --password="$password" --execute="SET PASSWORD FOR 'nanolims_test'@'localhost' = PASSWORD('$new_password');FLUSH PRIVILEGES;"

#Create connection.php and edit database_connection.php. Remove strict mode
config_path=$(pwd)
echo "" | sudo tee connection.php > /dev/null
echo "" | sudo tee $webroot/NanoLIMS/database_connection.php > /dev/null
else
#Create Nanolims db and user
mysql --user="root" --password="$password" --execute="source nanolims_empty.sql"

#Change Nanolims db password
read -s -p "Please enter a new nanolims mysql db password : " new_password
mysql --user="root" --password="$password" --execute="SET PASSWORD FOR 'nanolims'@'localhost' = PASSWORD('$new_password');FLUSH PRIVILEGES;"

#Create connection.php and edit database_connection.php. Remove strict mode
config_path=$(pwd)
echo "" | sudo tee connection.php > /dev/null
echo "" | sudo tee $webroot/NanoLIMS/database_connection.php > /dev/null
fi