Skip to content

Commit 1b75699

Browse files
Fixed install script to work on RHEL/CentOS
1 parent 0468296 commit 1b75699

File tree

5 files changed

+64
-19
lines changed

5 files changed

+64
-19
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vagrant

Vagrantfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Vagrant.configure("2") do |config|
2+
3+
# ------------------------------------------------
4+
# NOTE: Comment out OSes you don't want to create
5+
# ------------------------------------------------
6+
7+
config.vm.define "ubuntu20" do |server|
8+
server.vm.box = "ubuntu/focal64"
9+
server.vm.hostname = "ubuntu20"
10+
server.vm.network "private_network", ip: "192.168.56.30"
11+
end
12+
13+
config.vm.define "centos8" do |server|
14+
server.vm.box = "centos/8"
15+
server.vm.hostname = "centos8"
16+
server.vm.network "private_network", ip: "192.168.56.39"
17+
end
18+
end

example/haproxy/haproxy.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ global
88
lua-load /usr/local/share/lua/5.3/jwtverify.lua
99

1010
# Replace the Auth0 URL with your own:
11-
setenv OAUTH_ISSUER https://nickram44.auth0.com/
11+
setenv OAUTH_ISSUER https://youraccount.auth0.com/
1212
setenv OAUTH_AUDIENCE https://api.mywebsite.com
1313
setenv OAUTH_PUBKEY_PATH /etc/haproxy/pem/pubkey.pem
1414

install.sh

+40-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
SOURCE_DIR=/usr/src
33
LUA_VERSION=5.3.5
4+
CWD=$(pwd)
45

56
install_luaoauth_var=false
67
rhel_based=false
@@ -57,7 +58,7 @@ install_deb_lua() {
5758
apt-get install -y software-properties-common unzip build-essential libssl-dev lua5.3 liblua5.3-dev >/dev/null 2>&1
5859
}
5960

60-
install_luaoauth_deps() {
61+
install_luaoauth_deps_debian() {
6162
printf "\r[+] Installing haproxy-lua-oauth dependencies\n"
6263

6364
if [ ! -e $lua_dep_dir ]; then
@@ -71,7 +72,7 @@ install_luaoauth_deps() {
7172

7273
curl -sLO https://github.com/rxi/json.lua/archive/refs/heads/master.zip
7374
unzip -qo master.zip && rm master.zip
74-
mv json.lua-master/json.lua $lua_dep_dir
75+
cp json.lua-master/json.lua $lua_dep_dir
7576

7677
curl -sLO https://github.com/lunarmodules/luasocket/archive/refs/heads/master.zip
7778
unzip -qo master.zip && rm master.zip
@@ -86,15 +87,43 @@ install_luaoauth_deps() {
8687
cd ..
8788
}
8889

89-
install_luaoauth() {
90-
printf "\r[+] Installing haproxy-lua-oauth\n"
90+
install_luaoauth_deps_rhel() {
91+
printf "\r[+] Installing haproxy-lua-oauth dependencies\n"
92+
9193
if [ ! -e $lua_dep_dir ]; then
9294
mkdir -p $lua_dep_dir;
9395
fi;
9496

97+
dnf config-manager --set-enabled powertools
98+
dnf update >/dev/null 2>&1
99+
dnf install -y gcc openssl-devel lua-devel make readline-devel systemd-devel unzip >/dev/null 2>&1
100+
95101
cd $SOURCE_DIR
96102

97-
mv ./lib/*.lua $lua_dep_dir
103+
curl -sLO https://github.com/rxi/json.lua/archive/refs/heads/master.zip
104+
unzip -qo master.zip && rm master.zip
105+
mv json.lua-master/json.lua $lua_dep_dir
106+
107+
curl -sLO https://github.com/lunarmodules/luasocket/archive/refs/heads/master.zip
108+
unzip -qo master.zip && rm master.zip
109+
cd luasocket-master/
110+
make clean all install-both LUAINC=/usr/include/ >/dev/null
111+
cd ..
112+
113+
curl -sLO https://github.com/wahern/luaossl/archive/rel-20181207.zip
114+
unzip -qo rel-20181207.zip && rm rel-20181207.zip
115+
cd luaossl-rel-20181207/
116+
make install >/dev/null
117+
cd ..
118+
}
119+
120+
install_luaoauth() {
121+
printf "\r[+] Installing haproxy-lua-oauth\n"
122+
if [ ! -e $lua_dep_dir ]; then
123+
mkdir -p $lua_dep_dir;
124+
fi;
125+
126+
cp $CWD/lib/*.lua $lua_dep_dir
98127
}
99128

100129
case $1 in
@@ -106,19 +135,12 @@ case $1 in
106135
esac
107136

108137
if $install_luaoauth_var; then
109-
# Install Lua JWT
110-
# if ! $lua_installed; then
111-
# if $rhel_based; then
112-
# download_and_install_lua=(install_yum_deps download_rhel_lua build_lua install_rhel_lua)
113-
# elif $debian_based; then
114-
# download_and_install_lua=(install_deb_lua)
115-
# fi
116-
# for func in ${download_and_install_lua[*]}; do
117-
# $func &
118-
# display_working $!
119-
# done
120-
# fi
121-
download_and_install_luaoauth=(install_luaoauth_deps install_luaoauth)
138+
if $rhel_based; then
139+
download_and_install_luaoauth=(install_luaoauth_deps_rhel install_luaoauth)
140+
elif $debian_based; then
141+
download_and_install_luaoauth=(install_luaoauth_deps_debian install_luaoauth)
142+
fi
143+
122144
for func in ${download_and_install_luaoauth[*]}; do
123145
$func &
124146
display_working $!

lib/jwtverify.lua

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ if not config then
3131
}
3232
end
3333

34+
-- search these paths for *.lua and *.so files on CentOS/RHEL
35+
package.path = package.path .. ';/usr/local/share/lua/5.3/?.lua'
36+
package.cpath = package.cpath .. ';/usr/local/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/?/?.so'
37+
3438
local json = require 'json'
3539
local base64 = require 'base64'
3640
local openssl = {

0 commit comments

Comments
 (0)