-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathinstall.sh
executable file
·148 lines (134 loc) · 5.17 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#! /bin/bash -
# Copyright 2018 Bergmann's Lab UNIL <[email protected]>
# This file is part of MONET.
#
# MONET is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# MONET is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MONET. If not, see <https://www.gnu.org/licenses/>.
#
###############################################################################
# Mattia Tomasoni - UNIL, CBG
# 2017 DREAM challenge on Disease Module Identification
# https://www.synapse.org/modulechallenge
###############################################################################
echo
echo "MONET: MOdularising NEtwork Toolbox"
echo " for mining of molecular and genetic networks"
echo
user_home=$HOME
username=$(whoami)
# check whether monet is already installed
if [ -d $user_home/.monet ]; then
read -p "MONET is already installed. Would you like to overwrite? [y|n] " -n 1 -r
echo ""
if [[ $REPLY =~ ^[y]$ ]]; then
echo y | ./uninstall.sh > /dev/null 2>&1
elif [[ $REPLY =~ ^[n]$ ]]; then
echo "EXITING: MONET WAS NOT RE-INSTALLED."
exit 0
else
echo ""
echo "ERROR: invalid option selected."
echo "EXITING: MONET WAS NOT RE-INSTALLED."
exit 0
fi
fi
# check that either docker or singularity are installed
echo "- Are docker or singularity installed?..."
docker --help > /tmp/docker_test 2>&1
if [ $? -eq "0" ]; then docker_installed=true; else docker_installed=false; fi
singularity --help > /tmp/singularity_test 2>&1
if [ $? -eq "0" ]; then singularity_installed=true; else singularity_installed=false; fi
if ! $docker_installed && ! $singularity_installed; then
echo " ERROR: Neither docker nor singularity are installed."
echo " Install either of the two to successfully run monet."
echo " Please visit https://www.docker.com or http://singularity.lbl.gov"
echo "" && echo "ABORTING: monet WAS NOT INSTALLED."
exit 1
else
echo " ...YES"
fi
# store monet code in the home directory
echo "- Copying files..."
mkdir $user_home/.monet
cp -r ./* $user_home/.monet
cp -r ./. $user_home/.monet
chmod -R 750 $user_home/.monet
# some folders were hidden in the repo to avoid confusing the user
mv $user_home/.monet/.monet $user_home/.monet/monet
mv $user_home/.monet/.src $user_home/.monet/src
mv $user_home/.monet/.test $user_home/.monet/test
mv $user_home/.monet/.containers $user_home/.monet/containers
echo " ...DONE"
function add_to_path {
# make monet command available: add location where monet will be installed to $PATH
case ":$PATH:" in
*"monet"*)
# already in path due to previous installation, nothing to do
echo "" && echo "Installation completed!"
;;
*)
# add to bashrc
echo ""; echo export PATH=\"'$PATH':$HOME/.monet\" >> $user_home/.bashrc
# add to bash_profile (this is necessary on macOS)
echo ""; echo export PATH=\"'$PATH':$HOME/.monet\" >> $user_home/.bash_profile
;;
esac
}
# in the case of Singularity users, the images need to be built by root
if ! $docker_installed && $singularity_installed; then
echo ""
echo "It appears only Singularity is intalled on this system."
echo "To complete the installation, you need SUPERUSER rights and INTERNET access."
read -p "Do you want to proceed? [y|n] " -n 1 -r
echo " " && echo "Please wait while the Singularity containers are being built"
echo "(this takes a few minutes)"
if [[ $REPLY =~ ^[y]$ ]]
then
# I could alternatively su root, but this does not work on Debian
cd $user_home/.monet/containers/K1/singularity
sudo singularity build ./K1-image.img Singularity
cd $user_home/.monet/containers/M1/singularity
sudo singularity build ./M1-image.img Singularity
cd $user_home/.monet/containers/R1/singularity
sudo singularity build ./R1-image.img Singularity
chmod -R 750 $user_home/.monet
else
echo " "
echo "The installation will need to be completed, manually, at a later stage."
echo "Please refer to MONET/doc/installation_no_sudo"
add_to_path
exit 0
fi
fi
# (optionally) test the installation
echo ""
read -p "Would you like to test the installation? (takes a few mins) [y|n] " -n 1 -r
echo ""
if [[ $REPLY =~ ^[y]$ ]]
then
echo "- Testing, thank you for waiting... "
cd $user_home/.monet/test/system_test && ./quick_test.sh > /dev/null 2>&1 && cd ..
if [ $? -gt "0" ]; then
echo " ERROR: see /tmp/monet_quick_test/console_output.txt"
echo "" && echo "ABORTING: monet WAS NOT INSTALLED."
exit 1
else
echo " ...OK"
fi
fi
add_to_path
echo ""
echo "SUCCESS: please provide your password to finalize the installation."
echo "You are being REDIRECTED TO YOUR HOME DIRECTORY"
echo "INVOKE monet FROM ANY LOCATION"
su - $username #re-login and execute the profile script to make monet command available