-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_2.sh
101 lines (81 loc) · 2.28 KB
/
script_2.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
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root or use sudo"
exit 1
fi
if [ "$#" -ne 1 ]
then
echo "You need to pass the logged in username."
exit 1
fi
echo "Removing default nginx configuration."
rm -rf /etc/nginx/sites-enabled/default
rm -rf /etc/nginx/sites-available/default
echo "Removal done."
echo "Configuring NGINX with $1 user..."
echo 'upstream kolibri {
server 127.0.0.1:8080;
}
server {
listen 8008;
location /static {
alias /home/'$1'/.kolibri/static;
}
location /content {
alias /home/'$1'/.kolibri/content/;
}
location /favicon.ico {
empty_gif;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://kolibri;
error_page 502 = @502;
}
location @502 {
types { }
default_type "text/html";
return 502 "
<BR>
<H1>Kolibri might be busy - wait a few moments and then reload this page
<BR><BR>
<H2>If kolibri is still busy, get help from the system administrator
<H3>Error code: nginx 502 Bad Gateway (maybe the kolibri webserver is not working correctly)";
}
}' > /etc/nginx/sites-enabled/default
echo 'upstream kolibri {
server 127.0.0.1:8080;
}
server {
listen 8008;
location /static {
alias /home/'$1'/.kolibri/static/;
}
location /content {
alias /home/'$1'/.kolibri/content/;
}
location /favicon.ico {
empty_gif;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://kolibri;
error_page 502 = @502;
}
location @502 {
types { }
default_type "text/html";
return 502 "
<BR>
<H1>kolibri might be busy - wait a few moments and then reload this page
<BR><BR>
<H2>If kolibri is still busy, get help from the system administrator
<H3>Error code: nginx 502 Bad Gateway (maybe the kolibri webserver is not working correctly)";
}
}' > /etc/nginx/sites-available/default
echo "Nginx is configured with $1 user..."
service nginx start