This repository has been archived by the owner on Dec 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompilemodule.sh
116 lines (93 loc) · 3.25 KB
/
compilemodule.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
set -e
nginx_location=./nginx
modules_sources_location=./modules-src
nginx_binary_modules_location=/etc/nginx/modules
## End of modifieable UwU
echo "-------------------------------------------------------------"
echo " Nginx Module Compiler V2"
echo " by @FoxieFlakey for Foxtanium"
echo " Published and edited by @Fjox at"
echo " https://github.com/Foxtanium/NGinxModuleCompiler"
echo "-------------------------------------------------------------"
echo ""
echo "We expect you to already have NGinx installed otherwisethe script doesnt work"
echo ""
neofetch
echo ""
echo "Installing dependencies if needed."
sudo apt install libpcre2-dev libpcre3-dev gcc git make -y
nginx_binary_modules_location=$(realpath "$nginx_binary_modules_location")
nginx_location=$(realpath "$nginx_location")
modules_location=$(realpath "$modules_sources_location")
mkdir -p "$modules_location"
nginx_version=$(nginx -v 2>&1 | grep -Eo "nginx/(([0-9]|\.)+)+" | grep -Eo "[^/]+$")
echo "Nginx $nginx_version detected"
updateNginx=
if [ ! -d "$nginx_location" ]; then
updateNginx="yes"
echo "Nginx source not present at $nginx_location: Downloading"
fi
if [ x$(cat "$nginx_location/.nginx_version_uwu") != "x$nginx_version" ]; then
updateNginx="yes"
echo "Nginx source out of date at $nginx_location: Downloading"
rm -rf "$nginx_location"
fi
if [ "x$updateNginx" == "xyes" ]; then
# Get new nginx
url="http://nginx.org/download/nginx-$nginx_version.tar.gz"
echo "Getting Nginx at $url"
mkdir -p "$nginx_location"
wget "$url" -O - | tar zx --directory "$nginx_location"
innerDirectory="$nginx_location/nginx-$nginx_version"
(find "$innerDirectory" -mindepth 1 -maxdepth 1; echo "$nginx_location") | xargs mv
rm -r "$innerDirectory"
echo $nginx_version > $nginx_location/.nginx_version_uwu
fi
echo "Paste github links here, then press Ctrl+D when done."
location=0
args=""
commands=""
while IFS=$'\n' read -r line; do
path=$(realpath "$modules_location/$location")
location=$(($location + 1))
args="$args --add-dynamic-module=$path"
rm -rf "$path"
commands="$commands git clone --recursive --depth=1 \"$line\" \"$path\"; "
done
if [ -z "$commands" ]; then
echo "No github links pasted exiting UwU"
exit 0
fi
bash -c "$commands"
# Get Dependancies
echo "Downloading Dependancies"
cd "$nginx_location/"
cd ../
git clone git://git.openssl.org/openssl.git
wget https://www.zlib.net/zlib-1.3.1.tar.gz
tar -xzvf zlib-1.3.1.tar.gz
mv zlib-1.3.1 zlib
# Do configure
cd "$nginx_location/"
cmd="./configure --with-compat --with-openssl=../openssl --with-zlib=../zlib $args"
$cmd
# Do make
rm -f "objs/*.so"
make -j$(nproc) modules
echo "----------------------"
echo "[Script] Copying files"
echo "----------------------"
mkdir -p "$nginx_binary_modules_location"
cd objs
addition=""
for FILE in $(find . -maxdepth 1 -regex ".+.so"); do
echo "[Script] Copying $FILE to $nginx_binary_modules_location/$FILE UwU"
addition="${addition}load_module $nginx_binary_modules_location/$FILE;\n"
sudo cp "$FILE" "$nginx_binary_modules_location/$FILE"
done
cd ..
# Copy files
echo "-------------[[Copy this to /etc/nginx/nginx.conf]]-------------"
echo -ne "$addition"
echo "----------------------------------------------------------------"