-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_web_servers.sh
executable file
·137 lines (111 loc) · 3.13 KB
/
install_web_servers.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
#!/usr/bin/env bash
# Filename:
# Description: install web-servers
# Author: Nanjiang Shu ([email protected])
set -e
#set -x
rundir=`dirname $0`
progname=`basename $0`
size_progname=${#progname}
wspace=`printf "%*s" $size_progname ""`
usage="
Usage: $progname method [method ...]
Options:
-h, --help Print this help message and exit
Created 2022-02-03, updated 2022-02-03, Nanjiang Shu
"
nodename=`uname -n`
case $nodename in
pcons*) webserver_base=/big/server/var/www;;
dev-web*) webserver_base=/software/server;;
*) webserver_base=/data3/server;;
esac
if [ $# -lt 1 ]; then
echo "$usage"
exit
fi
methodList=()
isDebug=0
url_base="https://github.com/NBISweden"
tmpdir=$(mktemp -d /tmp/tmpdir.install_web_servers.XXXXXXXXX) || { echo "Failed to create temp dir" >&2; exit 1; }
#trap 'rm -rf "$tmpdir"' INT TERM EXIT
InstallWebServer(){
local method="$1"
local reponame="predictprotein-webserver-${method}"
local git_url="${url_base}/${reponame}"
local servername=
case $method in
boctopus2) servername=dev.boctopus.bioshu.se;;
scampi2) servername=dev.scampi.bioshu.se;;
*) servername=dev.${method}.bioshu.se;;
esac
pushd $webserver_base
if [ ! -d $reponame ];then
git clone "$git_url"
else
echo "${webserver_base}/${reponame} exists."
fi
cd $reponame
git pull --all --prune
if [ ! -d env ] ;then
bash setup_virtualenv.sh
fi
source env/bin/activate
bash init.sh
deactivate
cd proj
echo $servername >> allowed_host_dev.txt
ln -sf dev_settings.py settings.py
popd
# creating symlink to the web server code base
pushd /var/www/html
if [ -L ${method} ] && [ -e ${method} ];then
echo "/var/www/html/$method exists. Ingore creating symlink!"
else
sudo ln -sfn ${webserver_base}/${reponame} $method
fi
popd
# creating config files
local exampleconf=$rundir/topcons2.apache2.conf.example
if [ -d /etc/httpd ];then
exampleconf=$rundir/topcons2.httpd.conf.example
fi
local conffile=/etc/httpd/conf.d/${method}.conf
if [ ! -s $conffile ] ;then
sed "s/topcons2/${method}/g" $exampleconf | sed "s/dev.topcons.bioshu.se/${servername}/g" | sudo tee $conffile 1> /dev/null
fi
}
isNonOptionArg=0
while [ "$1" != "" ]; do
if [ $isNonOptionArg -eq 1 ]; then
methodList+=("$1")
isNonOptionArg=0
elif [ "$1" == "--" ]; then
isNonOptionArg=true
elif [ "${1:0:1}" == "-" ]; then
case $1 in
-h | --help) echo "$usage"; exit;;
-q|-quiet|--quiet) isQuiet=1;;
-debug|--debug) isDebug=1;;
-*) echo Error! Wrong argument: $1 >&2; exit;;
esac
else
methodList+=("$1")
fi
shift
done
numMethod=${#methodList[@]}
numSpecialCountry=${#specialCountryList[@]}
if [ $numMethod -eq 0 ]; then
echo Input not set! Exit. >&2
exit 1
fi
for ((im=0;im<numMethod;im++));do
method=${methodList[$im]}
InstallWebServer "$method"
done
if [ $isDebug -eq 0 ]; then
rm -rf $tmpdir
else
echo "Temporary files are kept at $tmpdir"
fi