-
Notifications
You must be signed in to change notification settings - Fork 8
/
nginx
executable file
·45 lines (32 loc) · 1.12 KB
/
nginx
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
#!/bin/bash
FILE_NGINX_CONFIG=${FILE_NGINX_CONFIG:-/etc/nginx/sites-available/pixieboot.conf}
FILE_NGINX_CONFIGLINK=${FILE_NGINX_CONFIGLINK:-/etc/nginx/sites-enabled/pixieboot.conf}
CMD_RELOAD_NGINX=${CMD_RELOAD_NGINX:-"nginx -s reload"}
function die(){ warn $*; exit 1; }
function warn(){ echo $* >&2; }
checksum(){
sha1sum $* 2>/dev/null
}
checksum_old=$(checksum $FILE_NGINX_CONFIGLINK)
cat > $FILE_NGINX_CONFIG <<-END
server {
listen $NFSHOST:80 default;
root $NFSPREFIX;
access_log /var/log/nginx/pixieboot-access.log;
error_log /var/log/nginx/pixieboot-error.log;
index index.html index.htm index.php;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location ~ /\.ht {
deny all;
}
}
END
#[ -L $FILE_NGINX_CONFIGLINK ] && rm $FILE_NGINX_CONFIGLINK
ln -sT $FILE_NGINX_CONFIG $FILE_NGINX_CONFIGLINK
checksum_new=$(checksum $FILE_NGINX_CONFIGLINK)
if [[ "$checksum_old" != "$checksum_new" ]]; then
echo "nginx's configuration changed. Reloading."
${CMD_RELOAD_NGINX} || warn "Reloading nginx configuration failed."
fi