Skip to content

Commit bca4215

Browse files
committed
Initial support for Alpine linux
1 parent 8268e4b commit bca4215

File tree

1 file changed

+70
-15
lines changed

1 file changed

+70
-15
lines changed

install.sh

+70-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
SOURCE_DIR=/usr/src
33
LUA_VERSION=5.4.4
44
CWD=$(pwd)
55

6-
install_luaoauth_var=false
7-
rhel_based=false
8-
debian_based=false
9-
lua_installed=false
6+
install_luaoauth_var="false"
7+
rhel_based="false"
8+
debian_based="false"
9+
alpine_based="false"
10+
lua_installed="false"
1011
lua_dep_dir=/usr/local/share/lua/5.4/
1112

1213
if [ -f /etc/redhat-release ]; then
13-
rhel_based=true
14+
echo "Red Hat based system detected"
15+
rhel_based="true"
1416
elif [ -f /etc/debian_version ]; then
15-
debian_based=true
17+
echo "Debian based system detected"
18+
debian_based="true"
19+
elif [ -f /etc/alpine-release ]; then
20+
echo "Alpine based system detected"
21+
alpine_based="true"
1622
fi
1723

24+
if [ ! -e $SOURCE_DIR ]; then
25+
mkdir -p $SOURCE_DIR;
26+
fi;
27+
1828
cd $SOURCE_DIR
1929

2030
display_working() {
2131
pid=$1
2232
spin='-\|/'
2333
i=0
24-
while kill -0 $pid 2>/dev/null
34+
while kill -0 "$pid" 2>/dev/null
2535
do
2636
i=$(( (i+1) %4 ))
2737
printf "\r${spin:$i:1}"
@@ -63,9 +73,44 @@ install_deb_lua() {
6373
apt-get install -y software-properties-common unzip build-essential libssl-dev lua5.4 liblua5.4-dev >/dev/null 2>&1
6474
}
6575

76+
install_alpine_lua() {
77+
printf "\r[+] Installing Lua\n"
78+
apk add --no-cache lua5.4 lua5.4-dev openssl-dev gcc libc-dev git make automake libtool curl unzip >/dev/null 2>&1
79+
#?? build-base libc-dev liblua5.4-dev unzip
80+
}
81+
6682
# ----------------------------
6783
# ----------------------------
6884

85+
install_luaoauth_deps_alpine() {
86+
printf "\r[+] Installing haproxy-lua-oauth dependencies\n"
87+
88+
if [ ! -e $lua_dep_dir ]; then
89+
mkdir -p $lua_dep_dir;
90+
fi;
91+
92+
apt-get update >/dev/null 2>&1
93+
apk add --no-cache lua5.4 lua5.4-dev openssl-dev gcc libc-dev git make automake libtool curl unzip >/dev/null 2>&1
94+
95+
cd $SOURCE_DIR
96+
97+
curl -sLO https://github.com/rxi/json.lua/archive/refs/heads/master.zip
98+
unzip -qo master.zip && rm master.zip
99+
mv json.lua-master/json.lua $lua_dep_dir
100+
101+
curl -sLO https://github.com/lunarmodules/luasocket/archive/refs/heads/master.zip
102+
unzip -qo master.zip && rm master.zip
103+
cd luasocket-master/
104+
make clean all install-both LUAINC=/usr/include/lua5.4/ >/dev/null
105+
cd ..
106+
107+
curl -sLO https://github.com/wahern/luaossl/archive/refs/heads/master.zip
108+
unzip -qo master.zip && rm master.zip
109+
cd luaossl-master/
110+
make install >/dev/null
111+
cd ..
112+
}
113+
69114
install_luaoauth_deps_debian() {
70115
printf "\r[+] Installing haproxy-lua-oauth dependencies\n"
71116

@@ -133,26 +178,36 @@ install_luaoauth() {
133178
mkdir -p $lua_dep_dir;
134179
fi;
135180

136-
cp $CWD/lib/*.lua $lua_dep_dir
181+
cp "$CWD"/lib/*.lua $lua_dep_dir
137182
}
138183

139184
case $1 in
140185
luaoauth)
141-
install_luaoauth_var=true
186+
install_luaoauth_var="true"
142187
;;
143188
*)
144189
echo "Usage: install.sh luaoauth"
190+
exit 1
191+
;;
145192
esac
146193

194+
echo "$rhel_based"
195+
147196
if $install_luaoauth_var; then
148197
if $rhel_based; then
149-
download_and_install_luaoauth=(install_luaoauth_deps_rhel install_luaoauth)
198+
echo "RHEL based system detected"
199+
download_and_install_luaoauth="install_luaoauth_deps_rhel install_luaoauth"
150200
elif $debian_based; then
151-
download_and_install_luaoauth=(install_luaoauth_deps_debian install_luaoauth)
201+
echo "Debian based system detected"
202+
download_and_install_luaoauth="install_luaoauth_deps_debian install_luaoauth"
203+
elif $alpine_based; then
204+
echo "Alpine based system detected"
205+
download_and_install_luaoauth="install_luaoauth_deps_alpine install_luaoauth"
152206
fi
153207

154-
for func in ${download_and_install_luaoauth[*]}; do
155-
$func &
156-
display_working $!
208+
for func in $download_and_install_luaoauth; do
209+
"$func" &
210+
display_working "$!"
157211
done
158212
fi
213+

0 commit comments

Comments
 (0)