2022-02-09 09:59:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
ubuntu_version=$(lsb_release -rs)
|
2022-09-15 08:39:48 +00:00
|
|
|
ubuntu_codename=$(lsb_release -cs)
|
2022-09-15 08:09:44 +00:00
|
|
|
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
|
2022-02-09 09:59:50 +00:00
|
|
|
sudo apt update
|
2023-09-09 03:39:54 +00:00
|
|
|
sudo apt install -y git psmisc #fuser
|
2022-09-15 08:39:48 +00:00
|
|
|
org_pwd=$(pwd)
|
2023-02-23 07:45:06 +00:00
|
|
|
if [[ "$ubuntu_version" > '22' ]]; then #In ubuntu 22, install linux-libc-dev instead of linux-kernel-headers
|
2022-11-03 15:34:46 +00:00
|
|
|
sudo apt install -y linux-libc-dev software-properties-common build-essential
|
2022-09-15 08:39:48 +00:00
|
|
|
else
|
2022-11-03 15:34:46 +00:00
|
|
|
sudo apt install -y linux-kernel-headers software-properties-common build-essential
|
2022-09-15 08:39:48 +00:00
|
|
|
fi
|
|
|
|
if [[ ! -e "/usr/lib/x86_64-linux-gnu/librt.so" ]]; then
|
|
|
|
sudo apt install -y libc6 libc6-dev
|
|
|
|
sudo ln -s /usr/lib/x86_64-linux-gnu/librt.so.1 /usr/lib/x86_64-linux-gnu/librt.so
|
|
|
|
fi
|
2022-02-09 11:26:06 +00:00
|
|
|
org_pwd=$(pwd)
|
2023-02-17 08:42:38 +00:00
|
|
|
sudo apt install -y libncurses5-dev libgmp-dev
|
2023-12-17 16:23:27 +00:00
|
|
|
sudo apt-get install libjemalloc-dev -y
|
2022-02-09 09:59:50 +00:00
|
|
|
echo "postfix postfix/mailname string $USER" | sudo debconf-set-selections
|
|
|
|
echo "postfix postfix/main_mailer_type string 'Local only'" | sudo debconf-set-selections
|
|
|
|
sudo apt-get install -y postfix
|
|
|
|
sudo service postfix start
|
2022-08-04 07:33:40 +00:00
|
|
|
#install nginx 1.23.1
|
|
|
|
wget http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/install_nginx.sh -O install_nginx.sh
|
|
|
|
bash install_nginx.sh
|
2022-05-24 07:46:03 +00:00
|
|
|
sudo nginx -t
|
|
|
|
nginx_status="$(echo $?)"
|
2022-08-25 01:39:48 +00:00
|
|
|
messages_logs=""
|
|
|
|
function push_messages(){
|
|
|
|
if [[ ! -z "$1" ]]; then
|
|
|
|
if [ -z "$messages_logs" ]; then
|
|
|
|
messages_logs="$1"
|
|
|
|
else
|
|
|
|
messages_logs="$messages_logs
|
|
|
|
$1"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
function write_messages(){
|
|
|
|
echo "$messages_logs"
|
|
|
|
echo "$messages_logs" > install_orbit_environment.log
|
|
|
|
echo "Logs stored in install_orbit_environment.log!"
|
|
|
|
}
|
2022-12-28 01:21:34 +00:00
|
|
|
function fix_mongod_and_logrotate(){
|
|
|
|
if [ -z "$(grep logRotate /etc/mongod.conf)" ]; then
|
|
|
|
sed -i -E 's/logAppend.*/logRotate: reopen\n \0/g' /etc/mongod.conf
|
|
|
|
fi
|
|
|
|
sudo bash -l -c "
|
|
|
|
cd /root && \
|
|
|
|
git clone https://github.com/logrotate/logrotate && \
|
|
|
|
cd logrotate && \
|
|
|
|
apt-get -y install autoconf automake libpopt-dev libtool make xz-utils && \
|
|
|
|
autoreconf -fiv && \
|
|
|
|
./configure --prefix=/usr && \
|
|
|
|
make && make install && \
|
|
|
|
logrotate -d /etc/logrotate.conf"
|
|
|
|
cd "$org_pwd"
|
|
|
|
}
|
2023-02-23 07:45:06 +00:00
|
|
|
function get_mongodb_old(){
|
|
|
|
old_dir="mongodb_old"
|
|
|
|
if [ -d "/var/lib/$old_dir" ]; then
|
|
|
|
postfix_num="0"
|
|
|
|
while true; do
|
|
|
|
old_dir="mongodb_old.$postfix_num"
|
|
|
|
if [ ! -d "/var/lib/$old_dir" ]; then
|
|
|
|
break
|
|
|
|
else
|
|
|
|
postfix_num="$((postfix_num+1))"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
mongodb_old_dir="/var/lib/$old_dir"
|
|
|
|
}
|
|
|
|
function fix_downgrade_mongod(){
|
2023-04-20 02:40:48 +00:00
|
|
|
if [ -z "$org_mongod_ver" ]; then
|
2023-02-23 07:45:06 +00:00
|
|
|
sudo rm -rf /var/lib/mongodb/*;
|
|
|
|
sudo chown mongodb:mongodb /var/lib/mongodb -R
|
|
|
|
sudo chown mongodb:mongodb /var/log/mongodb -R
|
|
|
|
sudo service mongod restart
|
|
|
|
sleep 10
|
|
|
|
else
|
|
|
|
if [[ "$org_mongod_ver" > "$1" ]] ; then
|
|
|
|
if [ -d "/var/lib/mongodb" ]; then
|
|
|
|
get_mongodb_old
|
|
|
|
mv /var/lib/mongodb $mongodb_old_dir
|
|
|
|
push_messages "old mongo move to $mongodb_old_dir!"
|
|
|
|
fi
|
|
|
|
sudo mkdir -p /var/lib/mongodb
|
|
|
|
sudo chown mongodb:mongodb /var/lib/mongodb -R
|
|
|
|
sudo chown mongodb:mongodb /var/log/mongodb -R
|
|
|
|
sudo service mongod restart
|
|
|
|
sleep 10
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
mongod --version
|
|
|
|
mongod_code="$(echo $?)"
|
|
|
|
}
|
|
|
|
function install_mongodb(){
|
2023-04-06 05:26:11 +00:00
|
|
|
if [[ "$2" == "1" ]]; then #reinstall
|
|
|
|
sudo rm -f /etc/apt/sources.list.d/mongodb-org-*
|
|
|
|
fi
|
2023-04-20 02:40:48 +00:00
|
|
|
if [[ "$ubuntu_version" > '20' ]]; then
|
|
|
|
sudo wget -nc http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
|
|
|
|
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
|
|
|
|
sudo wget -nc http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1f-1ubuntu2_amd64.deb
|
|
|
|
sudo dpkg -i libssl-dev_1.1.1f-1ubuntu2_amd64.deb
|
|
|
|
fi
|
2023-02-23 07:45:06 +00:00
|
|
|
case $1 in
|
|
|
|
3.2)
|
|
|
|
mongod_ver="3.2.22"
|
|
|
|
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=$mongod_ver mongodb-org-server=$mongod_ver mongodb-org-shell=$mongod_ver mongodb-org-mongos=$mongod_ver mongodb-org-tools=$mongod_ver
|
|
|
|
sudo service mongod stop
|
|
|
|
sudo rm -f /var/lib/mongodb/mongod.lock
|
|
|
|
sudo rm -f /tmp/mongodb-27017.sock
|
|
|
|
sudo chown mongodb:mongodb /var/lib/mongodb -R
|
|
|
|
sudo chown mongodb:mongodb /var/log/mongodb -R
|
|
|
|
sudo service mongod restart
|
|
|
|
sleep 10
|
|
|
|
fix_downgrade_mongod "$mongod_ver"
|
|
|
|
if [ $mongod_code != 0 ] && [ $mongod_code != 1 ]; then #mongo core dump
|
|
|
|
push_messages "Mongo 3.2 core dump!"
|
|
|
|
push_messages "Please install mongod by yourself!"
|
|
|
|
else
|
|
|
|
if [ -e /tmp/mongodb-27017.sock ]; then
|
|
|
|
push_messages "Mongo start success!"
|
|
|
|
else
|
|
|
|
push_messages "mongo not yet start!"
|
|
|
|
push_messages "Please check mongo status!"
|
|
|
|
fi
|
|
|
|
fix_mongod_and_logrotate
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
4.4)
|
|
|
|
mongod_ver="4.4.18"
|
|
|
|
apt_add_key_func https://www.mongodb.org/static/pgp/server-4.4.asc
|
|
|
|
if [[ "$ubuntu_version" > '20' ]]; 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
|
|
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
|
|
|
|
else
|
|
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
|
|
|
|
fi
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y mongodb-org=$mongod_ver mongodb-org-server=$mongod_ver mongodb-org-shell=$mongod_ver mongodb-org-mongos=$mongod_ver mongodb-org-tools=$mongod_ver --allow-downgrades
|
|
|
|
sudo service mongod restart
|
|
|
|
sleep 10
|
|
|
|
fix_downgrade_mongod "$mongod_ver"
|
|
|
|
#if mongo 4.4 core dump, then install mongo 3.2
|
|
|
|
if [ $mongod_code != 0 ] && [ $mongod_code != 1 ]; then
|
|
|
|
install_mongodb "3.2" "1"
|
|
|
|
else
|
|
|
|
push_messages "mongo not yet start!"
|
|
|
|
push_messages "Please check mongo status!"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
5.0)
|
|
|
|
mongod_ver="5.0.14"
|
|
|
|
apt_add_key_func https://www.mongodb.org/static/pgp/server-5.0.asc
|
|
|
|
# install mongod 5.0
|
|
|
|
if [[ "$ubuntu_version" > '20' ]]; then
|
|
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
|
|
|
|
elif [[ "$ubuntu_version" =~ '18' ]] || [[ "$ubuntu_version" =~ '19' ]]; then
|
|
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
|
|
|
|
else
|
|
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
|
|
|
|
fi
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y mongodb-org=$mongod_ver mongodb-org-database=$mongod_ver mongodb-org-server=$mongod_ver mongodb-mongosh mongodb-org-shell=$mongod_ver mongodb-org-mongos=$mongod_ver mongodb-org-tools=$mongod_ver --allow-downgrades
|
|
|
|
sudo rm -f /var/lib/mongodb/mongod.lock
|
|
|
|
sudo rm -f /tmp/mongodb-27017.sock
|
|
|
|
sudo chown mongodb:mongodb /var/lib/mongodb -R
|
|
|
|
sudo chown mongodb:mongodb /var/log/mongodb -R
|
|
|
|
sudo service mongod restart
|
|
|
|
sleep 10
|
|
|
|
if [[ ! -e /usr/bin/mongo ]]; then
|
|
|
|
sudo ln -s /usr/bin/mongosh /usr/bin/mongo
|
|
|
|
fi
|
|
|
|
if [ -e /tmp/mongodb-27017.sock ]; then
|
|
|
|
push_messages "Mongo start success!"
|
|
|
|
fix_mongod_and_logrotate
|
|
|
|
else
|
|
|
|
fix_downgrade_mongod "$mongod_ver"
|
|
|
|
#if mongo 5.0 core dump, then install mongo 4.4
|
|
|
|
if [ $mongod_code != 0 ] && [ $mongod_code != 1 ]; then
|
|
|
|
install_mongodb "4.4" "1"
|
|
|
|
else
|
|
|
|
push_messages "mongo not yet start!"
|
|
|
|
push_messages "Please check mongo status!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
6.0)
|
|
|
|
mongod_ver="6.0.4"
|
|
|
|
apt_add_key_func https://www.mongodb.org/static/pgp/server-6.0.asc
|
|
|
|
if [[ "$ubuntu_version" > '20' ]]; then
|
|
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
|
|
|
elif [[ "$ubuntu_version" =~ '18' ]] || [[ "$ubuntu_version" =~ '19' ]]; then
|
|
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
|
|
|
else
|
|
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
|
|
|
fi
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get remove mongodb-clients --purge
|
|
|
|
sudo apt-get install -y mongodb-org=$mongod_ver mongodb-org-database=$mongod_ver mongodb-org-server=$mongod_ver mongodb-mongosh mongodb-org-mongos=$mongod_ver mongodb-org-tools=$mongod_ver --allow-downgrades
|
|
|
|
sudo service mongod stop
|
|
|
|
sudo rm -f /var/lib/mongodb/mongod.lock
|
|
|
|
sudo rm -f /tmp/mongodb-27017.sock
|
|
|
|
sudo chown mongodb:mongodb /var/lib/mongodb -R
|
|
|
|
sudo chown mongodb:mongodb /var/log/mongodb -R
|
|
|
|
sudo service mongod restart
|
|
|
|
sleep 10
|
|
|
|
if [[ ! -e /usr/bin/mongo ]]; then
|
|
|
|
sudo ln -s /usr/bin/mongosh /usr/bin/mongo
|
|
|
|
fi
|
|
|
|
if [ -e /tmp/mongodb-27017.sock ]; then
|
|
|
|
push_messages "Mongo start success!"
|
|
|
|
fix_mongod_and_logrotate
|
|
|
|
else
|
|
|
|
fix_downgrade_mongod "$mongod_ver"
|
|
|
|
#if mongo 6.0 core dump, then install mongo 5.0
|
|
|
|
if [ $mongod_code != 0 ] && [ $mongod_code != 1 ]; then
|
|
|
|
install_mongodb "5.0" "1"
|
|
|
|
else
|
|
|
|
push_messages "mongo not yet start!"
|
|
|
|
push_messages "Please check mongo status!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
push_messages "Only support mongodb: 3.2, 4.4, 5.0, 6.0!"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
if [[ "$ubuntu_version" > '21' ]]; then
|
2022-09-15 08:09:44 +00:00
|
|
|
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'`
|
2023-04-20 06:16:39 +00:00
|
|
|
cat $file_path|sudo gpg --batch --yes --dearmor -o $new_file_path
|
|
|
|
sudo rm -f $file_path
|
2022-09-15 08:09:44 +00:00
|
|
|
file_path="$new_file_path"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
else
|
|
|
|
function apt_add_key_func(){
|
|
|
|
wget -qO - "$1" | sudo apt-key add -
|
|
|
|
}
|
|
|
|
fi
|
2022-08-24 10:09:51 +00:00
|
|
|
if [ $nginx_status != "0" ]; then
|
2022-05-24 07:46:03 +00:00
|
|
|
sudo sed -i 's/\([^#]include \/etc\/nginx\/sites-enabled\/*\)/\#\1/g' /etc/nginx/nginx.conf
|
|
|
|
fi
|
2022-02-09 09:59:50 +00:00
|
|
|
sudo service nginx restart
|
2022-09-15 08:09:44 +00:00
|
|
|
openssl_dir=""
|
|
|
|
need_export_apt_key="0"
|
2023-02-23 07:45:06 +00:00
|
|
|
if [[ "$ubuntu_version" > '21' ]]; then # ruby must use openssl <= 1.1.1. Not support openssl 3.0 yet.
|
2022-09-15 08:09:44 +00:00
|
|
|
need_export_apt_key="1"
|
|
|
|
if [[ ! -d "/opt/openssl" ]]; then
|
2024-01-28 04:20:07 +00:00
|
|
|
target_openssl_ver="1.1.1w"
|
2022-09-15 08:09:44 +00:00
|
|
|
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"
|
|
|
|
fi
|
2024-01-28 04:20:07 +00:00
|
|
|
openssl_dir="/opt/openssl"
|
2022-09-15 15:34:09 +00:00
|
|
|
sudo rm -rf /opt/openssl/ssl/certs
|
|
|
|
sudo ln -s /etc/ssl/certs/ /opt/openssl/ssl/.
|
2022-09-15 08:09:44 +00:00
|
|
|
sudo mkdir -p /etc/apt/trusted.gpg.d/
|
|
|
|
fi
|
2022-02-09 09:59:50 +00:00
|
|
|
cd /etc/nginx/
|
|
|
|
sudo mkdir orbit_sites/
|
2022-02-09 11:26:06 +00:00
|
|
|
if [ -z "$(grep 'orbit_sites' nginx.conf)" ]; then
|
2022-08-24 10:09:51 +00:00
|
|
|
sudo sed -i 's/\(include\ \/etc\/nginx\/sites-enabled\/\*\;\)/\1\n include\ \/etc\/nginx\/orbit_sites\/*;/g' nginx.conf
|
2022-02-09 11:26:06 +00:00
|
|
|
fi
|
2023-02-23 07:45:06 +00:00
|
|
|
if [[ "$ubuntu_version" > '22' ]]; then #Use root account prevent reading socket denied
|
2024-04-18 00:09:56 +00:00
|
|
|
sudo sed -E -i 's/^[# ]*user.*/user root;/g' /etc/nginx/nginx.conf
|
2022-09-15 08:51:00 +00:00
|
|
|
fi
|
2022-02-09 11:26:06 +00:00
|
|
|
cd $org_pwd
|
2022-02-10 03:17:04 +00:00
|
|
|
sudo apt-get install gnupg -y
|
2023-02-23 07:45:06 +00:00
|
|
|
if [ -z "$(which mongod)" ]; then
|
|
|
|
org_mongod_ver=""
|
2022-08-25 01:39:48 +00:00
|
|
|
else
|
2023-02-23 07:45:06 +00:00
|
|
|
org_mongod_ver=`mongod --version|grep 'Build Info' -A 20|grep 'version'|sed -E 's/\s*"version"://g'|cut -d '"' -f 2`
|
|
|
|
fi
|
|
|
|
if [[ "$ubuntu_version" =~ '14' ]]; then
|
|
|
|
install_mongodb "3.2"
|
|
|
|
else
|
2024-01-01 02:30:38 +00:00
|
|
|
if [ -z "$(lscpu |grep -w 'avx')" ]; then #Latest version not use avx instruction is 4.4.
|
2023-02-23 07:45:06 +00:00
|
|
|
install_mongodb "4.4"
|
2022-08-25 01:39:48 +00:00
|
|
|
else
|
2023-02-23 07:45:06 +00:00
|
|
|
install_mongodb "6.0"
|
2022-02-10 03:17:04 +00:00
|
|
|
fi
|
2022-02-09 09:59:50 +00:00
|
|
|
fi
|
2022-02-09 11:26:06 +00:00
|
|
|
# build ImageMagick and install
|
2022-02-09 10:48:06 +00:00
|
|
|
if [ -z $(which convert) ]; then
|
2022-08-24 07:39:33 +00:00
|
|
|
remove_1_dir="0"
|
|
|
|
if [[ ! -d "1" ]]; then
|
|
|
|
remove_1_dir="1";
|
|
|
|
fi
|
2022-08-24 06:57:54 +00:00
|
|
|
tmp_pwd="$(pwd)"
|
|
|
|
sudo bash -l -c "cd /root && \
|
2022-02-09 10:48:06 +00:00
|
|
|
apt-get install libjpeg62 -y && \
|
|
|
|
wget -nc http://download.sourceforge.net/libpng/libpng-1.5.13.tar.gz && \
|
|
|
|
tar xvfz libpng-1.5.13.tar.gz && \
|
|
|
|
cd libpng-1.5.13/ && \
|
|
|
|
./configure && \
|
|
|
|
make && sudo make install && \
|
|
|
|
apt install -y libltdl-dev graphviz libpng-dev libfftw3-dev && \
|
|
|
|
apt-get install -y libjpeg-turbo8-dev && \
|
|
|
|
apt install -y libgif-dev libjpeg-dev libopenexr-dev libpng-dev libwebp-dev && \
|
|
|
|
apt install -y cmake pkg-config libbrotli-dev && \
|
2022-07-12 02:55:17 +00:00
|
|
|
wget -nc https://imagemagick.org/archive/ImageMagick.tar.gz && \
|
2022-08-24 07:39:33 +00:00
|
|
|
tar xfz ImageMagick.tar.gz && \
|
2022-08-25 00:22:21 +00:00
|
|
|
cd /root/libpng-1.5.13/ImageMagick-7* && \
|
2022-08-24 06:57:54 +00:00
|
|
|
./configure --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes --disable-shared --with-modules && \
|
2022-02-09 10:48:06 +00:00
|
|
|
make && make install && \
|
|
|
|
ln -s /usr/local/lib/* /usr/lib/. && \
|
|
|
|
ln -s /usr/local/lib/pkgconfig/* /usr/lib/pkgconfig/. && \
|
2022-08-24 06:57:54 +00:00
|
|
|
ln -s /usr/local/bin/* /usr/bin/. && \
|
|
|
|
convert -list configure"
|
2022-03-09 16:44:14 +00:00
|
|
|
cd $tmp_pwd
|
2022-08-24 07:39:33 +00:00
|
|
|
if [[ "$remove_1_dir" == "1" ]]; then
|
|
|
|
rm -rf 1/
|
|
|
|
fi
|
2022-02-09 10:48:06 +00:00
|
|
|
fi
|
2022-02-09 11:26:06 +00:00
|
|
|
## install rvm
|
2022-02-09 10:48:06 +00:00
|
|
|
if [ -z $(which rvm) ]; then
|
2022-02-15 04:59:49 +00:00
|
|
|
sudo apt-get install --reinstall ca-certificates -y
|
2022-02-09 10:48:06 +00:00
|
|
|
sudo apt-add-repository -y ppa:rael-gc/rvm
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install rvm -y
|
|
|
|
sudo usermod -a -G rvm $USER
|
|
|
|
echo 'source "/etc/profile.d/rvm.sh"' >> ~/.bashrc
|
|
|
|
source "/etc/profile.d/rvm.sh"
|
|
|
|
sudo chown $USER:$USER $HOME -R
|
|
|
|
rvm user gemsets
|
2022-02-09 11:26:06 +00:00
|
|
|
sudo chown $USER:$USER /usr/share/rvm -R
|
2022-02-09 10:48:06 +00:00
|
|
|
fi
|
2022-02-09 11:26:06 +00:00
|
|
|
source "/etc/profile.d/rvm.sh"
|
2022-08-24 09:22:55 +00:00
|
|
|
# install ruby 2.7.6
|
2022-09-15 08:09:44 +00:00
|
|
|
if [[ -z "$openssl_dir" ]]; then
|
2023-11-19 08:00:57 +00:00
|
|
|
rvm install 2.7.6 --with-jemalloc
|
2022-09-15 08:09:44 +00:00
|
|
|
else
|
2024-01-28 04:20:07 +00:00
|
|
|
export CPPFLAGS="-I$openssl_dir/include"
|
|
|
|
export LDFLAGS="-L$openssl_dir/lib"
|
|
|
|
rvm install 2.7.6 -- --with-openssl-dir="$openssl_dir" --with-jemalloc
|
2022-09-15 08:09:44 +00:00
|
|
|
fi
|
2022-08-24 09:22:55 +00:00
|
|
|
rvm --default use 2.7.6
|
2022-09-15 08:09:44 +00:00
|
|
|
gem install bundler -v 2.1.4
|
2022-03-06 08:27:38 +00:00
|
|
|
gem install zip
|
2022-08-24 09:22:55 +00:00
|
|
|
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
|
2022-02-09 10:48:06 +00:00
|
|
|
sudo apt-get install screen -y
|
2022-02-09 09:59:50 +00:00
|
|
|
sudo sed -i 's/#cron\.\*/cron\.\*/g' /etc/rsyslog.d/50-default.conf
|
|
|
|
sudo service rsyslog restart
|
|
|
|
sudo mkdir /home/backup/db/ -p
|
|
|
|
sudo mkdir /home/backup/orbit/ -p
|
|
|
|
sudo apt-get install rsnapshot -y
|
|
|
|
sudo sed -i 's/^[^#]etain/#retain/g' /etc/rsnapshot.conf
|
|
|
|
sudo sed -i 's/\(retain\tdelta\t3\)/\1\nretain\tdaily\t7/g' /etc/rsnapshot.conf
|
|
|
|
sudo sed -i 's/snapshot_root.*/snapshot_root\t\/home\/backup\/orbit/g' /etc/rsnapshot.conf
|
|
|
|
sudo sed -i 's/^\(backup\t.*\)/#\1/g' /etc/rsnapshot.conf
|
|
|
|
matched_backup_home=$(grep -P "backup\t$HOME" /etc/rsnapshot.conf|xargs)
|
|
|
|
if [ -z $matched_backup_home ]; then
|
2023-10-03 13:45:45 +00:00
|
|
|
sudo sed -i "$(echo "s/^\(#backup\t\/home\/\t\)/backup\t$(echo $HOME|sed 's/\//\\\//g')\tlocalhost\/\texclude=.rvm\n\1/g")" /etc/rsnapshot.conf
|
2022-03-19 02:56:28 +00:00
|
|
|
else
|
|
|
|
matched_backup_home=$(grep -P "(^|\s+)backup\t$HOME" /etc/rsnapshot.conf|xargs)
|
|
|
|
if [ -z $matched_backup_home ]; then
|
2023-10-03 13:45:45 +00:00
|
|
|
sudo sed -i "$(echo "s/[#\s\t]*backup\t$(echo $HOME|sed 's/\//\\\//g')\t\([^ \t]\+\).*/backup\t$(echo $HOME|sed 's/\//\\\//g')\t\1\texclude=.rvm/g")" /etc/rsnapshot.conf
|
2022-03-19 02:56:28 +00:00
|
|
|
fi
|
2022-02-09 09:59:50 +00:00
|
|
|
fi
|
2022-02-09 10:48:06 +00:00
|
|
|
sudo wget -nc http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/orbit_logrotate -O /etc/logrotate.d/orbit
|
2022-02-09 09:59:50 +00:00
|
|
|
sudo sed -i "s/rulingcom/$USER/g" /etc/logrotate.d/orbit
|
|
|
|
sudo logrotate -d /etc/logrotate.conf
|
|
|
|
sudo /usr/sbin/logrotate -f /etc/logrotate.conf
|
2022-02-09 10:48:06 +00:00
|
|
|
sudo wget -nc http://gitlab.tp.rulingcom.com/erictyl/install_r45_on_ubuntu_1804lts_doc/-/raw/master/orbit_service.sh -O /etc/init.d/orbit
|
2022-02-09 09:59:50 +00:00
|
|
|
sudo sed -i "s/ORBIT_USER=.*/ORBIT_USER=$USER/g" /etc/init.d/orbit
|
|
|
|
sudo chmod 755 /etc/init.d/orbit
|
|
|
|
sudo update-rc.d orbit defaults
|
|
|
|
sudo systemctl enable mongod.service
|
|
|
|
sudo_crontab_jobs=$(sudo crontab -l)
|
2022-02-09 10:48:06 +00:00
|
|
|
if [[ "$sudo_crontab_jobs" =~ "@reboot /bin/bash -l -c" ]]; then
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Already exist reboot crontab!"
|
2022-02-09 09:59:50 +00:00
|
|
|
else
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Adding reboot crontab!"
|
2022-08-25 09:45:31 +00:00
|
|
|
echo "$sudo_crontab_jobs"$'\n''@reboot /bin/bash -l -c "rm -f /tmp/mongodb-27017.sock && chown mongodb:mongodb /var/lib/mongodb/ -R && chown mongodb:mongodb /var/log/mongodb -R && /usr/sbin/service mongod restart && /etc/init.d/orbit restart"'| sudo crontab -
|
2022-02-09 09:59:50 +00:00
|
|
|
fi
|
|
|
|
sudo_crontab_jobs=$(sudo crontab -l)
|
2022-02-09 10:48:06 +00:00
|
|
|
if [[ "$sudo_crontab_jobs" =~ "mongodump -o /" ]]; then
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Already exist mongodump crontab!"
|
2022-02-09 09:59:50 +00:00
|
|
|
else
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Adding mongodump crontab!"
|
2022-08-25 09:45:31 +00:00
|
|
|
echo "$sudo_crontab_jobs"$'\n''0 3 * * * mongodump -o /home/backup/db/`date "+\%Y\%m\%d"`_db'| sudo crontab -
|
2022-02-09 09:59:50 +00:00
|
|
|
fi
|
|
|
|
sudo_crontab_jobs=$(sudo crontab -l)
|
2022-02-09 10:48:06 +00:00
|
|
|
if [[ `echo "$sudo_crontab_jobs" | grep -P "rm -fr.*/db/"` ]]; then
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Already exist remove old mongo backup crontab!"
|
2022-02-09 09:59:50 +00:00
|
|
|
else
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Adding remove old mongo backup crontab!"
|
2022-08-25 09:45:31 +00:00
|
|
|
echo "$sudo_crontab_jobs"$'\n''0 4 * * * rm -fr /home/backup/db/`date --date="1 week ago" "+\%Y\%m\%d"`_db'| sudo crontab -
|
2022-02-09 09:59:50 +00:00
|
|
|
fi
|
|
|
|
sudo_crontab_jobs=$(sudo crontab -l)
|
2022-02-09 10:48:06 +00:00
|
|
|
if [[ "$sudo_crontab_jobs" =~ "/usr/bin/rsnapshot" ]]; then
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Already exist rsnapshot crontab!"
|
2022-02-09 09:59:50 +00:00
|
|
|
else
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Adding rsnapshot crontab!"
|
2022-08-25 09:45:31 +00:00
|
|
|
echo "$sudo_crontab_jobs"$'\n''15 4 * * * /usr/bin/rsnapshot daily'| sudo crontab -
|
2022-02-09 09:59:50 +00:00
|
|
|
fi
|
2022-08-25 01:39:48 +00:00
|
|
|
push_messages "Finish setting orbit environment!"
|
|
|
|
push_messages "Please install orbit web app and setting nginx for single web by yourself!"
|
|
|
|
push_messages "You can use the following command to create web!"
|
|
|
|
push_messages "$ sudo /etc/init.d/orbit create \$site_path"
|
|
|
|
push_messages "Ex: sudo /etc/init.d/orbit create orbit_sites/orbit"
|
|
|
|
push_messages "Ex: sudo /etc/init.d/orbit create /home/rulingcom/orbit_sites/orbit"
|
|
|
|
write_messages
|