Fix install_nginx.sh.
This commit is contained in:
parent
210d903395
commit
a968e40cdd
|
@ -1,4 +1,32 @@
|
|||
#!/bin/bash
|
||||
vercomp () {
|
||||
if [[ "$1" == "$2" ]]; then
|
||||
echo "=";
|
||||
return 0;
|
||||
fi
|
||||
local IFS=.;
|
||||
local i ver1=($1) ver2=($2);
|
||||
# fill empty fields in ver1 with zeros
|
||||
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
|
||||
ver1[i]=0
|
||||
done
|
||||
for ((i=0; i<${#ver1[@]}; i++)); do
|
||||
if [[ -z ${ver2[i]} ]]; then
|
||||
# fill empty fields in ver2 with zeros
|
||||
ver2[i]=0
|
||||
fi
|
||||
if ((10#${ver1[i]} > 10#${ver2[i]})); then
|
||||
echo ">";
|
||||
return 0;
|
||||
fi
|
||||
if ((10#${ver1[i]} < 10#${ver2[i]})); then
|
||||
echo "<";
|
||||
return 0;
|
||||
fi
|
||||
done
|
||||
echo "=";
|
||||
return 0;
|
||||
}
|
||||
function escape_str(){
|
||||
echo $1|sed -E 's/\\+//g' |sed -E 's/[\/\.\*]/\\\0/g'
|
||||
}
|
||||
|
@ -25,7 +53,7 @@ force_reinstall_openssl="0"
|
|||
if [[ ! -d "/usr/include/openssl" ]] && [[ ! -d "/usr/local/include/openssl" ]] && [[ ! -d "/usr/pkg/include/openssl" ]] && [[ ! -d "/opt/local/include/openssl" ]] && [[ ! -d /opt/openssl/include/openssl ]]; then
|
||||
force_reinstall_openssl="1"
|
||||
fi
|
||||
if [[ "$openssl_ver" < "1.1.1" ]] || [[ "$force_reinstall_openssl" == "1" ]]; then
|
||||
if [[ $(vercomp "$openssl_ver" "1.1.1") == "<" ]] || [[ "$force_reinstall_openssl" == "1" ]]; then
|
||||
# Build openssl
|
||||
target_openssl_ver="1.1.1q"
|
||||
sudo bash -l -c "
|
||||
|
@ -48,7 +76,7 @@ fi
|
|||
if [ -z "$cpu_cores" ]; then
|
||||
cpu_cores="1";
|
||||
fi
|
||||
if [[ "$ubuntu_ver" < "16" ]]; then #Need update ca-certificates manual
|
||||
if [[ $(vercomp "$ubuntu_ver" "16") == "<" ]]; then #Need update ca-certificates manual
|
||||
sudo bash -l -c "
|
||||
cd /root &&
|
||||
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/ca-certificates/20210119~20.04.2/ca-certificates_20210119~20.04.2.tar.xz --no-check-certificate -O ca-certificates_20210119~20.04.2.tar.xz &&
|
||||
|
@ -56,6 +84,8 @@ if [[ "$ubuntu_ver" < "16" ]]; then #Need update ca-certificates manual
|
|||
cd ca-certificates-20210119~20.04.1 &&
|
||||
make -j$cpu_cores && make install &&
|
||||
dpkg-reconfigure -fnoninteractive ca-certificates &&
|
||||
if [ -e /etc/ca-certificates.conf ]; then sed -E 's/^!//g' -i /etc/ca-certificates.conf; fi &&
|
||||
dpkg-reconfigure -fnoninteractive ca-certificates &&
|
||||
update-ca-certificates --fresh --verbose &&
|
||||
/usr/bin/c_rehash /etc/ssl/certs"
|
||||
cd "$org_pwd"
|
||||
|
@ -74,7 +104,7 @@ extra_remove_packages=""
|
|||
extra_build_nginx_cmd="true"
|
||||
if [[ "$@" == *"--install-modsecurity"* ]];then
|
||||
install_modsecurity="1"
|
||||
if [[ "$ubuntu_ver" < "16" ]]; then #use 3.0.6
|
||||
if [[ $(vercomp "$ubuntu_ver" "16") == "<" ]]; then #use 3.0.6
|
||||
sudo bash -l -c "
|
||||
cd /root &&
|
||||
apt-get install -y apt-utils autoconf automake build-essential git libcurl4-openssl-dev libgeoip-dev liblmdb-dev libpcre++-dev libtool libxml2-dev libyajl-dev pkgconf wget zlib1g-dev &&
|
||||
|
@ -160,7 +190,7 @@ if [[ ! -f /etc/init.d/nginx ]]; then
|
|||
sudo wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/nginx_service.sh -O /etc/init.d/nginx
|
||||
sudo chmod 755 /etc/init.d/nginx
|
||||
sudo chown root:root /etc/init.d/nginx
|
||||
if [[ "$ubuntu_ver" > "16" ]] || [[ "$ubuntu_ver" == "16" ]]; then
|
||||
if [[ $(vercomp "$ubuntu_ver" "16") == ">" ]]; then
|
||||
sudo wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/nginx.service -O /lib/systemd/system/nginx.service
|
||||
sudo chown root:root /lib/systemd/system/nginx.service
|
||||
sudo chmod 644 /lib/systemd/system/nginx.service
|
||||
|
@ -171,7 +201,7 @@ if [[ ! -f /etc/init.d/nginx ]]; then
|
|||
fi
|
||||
fi
|
||||
nginx_target_ver="1.23.1"
|
||||
if [[ "$nginx_ver" < $nginx_target_ver ]] || [[ "$1" == '--force' ]] || [[ "$install_modsecurity" == "1" ]] || [[ "$install_passenger" == "1" ]]; then
|
||||
if [[ $(vercomp "$nginx_ver" "$nginx_target_ver") == "<"]] || [[ "$1" == '--force' ]] || [[ "$install_modsecurity" == "1" ]] || [[ "$install_passenger" == "1" ]]; then
|
||||
if [ -f "/etc/nginx/nginx.conf" ]; then
|
||||
nginx_conf_exist="1"
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue