forked from bibbox/app-openspecimen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddproxy.sh
More file actions
executable file
·105 lines (92 loc) · 2.55 KB
/
addproxy.sh
File metadata and controls
executable file
·105 lines (92 loc) · 2.55 KB
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
#!/bin/bash
# addproxy script
# BIBBOX shell script
# http://bibbox.org
#
# This script will create an proxy entry for a Apache2 debian ionstallation
PROGNAME=$(basename $0)
usage()
{
echo "Usage: addproxy [OPTIONS]"
echo " addproxy [ --help | -v | --version ]"
echo ""
echo "Creates Proxy entry for tool"
echo ""
echo "OPTIONS:"
echo " -t, --instance Unique name of the tool"
echo ""
echo "Example:"
echo " sudo ./addproxy.sh -t test -s subtest -p 7867 -i 127.0.0.1"
}
version()
{
echo "Version: 1.0"
echo "BIBBOX Version: 1.0"
echo "Build: 2016-07-06"
}
clean_up() {
exit $1
}
error_exit()
{
echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
clean_up 1
}
createProxyfile()
{
if [ -e /etc/apache2/sites-available ]; then
echo "Create proxy file /etc/apache2/sites-available/005-$instance.conf"
else
error_exit "$LINENO: Directory sites-available from apache2 not available! Aborting."
fi
cat > /etc/apache2/sites-available/005-$instance.conf <<EOF
<VirtualHost *:80>
ServerName $subdomain.$url
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://$ip:$port/
ProxyPassReverse / http://$ip:$port/
</VirtualHost>
EOF
}
linkfile()
{
ln -s /etc/apache2/sites-available/005-$instance.conf /etc/apache2/sites-enabled/005-$instance.conf
}
ip=127.0.0.1
url=demo.bibbox.org
while [ "$1" != "" ]; do
case $1 in
-i | --instance ) shift
instance=$1
;;
-s | --subdomain ) shift
subdomain=$1
;;
-p | --port ) shift
port=$1
;;
-i | --ip ) shift
ip=$1
;;
-u | --url ) shift
url=$1
;;
-h | --help ) usage
clean_up
;;
-v | --version | version ) version
clean_up
;;
* ) usage
error_exit "Parameters not matching"
esac
shift
done
createProxyfile
linkfile
clean_up