Fix bug for ubuntu 22.04.
This commit is contained in:
parent
56147289d5
commit
5543796f1e
|
@ -3,6 +3,10 @@ function escape_str(){
|
|||
echo $1|sed -E 's/\\+//g' |sed -E 's/[\/\.\*]/\\\0/g'
|
||||
}
|
||||
ubuntu_ver="$(lsb_release -rs)"
|
||||
if [[ -e "/etc/needrestart/needrestart.conf" ]]; then
|
||||
sudo sed -E -i "s/(^|#)\\\$nrconf\{restart\}\s*=.*/\$nrconf\{restart\} = 'a';/g" /etc/needrestart/needrestart.conf
|
||||
sudo sed -E -i "s/(^|#)\\\$nrconf\{kernelhints\}\s*=.*/\$nrconf\{kernelhints\} = -1;/g" /etc/needrestart/needrestart.conf
|
||||
fi
|
||||
sudo apt-get install -y linux-kernel-headers build-essential
|
||||
org_pwd="$(pwd)"
|
||||
cpu_cores="$(nproc --all)"
|
||||
|
@ -21,7 +25,7 @@ if [[ "$openssl_ver" < "1.1.1" ]] || [[ "$force_reinstall_openssl" == "1" ]]; th
|
|||
target_openssl_ver="1.1.1m"
|
||||
sudo bash -l -c "
|
||||
cd /root &&
|
||||
wget https://www.openssl.org/source/openssl-$target_openssl_ver.tar.gz --no-check-certificate &&
|
||||
wget https://www.openssl.org/source/openssl-$target_openssl_ver.tar.gz --no-check-certificate -O openssl-$target_openssl_ver.tar.gz &&
|
||||
tar xzvf openssl-$target_openssl_ver.tar.gz &&
|
||||
cd openssl-$target_openssl_ver &&
|
||||
./config no-ssl2 no-ssl3 zlib-dynamic -fPIC shared --prefix=/opt/openssl &&
|
||||
|
@ -41,7 +45,7 @@ fi
|
|||
if [[ "$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 &&
|
||||
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 &&
|
||||
tar -xJf ca-certificates_20210119~20.04.2.tar.xz &&
|
||||
cd ca-certificates-20210119~20.04.1 &&
|
||||
make -j$cpu_cores && make install &&
|
||||
|
@ -110,7 +114,7 @@ if [[ "$nginx_ver" < $nginx_target_ver ]] || [[ "$1" == '--force' ]] || [[ "$ins
|
|||
#Build nginx and install
|
||||
sudo bash -l -c "
|
||||
cd /root && \
|
||||
wget http://nginx.org/download/nginx-$nginx_target_ver.tar.gz && \
|
||||
wget http://nginx.org/download/nginx-$nginx_target_ver.tar.gz -O nginx-$nginx_target_ver.tar.gz && \
|
||||
tar -zxvf nginx-$nginx_target_ver.tar.gz && \
|
||||
cd nginx-$nginx_target_ver && \
|
||||
apt remove nginx --purge -y && \
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/bin/bash
|
||||
ubuntu_version=$(lsb_release -rs)
|
||||
if [[ -e "/etc/needrestart/needrestart.conf" ]]; then
|
||||
sudo sed -E -i "s/(^|#)\\\$nrconf\{restart\}\s*=.*/\$nrconf\{restart\} = 'a';/g" /etc/needrestart/needrestart.conf
|
||||
sudo sed -E -i "s/(^|#)\\\$nrconf\{kernelhints\}\s*=.*/\$nrconf\{kernelhints\} = -1;/g" /etc/needrestart/needrestart.conf
|
||||
fi
|
||||
sudo apt update
|
||||
sudo apt install -y git
|
||||
sudo apt install -y linux-kernel-headers build-essential
|
||||
|
@ -32,10 +36,51 @@ function write_messages(){
|
|||
echo "$messages_logs" > install_orbit_environment.log
|
||||
echo "Logs stored in install_orbit_environment.log!"
|
||||
}
|
||||
if [[ $ubuntu_version > '21' ]]; then
|
||||
function apt_add_key_func(){
|
||||
url="$1"
|
||||
base_name="$(basename $url)"
|
||||
file_path="/etc/apt/trusted.gpg.d/$base_name"
|
||||
sudo wget "$url" -q -O "$file_path"
|
||||
if [[ -e "$file_path" ]]; then
|
||||
mime_type=`file -b --mime-type "$file_path"`
|
||||
if [[ $mime_type == "application/pgp-keys" ]]; then
|
||||
new_file_path=`echo "$file_path"| sed -E 's/(\.[^.]+$|$)/\.gpg/g'`
|
||||
cat $file_path|sudo gpg --dearmor -o $new_file_path
|
||||
rm -f $file_path
|
||||
file_path="$new_file_path"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
else
|
||||
function apt_add_key_func(){
|
||||
wget -qO - "$1" | sudo apt-key add -
|
||||
}
|
||||
fi
|
||||
if [ $nginx_status != "0" ]; then
|
||||
sudo sed -i 's/\([^#]include \/etc\/nginx\/sites-enabled\/*\)/\#\1/g' /etc/nginx/nginx.conf
|
||||
fi
|
||||
sudo service nginx restart
|
||||
openssl_dir=""
|
||||
need_export_apt_key="0"
|
||||
if [[ $ubuntu_version > '21' ]]; then # ruby must use openssl <= 1.1.1. Not support openssl 3.0 yet.
|
||||
need_export_apt_key="1"
|
||||
if [[ ! -d "/opt/openssl" ]]; then
|
||||
target_openssl_ver="1.1.1q"
|
||||
sudo bash -l -c "
|
||||
cd /root &&
|
||||
wget https://www.openssl.org/source/openssl-$target_openssl_ver.tar.gz --no-check-certificate -O openssl-$target_openssl_ver.tar.gz &&
|
||||
tar xzvf openssl-$target_openssl_ver.tar.gz &&
|
||||
cd openssl-$target_openssl_ver &&
|
||||
./config no-ssl2 no-ssl3 zlib-dynamic -fPIC shared --prefix=/opt/openssl &&
|
||||
make depend -j$cpu_cores && make install"
|
||||
openssl_ver="$target_openssl_ver"
|
||||
cd "$org_pwd"
|
||||
openssl_dir="/opt/openssl"
|
||||
openssl_source_dir="/root/openssl-$target_openssl_ver"
|
||||
fi
|
||||
sudo mkdir -p /etc/apt/trusted.gpg.d/
|
||||
fi
|
||||
cd /etc/nginx/
|
||||
sudo mkdir orbit_sites/
|
||||
if [ -z "$(grep 'orbit_sites' nginx.conf)" ]; then
|
||||
|
@ -44,7 +89,7 @@ fi
|
|||
cd $org_pwd
|
||||
sudo apt-get install gnupg -y
|
||||
if [[ $ubuntu_version =~ '14' ]]; then
|
||||
wget -qO - https://www.mongodb.org/static/pgp/server-3.2.asc | sudo apt-key add -
|
||||
apt_add_key_func https://www.mongodb.org/static/pgp/server-3.2.asc
|
||||
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y mongodb-org=3.2.22 mongodb-org-server=3.2.22 mongodb-org-shell=3.2.22 mongodb-org-mongos=3.2.22 mongodb-org-tools=3.2.22
|
||||
|
@ -70,7 +115,7 @@ if [[ $ubuntu_version =~ '14' ]]; then
|
|||
fi
|
||||
else
|
||||
# install mongod 6.0
|
||||
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
|
||||
apt_add_key_func https://www.mongodb.org/static/pgp/server-6.0.asc
|
||||
if [[ $ubuntu_version =~ '20' ]] || [[ $ubuntu_version =~ '21' ]]; then
|
||||
sudo wget -nc http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0-dev_1.0.2n-1ubuntu5_amd64.deb
|
||||
sudo dpkg -i libssl1.0-dev_1.0.2n-1ubuntu5_amd64.deb
|
||||
|
@ -105,7 +150,7 @@ else
|
|||
sudo apt-get purge mongodb-org* -y
|
||||
sudo rm -rf /var/log/mongodb
|
||||
sudo rm -rf /var/lib/mongodb
|
||||
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
|
||||
apt_add_key_func https://www.mongodb.org/static/pgp/server-5.0.asc
|
||||
# install mongod 5.0
|
||||
if [[ $ubuntu_version =~ '20' ]] || [[ $ubuntu_version =~ '21' ]]; then
|
||||
sudo wget -nc http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0-dev_1.0.2n-1ubuntu5_amd64.deb
|
||||
|
@ -139,7 +184,7 @@ else
|
|||
sudo apt-get purge mongodb-org* -y
|
||||
sudo rm -rf /var/log/mongodb
|
||||
sudo rm -rf /var/lib/mongodb
|
||||
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
|
||||
apt_add_key_func https://www.mongodb.org/static/pgp/server-4.4.asc
|
||||
if [[ $ubuntu_version =~ '20' ]] || [[ $ubuntu_version =~ '21' ]]; then
|
||||
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
|
||||
elif [[ $ubuntu_version =~ '18' ]] || [[ $ubuntu_version =~ '19' ]]; then
|
||||
|
@ -220,8 +265,13 @@ if [ -z $(which rvm) ]; then
|
|||
fi
|
||||
source "/etc/profile.d/rvm.sh"
|
||||
# install ruby 2.7.6
|
||||
if [[ -z "$openssl_dir" ]]; then
|
||||
rvm install 2.7.6
|
||||
else
|
||||
rvm install 2.7.6 --with-openssl-dir="$openssl_dir"
|
||||
fi
|
||||
rvm --default use 2.7.6
|
||||
gem install bundler -v 2.1.4
|
||||
gem install zip
|
||||
gem install nokogiri -v 1.8.5 #for ruby 2.7.6
|
||||
#gem install nokogiri -v 1.7.0.1 #for ruby 2.1.10
|
||||
|
|
Loading…
Reference in New Issue