feat(apisix): add Cloudron package
- Implements Apache APISIX packaging for Cloudron platform. - Includes Dockerfile, CloudronManifest.json, and start.sh. - Configured to use Cloudron's etcd addon. 🤖 Generated with Gemini CLI Co-Authored-By: Gemini <noreply@google.com>
This commit is contained in:
72
CloudronPackages/APISIX/apisix-source/utils/check-category.py
Executable file
72
CloudronPackages/APISIX/apisix-source/utils/check-category.py
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from os import path
|
||||
|
||||
EXT = ".md"
|
||||
|
||||
try:
|
||||
unicode # Python 2
|
||||
except NameError:
|
||||
unicode = str # Python 3
|
||||
|
||||
def collect_fn(entries, topic):
|
||||
if "id" in topic:
|
||||
fn = topic["id"]
|
||||
entries.append(fn)
|
||||
elif "items" in topic:
|
||||
for item in topic["items"]:
|
||||
if isinstance(item, unicode):
|
||||
entries.append(item)
|
||||
else:
|
||||
collect_fn(entries, item)
|
||||
|
||||
def check_category(root):
|
||||
index = root + "config.json"
|
||||
with open(index) as f:
|
||||
entries = []
|
||||
|
||||
data = json.load(f)
|
||||
for topic in data["sidebar"]:
|
||||
collect_fn(entries, topic)
|
||||
for e in entries:
|
||||
fn = root + e + EXT
|
||||
if not path.exists(fn):
|
||||
print("Entry %s in the sidebar can't be found. Please remove it from %s."
|
||||
% (fn, index))
|
||||
return False
|
||||
|
||||
ignore_list = ["examples/plugins-hmac-auth-generate-signature", "config", "README"]
|
||||
entries.extend(ignore_list)
|
||||
existed_files = []
|
||||
for parent, dirs, files in os.walk(root):
|
||||
for fn in files:
|
||||
existed_files.append(path.join(parent[len(root):], path.splitext(fn)[0]))
|
||||
for fn in existed_files:
|
||||
if fn not in entries:
|
||||
print("File %s%s%s is not indexed. Please add it to %s." % (root, fn, EXT, index))
|
||||
return False
|
||||
return True
|
||||
|
||||
roots = ["docs/en/latest/", "docs/zh/latest/"]
|
||||
for r in roots:
|
||||
if not check_category(r):
|
||||
sys.exit(-1)
|
32
CloudronPackages/APISIX/apisix-source/utils/check-lua-code-style.sh
Executable file
32
CloudronPackages/APISIX/apisix-source/utils/check-lua-code-style.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
set -ex
|
||||
|
||||
luacheck -q apisix t/lib
|
||||
|
||||
find apisix -name '*.lua' ! -wholename 'apisix/cli/ngx_tpl.lua' ! -wholename 'apisix/cli/config.lua' -exec ./utils/lj-releng {} + > \
|
||||
/tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)
|
||||
|
||||
grep -E "ERROR.*.lua:" /tmp/check.log > /tmp/error.log || true
|
||||
if [ -s /tmp/error.log ]; then
|
||||
echo "=====bad style====="
|
||||
cat /tmp/check.log
|
||||
exit 1
|
||||
fi
|
24
CloudronPackages/APISIX/apisix-source/utils/check-merge-conflict.sh
Executable file
24
CloudronPackages/APISIX/apisix-source/utils/check-merge-conflict.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
grep "^<<<<<<< HEAD" $(git grep --cached -l '' | xargs) && exit 1
|
||||
grep "^>>>>>>> master" $(git grep --cached -l '' | xargs) && exit 1
|
||||
exit 0
|
73
CloudronPackages/APISIX/apisix-source/utils/check-plugins-code.sh
Executable file
73
CloudronPackages/APISIX/apisix-source/utils/check-plugins-code.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
RED="\033[1;31m";
|
||||
NC="\033[0m"; # No Color
|
||||
hit=0
|
||||
|
||||
checkfunc () {
|
||||
funccontent=$1
|
||||
file=$2
|
||||
[[ $funccontent =~ "core.response.exit" ]] && echo -e ${RED}${file}${NC} && echo " can't exit in rewrite or access phase!" && ((hit++))
|
||||
[[ $funccontent =~ "ngx.exit" ]] && echo -e ${RED}${file}${NC} && echo " can't exit in rewrite or access phase!" && ((hit++))
|
||||
[[ $funccontent =~ "ngx.redirect" ]] && echo -e ${RED}${file}${NC} && echo " can't call ngx.redirect in rewrite or access phase!" && ((hit++))
|
||||
}
|
||||
|
||||
|
||||
filtercode () {
|
||||
content=$1
|
||||
file=$2
|
||||
|
||||
rcontent=${content##*_M.rewrite}
|
||||
rewritefunc=${rcontent%%function*}
|
||||
checkfunc "$rewritefunc" "$file"
|
||||
|
||||
rcontent=${content##*_M.access}
|
||||
accessfunc=${rcontent%%function*}
|
||||
checkfunc "$accessfunc" "$file"
|
||||
}
|
||||
|
||||
|
||||
for file in apisix/plugins/*.lua
|
||||
do
|
||||
if test -f $file
|
||||
then
|
||||
content=$(cat $file)
|
||||
filtercode "$content" "$file"
|
||||
fi
|
||||
done
|
||||
for file in apisix/stream/plugins/*.lua
|
||||
do
|
||||
if test -f $file
|
||||
then
|
||||
content=$(cat $file)
|
||||
filtercode "$content" "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
if (($hit>0))
|
||||
then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# test case for check
|
||||
content=$(cat t/fake-plugin-exit.lua)
|
||||
filtercode "$content" > test.log 2>&1 || (cat test.log && exit 1)
|
||||
|
||||
echo "All passed."
|
38
CloudronPackages/APISIX/apisix-source/utils/check-test-code-style.sh
Executable file
38
CloudronPackages/APISIX/apisix-source/utils/check-test-code-style.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
set -x -euo pipefail
|
||||
|
||||
find t -name '*.t' -exec grep -E "\-\-\-\s+(SKIP|ONLY|LAST|FIRST)$" {} + > /tmp/error.log || true
|
||||
if [ -s /tmp/error.log ]; then
|
||||
echo "Forbidden directives to found. Bypass test cases without reason are not allowed."
|
||||
cat /tmp/error.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find t -name '*.t' -exec ./utils/reindex {} + > \
|
||||
/tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)
|
||||
|
||||
grep "done." /tmp/check.log > /tmp/error.log || true
|
||||
if [ -s /tmp/error.log ]; then
|
||||
echo "=====bad style====="
|
||||
cat /tmp/error.log
|
||||
echo "you need to run 'reindex' to fix them. Read CONTRIBUTING.md for more details."
|
||||
exit 1
|
||||
fi
|
82
CloudronPackages/APISIX/apisix-source/utils/check-version.sh
Executable file
82
CloudronPackages/APISIX/apisix-source/utils/check-version.sh
Executable file
@@ -0,0 +1,82 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
ver=$1
|
||||
|
||||
red='\e[0;41m'
|
||||
RED='\e[1;31m'
|
||||
green='\e[0;32m'
|
||||
GREEN='\e[1;32m'
|
||||
NC='\e[0m'
|
||||
|
||||
# doc: apisix $ver
|
||||
matched=`grep "apisix.[0-9][0-9.]*" -r doc/`
|
||||
expected=`grep "apisix.$ver" -r doc/`
|
||||
|
||||
if [ "$matched" = "$expected" ]; then
|
||||
echo -e "${green}passed: (doc) apisix $ver ${NC}"
|
||||
else
|
||||
echo -e "${RED}failed: (doc) apisix $ver ${NC}" 1>&2
|
||||
echo
|
||||
echo "-----maybe wrong version-----"
|
||||
echo "$matched"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# doc: version $ver
|
||||
matched=`grep "version [0-9][0-9.]*" -r doc/`
|
||||
expected=`grep -F "version $ver" -r doc/`
|
||||
|
||||
if [ "$matched" = "$expected" ]; then
|
||||
echo -e "${green}passed: (doc) version $ver ${NC}"
|
||||
else
|
||||
echo -e "${RED}failed: (doc) version $ver ${NC}" 1>&2
|
||||
echo
|
||||
echo "-----maybe wrong version-----"
|
||||
echo "$matched"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# lua: VERSION = $ver
|
||||
matched=`grep "VERSION = \"[0-9][0-9.]*\"" -r apisix/`
|
||||
expected=`grep -F "VERSION = \"$ver\"" -r apisix/`
|
||||
|
||||
if [ "$matched" = "$expected" ]; then
|
||||
echo -e "${green}passed: (lua) VERSION = $ver ${NC}"
|
||||
else
|
||||
echo -e "${RED}failed: (lua) VERSION = \"$ver\" ${NC}" 1>&2
|
||||
echo
|
||||
echo "-----maybe wrong version-----"
|
||||
echo "$matched"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# rockspec
|
||||
matched=`ls -l | grep "$ver" `
|
||||
|
||||
if [ -z "$matched" ]; then
|
||||
echo -e "${RED}failed: (rockspec) VERSION = $ver \"$ver\" ${NC}" 1>&2
|
||||
echo
|
||||
echo "-----please check rockspec file for VERSION \"$ver\"-----"
|
||||
echo "$matched"
|
||||
exit 1
|
||||
else
|
||||
echo -e "${green}passed: (rockspec) VERSION = $ver ${NC}"
|
||||
fi
|
62
CloudronPackages/APISIX/apisix-source/utils/fix-zh-doc-segment.py
Executable file
62
CloudronPackages/APISIX/apisix-source/utils/fix-zh-doc-segment.py
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
import os
|
||||
from os import path
|
||||
from zhon.hanzi import punctuation # sudo pip3 install zhon
|
||||
|
||||
|
||||
def need_fold(pre, cur):
|
||||
pre = pre.rstrip("\r\n")
|
||||
if len(pre) == 0 or len(cur) == 0:
|
||||
return False
|
||||
if ord(pre[-1]) < 128 or ord(cur[0]) < 128:
|
||||
return False
|
||||
# the prev line ends with Chinese and the curr line starts with Chinese
|
||||
if pre.startswith(":::note"):
|
||||
# ignore special mark
|
||||
return False
|
||||
if pre[-1] in punctuation:
|
||||
# skip punctuation
|
||||
return False
|
||||
return True
|
||||
|
||||
def check_segment(root):
|
||||
for parent, dirs, files in os.walk(root):
|
||||
for fn in files:
|
||||
fn = path.join(parent, fn)
|
||||
with open(fn) as f:
|
||||
lines = f.readlines()
|
||||
new_lines = [lines[0]]
|
||||
skip = False
|
||||
for i in range(1, len(lines)):
|
||||
if lines[i-1].startswith('```'):
|
||||
skip = not skip
|
||||
if not skip and need_fold(lines[i-1], lines[i]):
|
||||
new_lines[-1] = new_lines[-1].rstrip("\r\n") + lines[i]
|
||||
else:
|
||||
new_lines.append(lines[i])
|
||||
if len(new_lines) != len(lines):
|
||||
print("find broken newline in file: %s" % fn)
|
||||
with open(fn, "w") as f:
|
||||
f.writelines(new_lines)
|
||||
|
||||
|
||||
roots = ["docs/zh/latest/"]
|
||||
for r in roots:
|
||||
check_segment(r)
|
93
CloudronPackages/APISIX/apisix-source/utils/gen-vote-contents.sh
Executable file
93
CloudronPackages/APISIX/apisix-source/utils/gen-vote-contents.sh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
VERSION=$1
|
||||
|
||||
SUBSTRING1=$(echo $VERSION| cut -d'.' -f 1)
|
||||
SUBSTRING2=$(echo $VERSION| cut -d'.' -f 2)
|
||||
BLOB_VERSION=$SUBSTRING1.$SUBSTRING2
|
||||
CHANGELOG_HASH=$(printf $VERSION | sed 's/\.//g')
|
||||
|
||||
RELEASE_NOTE_PR="https://github.com/apache/apisix/blob/release/$BLOB_VERSION/CHANGELOG.md#$CHANGELOG_HASH"
|
||||
COMMIT_ID=$(git rev-parse --short HEAD)
|
||||
|
||||
vote_contents=$(cat <<EOF
|
||||
Hello, Community,
|
||||
|
||||
This is a call for the vote to release Apache APISIX version
|
||||
|
||||
Release notes:
|
||||
|
||||
$RELEASE_NOTE_PR
|
||||
|
||||
The release candidates:
|
||||
|
||||
https://dist.apache.org/repos/dist/dev/apisix/$VERSION/
|
||||
|
||||
Release Commit ID:
|
||||
|
||||
https://github.com/apache/apisix/commit/$COMMIT_ID
|
||||
|
||||
Keys to verify the Release Candidate:
|
||||
|
||||
https://dist.apache.org/repos/dist/dev/apisix/KEYS
|
||||
|
||||
Steps to validating the release:
|
||||
|
||||
1. Download the release
|
||||
|
||||
wget https://dist.apache.org/repos/dist/dev/apisix/$VERSION/apache-apisix-$VERSION-src.tgz
|
||||
|
||||
2. Checksums and signatures
|
||||
|
||||
wget https://dist.apache.org/repos/dist/dev/apisix/KEYS
|
||||
|
||||
wget https://dist.apache.org/repos/dist/dev/apisix/$VERSION/apache-apisix-$VERSION-src.tgz.asc
|
||||
|
||||
wget https://dist.apache.org/repos/dist/dev/apisix/$VERSION/apache-apisix-$VERSION-src.tgz.sha512
|
||||
|
||||
gpg --import KEYS
|
||||
|
||||
shasum -c apache-apisix-$VERSION-src.tgz.sha512
|
||||
|
||||
gpg --verify apache-apisix-$VERSION-src.tgz.asc apache-apisix-$VERSION-src.tgz
|
||||
|
||||
3. Unzip and Check files
|
||||
|
||||
tar zxvf apache-apisix-$VERSION-src.tgz
|
||||
|
||||
4. Build Apache APISIX:
|
||||
|
||||
https://github.com/apache/apisix/blob/release/$BLOB_VERSION/docs/en/latest/building-apisix.md#building-apisix-from-source
|
||||
|
||||
The vote will be open for at least 72 hours or until necessary number of
|
||||
votes are reached.
|
||||
|
||||
Please vote accordingly:
|
||||
|
||||
[ ] +1 approve
|
||||
[ ] +0 no opinion
|
||||
[ ] -1 disapprove with the reason
|
||||
EOF
|
||||
)
|
||||
|
||||
if [ ! -d release ];then
|
||||
mkdir release
|
||||
fi
|
||||
|
||||
printf "$vote_contents" > ./release/apache-apisix-$VERSION-vote-contents.txt
|
174
CloudronPackages/APISIX/apisix-source/utils/install-dependencies.sh
Executable file
174
CloudronPackages/APISIX/apisix-source/utils/install-dependencies.sh
Executable file
@@ -0,0 +1,174 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
set -ex
|
||||
|
||||
function detect_aur_helper() {
|
||||
if [[ $(command -v yay) ]]; then
|
||||
AUR_HELPER=yay
|
||||
elif [[ $(command -v pacaur) ]]; then
|
||||
AUR_HELPER=pacaur
|
||||
else
|
||||
echo No available AUR helpers found. Please specify your AUR helper by AUR_HELPER.
|
||||
exit 255
|
||||
fi
|
||||
}
|
||||
|
||||
function install_dependencies_with_aur() {
|
||||
detect_aur_helper
|
||||
$AUR_HELPER -S openresty --noconfirm
|
||||
sudo pacman -S openssl --noconfirm
|
||||
|
||||
export OPENRESTY_PREFIX=/opt/openresty
|
||||
|
||||
sudo mkdir $OPENRESTY_PREFIX/openssl
|
||||
sudo ln -s /usr/include $OPENRESTY_PREFIX/openssl/include
|
||||
sudo ln -s /usr/lib $OPENRESTY_PREFIX/openssl/lib
|
||||
}
|
||||
|
||||
# Install dependencies on centos and fedora
|
||||
function install_dependencies_with_yum() {
|
||||
sudo yum install -y yum-utils
|
||||
sudo yum-config-manager --add-repo "https://openresty.org/package/${1}/openresty.repo"
|
||||
if [[ "${1}" == "centos" ]]; then
|
||||
sudo yum -y install centos-release-scl
|
||||
sudo yum -y install devtoolset-9 patch wget
|
||||
set +eu
|
||||
source scl_source enable devtoolset-9
|
||||
set -eu
|
||||
fi
|
||||
sudo yum install -y \
|
||||
gcc gcc-c++ curl wget unzip xz gnupg perl-ExtUtils-Embed cpanminus patch libyaml-devel \
|
||||
perl perl-devel pcre pcre-devel openldap-devel \
|
||||
openresty-zlib-devel openresty-pcre-devel
|
||||
}
|
||||
|
||||
# Install dependencies on ubuntu and debian
|
||||
function install_dependencies_with_apt() {
|
||||
# add OpenResty source
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install software-properties-common wget lsb-release gnupg patch
|
||||
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
|
||||
arch=$(uname -m | tr '[:upper:]' '[:lower:]')
|
||||
arch_path=""
|
||||
if [[ $arch == "arm64" ]] || [[ $arch == "aarch64" ]]; then
|
||||
arch_path="arm64/"
|
||||
fi
|
||||
if [[ "${1}" == "ubuntu" ]]; then
|
||||
sudo add-apt-repository -y "deb http://openresty.org/package/${arch_path}ubuntu $(lsb_release -sc) main"
|
||||
elif [[ "${1}" == "debian" ]]; then
|
||||
sudo add-apt-repository -y "deb http://openresty.org/package/${arch_path}debian $(lsb_release -sc) openresty"
|
||||
fi
|
||||
sudo apt-get update
|
||||
|
||||
# install some compilation tools
|
||||
sudo apt-get install -y curl make gcc g++ cpanminus libpcre3 libpcre3-dev libyaml-dev unzip openresty-zlib-dev openresty-pcre-dev
|
||||
}
|
||||
|
||||
# Identify the different distributions and call the corresponding function
|
||||
function multi_distro_installation() {
|
||||
if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
|
||||
install_dependencies_with_yum "centos"
|
||||
elif grep -Eqi -e "Red Hat" -e "rhel" /etc/*-release; then
|
||||
install_dependencies_with_yum "rhel"
|
||||
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
|
||||
install_dependencies_with_yum "fedora"
|
||||
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
|
||||
install_dependencies_with_apt "debian"
|
||||
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
|
||||
install_dependencies_with_apt "ubuntu"
|
||||
elif grep -Eqi "Arch" /etc/issue || grep -Eqi "EndeavourOS" /etc/issue || grep -Eq "Arch" /etc/*-release; then
|
||||
install_dependencies_with_aur
|
||||
else
|
||||
echo "Non-supported distribution, APISIX is only supported on Linux-based systems"
|
||||
exit 1
|
||||
fi
|
||||
install_apisix_runtime
|
||||
}
|
||||
|
||||
function multi_distro_uninstallation() {
|
||||
if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
|
||||
sudo yum autoremove -y openresty-zlib-devel openresty-pcre-devel
|
||||
elif grep -Eqi -e "Red Hat" -e "rhel" /etc/*-release; then
|
||||
sudo yum autoremove -y openresty-zlib-devel openresty-pcre-devel
|
||||
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
|
||||
sudo yum autoremove -y openresty-zlib-devel openresty-pcre-devel
|
||||
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
|
||||
sudo apt-get autoremove -y openresty-zlib-dev openresty-pcre-dev
|
||||
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
|
||||
sudo apt-get autoremove -y openresty-zlib-dev openresty-pcre-dev
|
||||
else
|
||||
echo "Non-supported distribution, APISIX is only supported on Linux-based systems"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function install_apisix_runtime() {
|
||||
export runtime_version=${APISIX_RUNTIME:?}
|
||||
wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh"
|
||||
chmod +x build-apisix-runtime.sh
|
||||
./build-apisix-runtime.sh latest
|
||||
rm build-apisix-runtime.sh
|
||||
}
|
||||
|
||||
# Install LuaRocks
|
||||
function install_luarocks() {
|
||||
if [ -f "./utils/linux-install-luarocks.sh" ]; then
|
||||
./utils/linux-install-luarocks.sh
|
||||
elif [ -f "./linux-install-luarocks.sh" ]; then
|
||||
./linux-install-luarocks.sh
|
||||
else
|
||||
echo "Installing luarocks from remote master branch"
|
||||
curl https://raw.githubusercontent.com/apache/apisix/master/utils/linux-install-luarocks.sh -sL | bash -
|
||||
fi
|
||||
}
|
||||
|
||||
# Entry
|
||||
function main() {
|
||||
OS_NAME=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
if [[ "$#" == 0 ]]; then
|
||||
if [[ "${OS_NAME}" == "linux" ]]; then
|
||||
multi_distro_installation
|
||||
install_luarocks
|
||||
return
|
||||
else
|
||||
echo "Non-supported distribution, APISIX is only supported on Linux-based systems"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
case_opt=$1
|
||||
case "${case_opt}" in
|
||||
"install_luarocks")
|
||||
install_luarocks
|
||||
;;
|
||||
"uninstall")
|
||||
if [[ "${OS_NAME}" == "linux" ]]; then
|
||||
multi_distro_uninstallation
|
||||
else
|
||||
echo "Non-supported distribution, APISIX is only supported on Linux-based systems"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported method: ${case_opt}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main "$@"
|
68
CloudronPackages/APISIX/apisix-source/utils/linux-install-luarocks.sh
Executable file
68
CloudronPackages/APISIX/apisix-source/utils/linux-install-luarocks.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
set -ex
|
||||
|
||||
# you might need sudo to run this script
|
||||
if [ -z ${OPENRESTY_PREFIX} ]; then
|
||||
OPENRESTY_PREFIX="/usr/local/openresty"
|
||||
fi
|
||||
|
||||
LUAROCKS_VER=3.12.0
|
||||
wget -q https://github.com/luarocks/luarocks/archive/v"$LUAROCKS_VER".tar.gz
|
||||
tar -xf v"$LUAROCKS_VER".tar.gz
|
||||
rm -f v"$LUAROCKS_VER".tar.gz
|
||||
cd luarocks-"$LUAROCKS_VER" || exit
|
||||
|
||||
OR_BIN="$OPENRESTY_PREFIX/bin/openresty"
|
||||
OR_VER=$($OR_BIN -v 2>&1 | awk -F '/' '{print $2}' | awk -F '.' '{print $1 * 100 + $2}')
|
||||
if [[ -e $OR_BIN && "$OR_VER" -ge 119 ]]; then
|
||||
WITH_LUA_OPT="--with-lua=${OPENRESTY_PREFIX}/luajit"
|
||||
else
|
||||
# For old version OpenResty, we still need to install LuaRocks with Lua
|
||||
WITH_LUA_OPT=
|
||||
fi
|
||||
|
||||
./configure $WITH_LUA_OPT \
|
||||
> build.log 2>&1 || (cat build.log && exit 1)
|
||||
|
||||
make build > build.log 2>&1 || (cat build.log && exit 1)
|
||||
sudo make install > build.log 2>&1 || (cat build.log && exit 1)
|
||||
cd .. || exit
|
||||
rm -rf luarocks-"$LUAROCKS_VER"
|
||||
|
||||
mkdir ~/.luarocks || true
|
||||
|
||||
# For old version OpenResty, we still need to install LuaRocks with Lua
|
||||
OPENSSL_PREFIX=${OPENRESTY_PREFIX}/openssl
|
||||
if [ -d ${OPENRESTY_PREFIX}/openssl3 ]; then
|
||||
OPENSSL_PREFIX=${OPENRESTY_PREFIX}/openssl3
|
||||
elif [ -d ${OPENRESTY_PREFIX}/openssl111 ]; then
|
||||
OPENSSL_PREFIX=${OPENRESTY_PREFIX}/openssl111
|
||||
fi
|
||||
|
||||
[ ! -d ${OPENSSL_PREFIX} ] && echo "Warning: the path ${OPENSSL_PREFIX} is not found."
|
||||
|
||||
FOUND_PATH=$(echo "${PATH}" | grep -oP '(?<=:|)/usr/local/bin(?=:|)') || true
|
||||
if [[ "${FOUND_PATH}" == "" ]]; then
|
||||
echo "Warning: the path /usr/local/bin is not included in the system default PATH variable."
|
||||
export PATH=$PATH:/usr/local/bin
|
||||
fi
|
||||
|
||||
luarocks config variables.OPENSSL_LIBDIR ${OPENSSL_PREFIX}/lib
|
||||
luarocks config variables.OPENSSL_INCDIR ${OPENSSL_PREFIX}/include
|
||||
luarocks config variables.YAML_DIR /usr
|
Reference in New Issue
Block a user