Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/scripts/install/ubuntu.sh

209 lines
5.6 KiB

3 years ago
#!/bin/bash
2 years ago
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
3 years ago
export PATH
3 years ago
export LANG=en_US.UTF-8
export DEBIAN_FRONTEND=noninteractive
3 years ago
7 months ago
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; }
function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; }
3 years ago
if grep -Eq "Ubuntu" /etc/*-release; then
3 years ago
sudo ln -sf /bin/bash /bin/sh
#sudo dpkg-reconfigure dash
fi
7 months ago
# synchronize server
7 months ago
# systemctl status chronyd -l
7 months ago
apt install chrony -y
apt install ntpdate -y
3 years ago
apt update -y
11 months ago
apt autoremove -y
3 years ago
3 years ago
apt install -y wget curl lsof unzip
2 years ago
apt install -y rar unrar
3 years ago
apt install -y python3-pip
apt install -y python3-venv
3 years ago
apt install -y python3-dev
apt install -y expect
1 year ago
apt install -y pv
12 months ago
apt install -y bc
3 years ago
apt install -y cron
11 months ago
apt install -y net-tools
11 months ago
apt install -y libncurses5
apt install -y libncurses5-dev
11 months ago
apt install -y software-properties-common
10 months ago
apt install -y bzip2
2 years ago
7 months ago
P_VER=`python3 -V | awk '{print $2}'`
if version_ge "$P_VER" "3.11.0" ;then
echo -e "\e[1;31mapt install python3.12-venv\e[0m"
apt install -y python3.12-venv
fi
10 months ago
# choose lang cmd
# dpkg-reconfigure --frontend=noninteractive locales
# dpkg-reconfigure locales
if [ ! -f /usr/sbin/locale-gen ];then
apt install -y locales
sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen
locale-gen en_US.UTF-8
locale-gen zh_CN.UTF-8
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 > /dev/null 2>&1
update-locale LANG=en_US.UTF-8
else
locale-gen en_US.UTF-8
locale-gen zh_CN.UTF-8
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 > /dev/null 2>&1
fi
3 years ago
SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'`
if [ "$SSH_PORT" == "" ];then
SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1`
SSH_PORT=${SSH_PORT_LINE/"Port "/""}
fi
2 years ago
echo "SSH PORT:${SSH_PORT}"
3 years ago
2 years ago
if [ -f /usr/sbin/ufw ];then
# look
# ufw status
5 months ago
echo 'y' | ufw enable
2 years ago
if [ "$SSH_PORT" != "" ];then
ufw allow $SSH_PORT/tcp
else
ufw allow 22/tcp
fi
ufw allow 80/tcp
ufw allow 443/tcp
1 year ago
ufw allow 443/udp
# ufw allow 888/tcp
2 years ago
fi
3 years ago
2 years ago
if [ ! -f /usr/sbin/ufw ];then
3 years ago
apt install -y firewalld
systemctl enable firewalld
3 years ago
2 years ago
if [ "$SSH_PORT" != "" ];then
firewall-cmd --permanent --zone=public --add-port=${SSH_PORT}/tcp
else
firewall-cmd --permanent --zone=public --add-port=22/tcp
fi
2 years ago
3 years ago
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp
11 months ago
firewall-cmd --permanent --zone=public --add-port=443/udp
# firewall-cmd --permanent --zone=public --add-port=888/tcp
3 years ago
systemctl start firewalld
3 years ago
# fix:debian10 firewalld faq
# https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled/fang-huo-qiang#debian-10-firewalld-0.6.3-error-commandfailed-usrsbinip6tablesrestorewn-failed-ip6tablesrestore-v1.8
sed -i 's#IndividualCalls=no#IndividualCalls=yes#g' /etc/firewalld/firewalld.conf
3 years ago
firewall-cmd --reload
# #安装时不开启
# systemctl stop firewalld
3 years ago
fi
apt install -y devscripts
apt install -y python3-dev
apt install -y autoconf
apt install -y gcc
2 years ago
apt install -y lrzsz
apt install -y libffi-dev
apt install -y cmake automake make
apt install -y webp scons
apt install -y libwebp-dev
apt install -y lzma lzma-dev
apt install -y libunwind-dev
apt install -y libpcre3 libpcre3-dev
apt install -y openssl
apt install -y libssl-dev
2 years ago
apt install -y libargon2-dev
apt install -y libmemcached-dev
apt install -y libsasl2-dev
apt install -y imagemagick
apt install -y libmagickwand-dev
apt install -y libxml2 libxml2-dev libbz2-dev libmcrypt-dev libpspell-dev librecode-dev
apt install -y libgmp-dev libgmp3-dev libreadline-dev libxpm-dev
7 months ago
apt install -y libpq-dev
2 years ago
apt install -y dia
apt install -y pkg-config
apt install -y zlib1g-dev
2 years ago
apt install -y libjpeg-dev libpng-dev
apt install -y libfreetype6
apt install -y libjpeg62-turbo-dev
apt install -y libfreetype6-dev
11 months ago
apt install -y libevent-dev libldap2-dev
2 years ago
apt install -y libzip-dev
apt install -y libicu-dev
2 years ago
apt install -y libyaml-dev
2 years ago
# mqtt
apt install -y xsltproc
apt install -y build-essential
apt install -y libcurl4-openssl-dev
apt install -y libcurl4-nss-dev
apt install -y curl libcurl4-gnutls-dev
#https://blog.csdn.net/qq_36228377/article/details/123154344
# ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
if [ ! -d /usr/include/curl ];then
SYS_ARCH=`arch`
if [ -f /usr/include/x86_64-linux-gnu/curl ];then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
else
2 years ago
# ln -s /usr/include/aarch64-linux-gnu/curl /usr/include/curl
ln -s /usr/include/${SYS_ARCH}-linux-gnu/curl /usr/include/curl
fi
fi
apt install -y graphviz bison re2c flex
apt install -y libsqlite3-dev
apt install -y libonig-dev
apt install -y perl g++ libtool
apt install -y libxslt1-dev
apt install -y libmariadb-dev
#apt install -y libmysqlclient-dev
apt install -y libmariadb-dev-compat
#apt install -y libmariadbclient-dev
3 years ago
3 years ago
# mysql8.0 在ubuntu22需要的库
apt install -y patchelf
3 years ago
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
3 years ago
if [ "${VERSION_ID}" == "22.04" ];then
3 years ago
apt install -y python3-cffi
3 years ago
pip3 install -U --force-reinstall --no-binary :all: gevent
fi
3 years ago
cd /www/server/mdserver-web/scripts && bash lib.sh
chmod 755 /www/server/mdserver-web/data
3 years ago
if [ "${VERSION_ID}" == "22.04" ];then
3 years ago
apt install -y python3-cffi
3 years ago
pip3 install -U --force-reinstall --no-binary :all: gevent
fi