-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·184 lines (164 loc) · 9.13 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/usr/bin/env bash
# ██████╗ ███╗ ██╗███████╗ ██████╗██╗ ██╗ ██████╗██╗ ██╗
# ██╔═══██╗████╗ ██║██╔════╝ ██╔════╝██║ ██║██╔════╝██║ ██╔╝
# ██║ ██║██╔██╗ ██║█████╗ ██║ ██║ ██║██║ █████╔╝
# ██║ ██║██║╚██╗██║██╔══╝ ██║ ██║ ██║██║ ██╔═██╗
# ╚██████╔╝██║ ╚████║███████╗ ╚██████╗███████╗██║╚██████╗██║ ██╗
# ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═════╝╚══════╝╚═╝ ╚═════╝╚═╝ ╚═╝
# ██╗ ██╗███████╗██████╗ ███████╗██╗████████╗███████╗
# ██║ ██║██╔════╝██╔══██╗██╔════╝██║╚══██╔══╝██╔════╝
# ██║ █╗ ██║█████╗ ██████╔╝███████╗██║ ██║ █████╗
# ██║███╗██║██╔══╝ ██╔══██╗╚════██║██║ ██║ ██╔══╝
# ╚███╔███╔╝███████╗██████╔╝███████║██║ ██║ ███████╗
# ╚══╝╚══╝ ╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚══════╝
# ██████╗ ███████╗██████╗ ██╗ ██████╗ ██╗ ██╗███████╗██████╗
# ██╔══██╗██╔════╝██╔══██╗██║ ██╔═══██╗╚██╗ ██╔╝██╔════╝██╔══██╗
# ██║ ██║█████╗ ██████╔╝██║ ██║ ██║ ╚████╔╝ █████╗ ██████╔╝
# ██║ ██║██╔══╝ ██╔═══╝ ██║ ██║ ██║ ╚██╔╝ ██╔══╝ ██╔══██╗
# ██████╔╝███████╗██║ ███████╗╚██████╔╝ ██║ ███████╗██║ ██║
# ╚═════╝ ╚══════╝╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
# Developed for https://BharatGenomeDatabase.org by
# Shreyas A S [https://github.com/shreyas-a-s/website-tripal]
# Sastha Kumar N [https://github.com/Sastha-Kumar-N]
# Sabarinath Subramaniam [https://www.linkedin.com/in/sabarinath-subramaniam-a228014]
# Create log files and append OS info to them
if [ ! -f ~/oneclick-website-deployer.log ] || ! grep -qF 'SYS INFO' ~/oneclick-website-deployer.log; then
printf -- "--------\
\nSYS INFO\
\n--------\
\n%s\
\n--------\
\n" "$(grep -iv 'url' /etc/os-release)" | tee -a ~/oneclick-website-deployer.log ~/oneclick-website-deployer-errors.log > /dev/null
fi
# Append time of execution to log files
printf -- "-------------------------------\
\n%s\
\n-------------------------------\
\n" "$(date)" | tee -a ~/oneclick-website-deployer.log ~/oneclick-website-deployer-errors.log > /dev/null
# Redirect stdout to one log file and stderr to another
exec > >(tee -a ~/oneclick-website-deployer.log) 2> >(tee -a ~/oneclick-website-deployer-errors.log >&2)
# Define web root folder
export WEB_ROOT=/var/www/html
# Change directory
SCRIPT_DIR=$(dirname -- "$( readlink -f -- "$0"; )") && cd "$SCRIPT_DIR" || exit
# Source functions
for fn in ./functions/*.sh; do
. "$fn"
done
# Check & prepare environment
_install_whiptail # Install whiptail program that poweres the script
_set_whiptail_colors_default # Apply default whiptail colors
_is_os_supported # Check if the OS is on the supported list
_is_internet_available # Check if system is connected to internet
./scripts/show-about-us-page.sh # Display the "About Us" page on the screen
./scripts/install-dependencies.sh # Install dependency programs like wget, jq, etc.
# Prompt the user to enter inputs (database creds & memory limit)
while true; do
_input_db_name # PostgreSQL Database name
_input_db_username # PostgreSQL Database username
_input_db_pass # PostgreSQL Database password
_input_memory_limit # Maximum amount of memory a PHP script can consume
# Give user option to edit choices
whiptail --title "USER SELECTION" --yesno \
--defaultno \
--yes-button "Edit" \
--no-button "Continue" \
"Database Name: $psqldb\
\nDatabase User: $psqluser\
\nDatabase Password: $HIDDEN_PGPASSWORD\
\nMemory Limit: $memorylimit""MB\
\n\n You can edit the data if you want.\
\n (ARROW KEYS to move, ENTER to confirm)" \
14 53
exitstatus=$?
if [ $exitstatus = 0 ]; then
continue
else
break
fi
done
# Set whiptail BG color to cyan
_set_whiptail_colors_bg_cyan
# Prompt the user to enter inputs (drupal creds)
while true; do
_input_drupal_dir # Directory to which Drupal should be installed
_input_drupal_site_name # Name for website
_input_drupal_username # Username to use for Drupal
_input_drupal_pass # Password for drupal user
_input_drupal_mail # Email to be added to Drupal
_input_drupal_country # Default country to be set in Drupal
# Give user option to edit choices
whiptail --title "DRUPAL WEBSITE DETAILS" --yesno \
--defaultno \
--yes-button "Edit" \
--no-button "Continue" \
"Drupal Website Directory: $WEB_ROOT/$DRUPAL_HOME\
\nDrupal Site Name: $drupal_site_name\
\nDrupal Username: $drupal_user\
\nDrupal Password: $hidden_drupal_pass\
\nDrupal Email: $drupal_mail\
\nCountry: $drupal_country_name\
\n\n You can edit the data if you want.\
\n (ARROW KEYS to move, ENTER to confirm)" \
16 53
exitstatus=$?
if [ $exitstatus = 0 ]; then
continue
else
break
fi
done
# Prompt user to choose which website components to install
while true; do
_set_whiptail_colors_bg_magenta # Set whiptail BG color to magenta for selection of components
website_components=$(whiptail --title "COMPONENTS SELECTION" --checklist \
"\n Choose which website components to install\
\n (ARROW KEYS to move, SPACE to select,\
\n TAB to move between sections, ENTER to confirm):" 14 64 4 \
"Webform" "[Drupal module used to create Forms]" ON \
"Tripal Blast" "[Interface for using NCBI Blast+]" ON \
"Tripal JBrowse" "[Integrate GMOD JBrowse with Tripal]" ON \
3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 1 ]; then
exit 1
fi
if [[ -z $website_components ]]; then # Prompt user if they chose nothing
_set_whiptail_colors_bg_red # Set whiptail BG color to red indicating warning
whiptail --title 'ATTENTION PLEASE !!' --yesno \
--defaultno \
--yes-button "Go Back" \
--no-button "Continue" \
"You did not select any components to install. If this was intended, you can continue. If not, go back and choose the components by pressing SPACE.\
\n (ARROW KEYS to move, ENTER to confirm)" \
11 53
exitstatus=$?
if [ $exitstatus = 0 ]; then
continue
else
break
fi
else
break
fi
done
# Set whiptail colors to default before proceeding
_set_whiptail_colors_default
# Custom scripts
./scripts/install-apache.sh # Web server used to run website
./scripts/install-php.sh # Major backend program for Drupal
./scripts/install-psql.sh # PostgreSQL - the database backend for Drupal
./scripts/install-drush.sh # Drush is the utility to manage Drupal from cli
./scripts/install-drupal.sh # Drupal powers the whole website
./scripts/setup-cron.sh # Replace drupal cron tasks with system cronjob
./scripts/install-tripal.sh # Install Tripal
./scripts/install-chado.sh # Install chado database
./scripts/prepare-chado.sh # Prepare website to work with chado
./scripts/install-tripal-daemon.sh # Tripal Daemon is used to automate execution of tripal jobs
if [[ -n $website_components ]]; then # Install tripal extensions based on user choice
[[ $website_components == *"Webform"* ]] && ./scripts/install-webform.sh
[[ $website_components == *"Tripal Blast"* ]] && ./scripts/install-tripal-blast.sh && ./scripts/setup-sample-blast-db.sh
[[ $website_components == *"Tripal JBrowse"* ]] && ./scripts/install-jbrowse.sh && ./scripts/install-tripal-jbrowse.sh
fi
# Provide users the option for an automatic system reboot
./scripts/auto-system-reboot.sh