forked from luapower/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathngx
executable file
·37 lines (29 loc) · 1.41 KB
/
ngx
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
#!/bin/bash
# nginx wrapper for the luapower.com website.
# all it does is setting all the needed paths before starting nginx.
die() { echo "$@" >&2; exit 1; }
# everything is done relative to this script's parent dir.
cd "$(dirname "$0")" || die "Could not cd to \"$(dirname "$0")\"."
OPENRESTY_DIR="$PWD/openresty"; [ -d "$OPENRESTY_DIR" ] || die "Directory \"$OPENRESTY_DIR\" not found."
LUAPOWER_DIR="$PWD/luapower"; [ -d "$LUAPOWER_DIR" ] || die "Directory \"$LUAPOWER_DIR\" not found."
WWW_DIR="$PWD/www"; [ -d "$WWW_DIR" ] || die "Directory \"$WWW_DIR\" not found."
NGINX_CONF="$PWD/nginx/conf/nginx.conf"; [ -f "$NGINX_CONF" ] || die "File \"$NGINX_CONF\" not found."
which pandoc >/dev/null || echo "WARNING: Pandoc not installed. Documentation will not be visible."
# detect platform. Linux and OSX are supported.
[ "$(uname -m)" != x86_64 ] && P=32 || P=64
[ "${OSTYPE#darwin}" != "$OSTYPE" ] && P=osx$P || P=linux$P
# configure Lua and ldd paths
WWWL="$WWW_DIR/?.lua"
LPB="$LUAPOWER_DIR/bin/$P"
LPBL="$LPB/lua/?.lua"
LPBB="$LPB/clib/?.so"
LPL="$LUAPOWER_DIR/?.lua"
ORL="$OPENRESTY_DIR/lualib/?.lua"
ORB="$OPENRESTY_DIR/lualib/?.so"
export LUA_PATH="$WWWL;$LPBL;$LPL;$ORL"
export LUA_CPATH="$LPBB;$ORB"
export WWW_DIR="$WWW_DIR"
export LUAPOWER_DIR="$LUAPOWER_DIR"
export LD_LIBRARY_PATH="$LPB"
# finally, run nginx
exec "$OPENRESTY_DIR/nginx/sbin/nginx" -p "$PWD/nginx" -c "$PWD/nginx/conf/nginx.conf" "$@"