-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx
executable file
·99 lines (80 loc) · 2.18 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
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
#!/usr/bin/env bash
SYSTEM_DIR="/usr/local"
INSTALL_DIR="/opt/local"
VERSION=$2
APP_NAME="nginx"
URL="http://nginx.org/download/nginx-$VERSION.tar.gz"
PREFIX="$INSTALL_DIR/$APP_NAME/$VERSION"
CURRENT="$INSTALL_DIR/$APP_NAME/current"
TGZ="$INSTALL_DIR/src/$(basename $URL)"
COMMAND=$1
if [ $UID != 0 ]; then
echo "Sorry, you are not root."
exit 1
elif [[ -z "$COMMAND" ]]; then
${0} help
exit 1
elif [[ -z "$VERSION" && "$COMMAND" != "help" && "$COMMAND" != "deactivate" ]]; then
${0} help
fi
case "$COMMAND" in
install)
mkdir -p /opt/local/src
cd /opt/local/src
apt-get install libpcre3-dev libssl-dev
[ ! -f "$TGZ" ] && wget $URL
tar xvf $TGZ
cd nginx-$VERSION
./configure --prefix=$PREFIX \
--with-http_ssl_module --with-http_realip_module \
--with-http_gzip_static_module --conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-ipv6
mkdir -p /var/lib/nginx
mkdir -p /var/lib/nginx/body
mkdir -p /var/lib/nginx/fastcgi
mkdir -p /var/lib/nginx/proxy
make
make install
;;
activate)
if [[ ! -d $PREFIX ]]; then
${0} install $VERSION
fi
${0} deactivate
ln -s "$PREFIX" "$CURRENT"
for dir in bin sbin
do
[ ! -d "$CURRENT/$dir" ] && continue
mkdir -p "$SYSTEM_DIR/$dir"
for file in `ls $CURRENT/$dir`
do
bin=$(basename $file)
ln -s "$CURRENT/$dir/$bin" "$SYSTEM_DIR/$dir/$bin"
done
done
;;
deactivate)
if [[ ! -L "$CURRENT" ]]; then
exit
fi
for dir in bin sbin
do
[ ! -d "$CURRENT/$dir" ] && continue
for file in `ls $CURRENT/$dir`
do
bin=$(basename $file)
[ -L "$SYSTEM_DIR/$dir/$bin" ] && rm "$SYSTEM_DIR/$dir/$bin"
done
done
rm "$CURRENT"
;;
*)
echo "Usage: ${0} {install|uninstall|activate|deactivate|help} {version}" >&2
exit 3
;;
esac
: