This commit is contained in:
condor
2026-07-24 18:54:53 +08:00
parent 43c2a411b9
commit 679e0b4184
128 changed files with 13855 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://linuxeye.com
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
# check MySQL dir
[ -d "${mysql_install_dir}/support-files" ] && { db_install_dir=${mysql_install_dir}; db_data_dir=${mysql_data_dir}; }
[ -d "${mariadb_install_dir}/support-files" ] && { db_install_dir=${mariadb_install_dir}; db_data_dir=${mariadb_data_dir}; }
# check Nginx dir
[ -e "${nginx_install_dir}/sbin/nginx" ] && web_install_dir=${nginx_install_dir}
+429
View File
@@ -0,0 +1,429 @@
#!/bin/bash
# Author: Alpha Eva <kaneawk AT gmail.com>
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
checkDownload() {
mirrorLink=https://lnmp.52or.com/src
pushd ${oneinstack_dir}/src > /dev/null
# icu
if ! command -v icu-config >/dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then
echo "Download icu..."
src_url=${mirrorLink}/icu/icu4c-${icu4c_ver}-src.tgz && Download_src
fi
# General system utils
if [ "${with_old_openssl_flag}" == 'y' ]; then
echo "Download openSSL..."
src_url=${mirrorLink}/utils/openssl-${openssl_ver}.tar.gz && Download_src
echo "Download cacert.pem..."
src_url=${mirrorLink}/utils/cacert.pem && Download_src
fi
# openssl1.1
if [[ ${nginx_option} =~ ^[1]$ ]]; then
echo "Download openSSL1.1..."
src_url=${mirrorLink}/utils/openssl-${openssl11_ver}.tar.gz && Download_src
fi
# jemalloc
if [[ ${nginx_option} =~ ^[1]$ ]] || [[ "${db_option}" =~ ^[1-9]$ ]]; then
echo "Download jemalloc..."
src_url=${mirrorLink}/utils/jemalloc-${jemalloc_ver}.tar.bz2 && Download_src
fi
# nginx
case "${nginx_option}" in
1)
echo "Download nginx..."
src_url=${mirrorLink}/nginx/nginx-${nginx_ver}.tar.gz && Download_src
src_url=${mirrorLink}/nginx/nginx-rtmp-module.tar.gz && Download_src
src_url=${mirrorLink}/nginx/ngx-fancyindex-${fancyindex_ver}.tar.xz && Download_src
;;
esac
# pcre
if [[ "${nginx_option}" =~ ^[1]$ ]]; then
echo "Download pcre..."
src_url=${mirrorLink}/nginx/pcre-${pcre_ver}.tar.gz && Download_src
fi
if [[ "${db_option}" =~ ^[1-9]$ ]]; then
if [[ "${db_option}" =~ ^[1,2,3,4,5]$ ]] && [ "${dbinstallmethod}" == "2" ]; then
[[ "${db_option}" =~ ^[2,3,4,5]$ ]] && boost_ver=${boost_oldver}
echo "Download boost..."
[ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_BOOST=${mirrorLink} || DOWN_ADDR_BOOST=https://downloads.sourceforge.net/project/boost/boost/${boost_ver}
boostVersion2=$(echo ${boost_ver} | awk -F. '{print $1"_"$2"_"$3}')
src_url=${mirrorLink}/boost/boost_${boostVersion2}.tar.gz && Download_src
fi
case "${db_option}" in
1)
# MySQL 8.0
if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
DOWN_ADDR_MYSQL=${mirrorLink}/mysql/mysql-8.0
DOWN_ADDR_MYSQL_BK=http://repo.huaweicloud.com/mysql/Downloads/MySQL-8.0
DOWN_ADDR_MYSQL_BK2=http://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0
else
DOWN_ADDR_MYSQL=${mirrorLink}/mysql/mysql-8.0
DOWN_ADDR_MYSQL_BK=https://cdn.mysql.com/Downloads/MySQL-8.0
fi
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download MySQL 8.0 binary package..."
FILE_NAME=mysql-${mysql80_ver}-linux-glibc2.12-x86_64.tar.xz
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download MySQL 8.0 source package..."
FILE_NAME=mysql-${mysql80_ver}.tar.gz
fi
# start download
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src
# verifying download
MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
2)
# MySQL 5.7
if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
DOWN_ADDR_MYSQL=${mirrorLink}/mysql/mysql-5.7
DOWN_ADDR_MYSQL_BK=https://cdn.mysql.com/Downloads/MySQL-5.7
DOWN_ADDR_MYSQL_BK2=http://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7
else
DOWN_ADDR_MYSQL=${mirrorLink}/mysql/mysql-5.7
DOWN_ADDR_MYSQL_BK=https://cdn.mysql.com/Downloads/MySQL-5.7
fi
if [ "${dbinstallmethod}" == '1' ]; then
echo "Download MySQL 5.7 binary package..."
FILE_NAME=mysql-${mysql57_ver}-linux-glibc2.12-x86_64.tar.gz
elif [ "${dbinstallmethod}" == '2' ]; then
echo "Download MySQL 5.7 source package..."
FILE_NAME=mysql-${mysql57_ver}.tar.gz
fi
# start download
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5 && Download_src
# verifying download
MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MYSQL_TAR_MD5}" ] && MYSQL_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
3)
mariadb_ver=${mariadb1011_ver}
if [ "${dbinstallmethod}" == '1' ]; then
FILE_NAME=mariadb-${mariadb_ver}-linux-systemd-x86_64.tar.gz
FILE_TYPE=bintar-linux-systemd-x86_64
elif [ "${dbinstallmethod}" == '2' ]; then
FILE_NAME=mariadb-${mariadb_ver}.tar.gz
FILE_TYPE=source
fi
DOWN_ADDR_MARIADB=${mirrorLink}/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
DOWN_ADDR_MARIADB_BK=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
echo "Download MariaDB ${FILE_NAME} package..."
src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src
wget --tries=6 --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MARIADB}/md5sums.txt -O ${FILE_NAME}.md5
MARAIDB_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MARAIDB_TAR_MD5}" ] && MARAIDB_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_MARIADB_BK}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
4)
mariadb_ver=${mariadb118_ver}
if [ "${dbinstallmethod}" == '1' ]; then
FILE_NAME=mariadb-${mariadb_ver}-linux-systemd-x86_64.tar.gz
FILE_TYPE=bintar-linux-systemd-x86_64
elif [ "${dbinstallmethod}" == '2' ]; then
FILE_NAME=mariadb-${mariadb_ver}.tar.gz
FILE_TYPE=source
fi
DOWN_ADDR_MARIADB=${mirrorLink}/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
DOWN_ADDR_MARIADB_BK=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
echo "Download MariaDB ${FILE_NAME} package..."
src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src
wget --tries=6 --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MARIADB}/md5sums.txt -O ${FILE_NAME}.md5
MARAIDB_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MARAIDB_TAR_MD5}" ] && MARAIDB_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_MARIADB_BK}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
5)
mariadb_ver=${mariadb123_ver}
if [ "${dbinstallmethod}" == '1' ]; then
FILE_NAME=mariadb-${mariadb_ver}-linux-systemd-x86_64.tar.gz
FILE_TYPE=bintar-linux-systemd-x86_64
elif [ "${dbinstallmethod}" == '2' ]; then
FILE_NAME=mariadb-${mariadb_ver}.tar.gz
FILE_TYPE=source
fi
DOWN_ADDR_MARIADB=${mirrorLink}/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
DOWN_ADDR_MARIADB_BK=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_ver}/${FILE_TYPE}
echo "Download MariaDB ${FILE_NAME} package..."
src_url=${DOWN_ADDR_MARIADB}/${FILE_NAME} && Download_src
wget --tries=6 --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MARIADB}/md5sums.txt -O ${FILE_NAME}.md5
MARAIDB_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MARAIDB_TAR_MD5}" ] && MARAIDB_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_MARIADB_BK}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MARIADB_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
6)
pgsql_ver=${pgsql1514_ver}
FILE_NAME=postgresql-${pgsql_ver}.tar.gz
DOWN_ADDR_PGSQL=${mirrorLink}/pgsql
DOWN_ADDR_PGSQL_BK=https://ftp.postgresql.org/pub/source/v${pgsql_ver}
src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME}.md5 && Download_src
PGSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${PGSQL_TAR_MD5}" ] && PGSQL_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PGSQL_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PGSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
7)
pgsql_ver=${pgsql1610_ver}
FILE_NAME=postgresql-${pgsql_ver}.tar.gz
DOWN_ADDR_PGSQL=${mirrorLink}/pgsql
DOWN_ADDR_PGSQL_BK=https://ftp.heanet.ie/mirrors/postgresql/source/v${pgsql_ver}
src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME}.md5 && Download_src
PGSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${PGSQL_TAR_MD5}" ] && PGSQL_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PGSQL_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PGSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
8)
pgsql_ver=${pgsql176_ver}
FILE_NAME=postgresql-${pgsql_ver}.tar.gz
DOWN_ADDR_PGSQL=${mirrorLink}/pgsql
DOWN_ADDR_PGSQL_BK=https://ftp.heanet.ie/mirrors/postgresql/source/v${pgsql_ver}
src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_PGSQL}/${FILE_NAME}.md5 && Download_src
PGSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${PGSQL_TAR_MD5}" ] && PGSQL_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PGSQL_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_PGSQL_BK}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PGSQL_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
9)
# MongoDB
echo "Download MongoDB binary package..."
FILE_NAME=mongodb-linux-x86_64-${mongodb_ver}.tgz
if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
DOWN_ADDR_MongoDB=${mirrorLink}/mongodb
else
DOWN_ADDR_MongoDB=https://fastdl.mongodb.org/linux
fi
src_url=${DOWN_ADDR_MongoDB}/${FILE_NAME} && Download_src
src_url=${DOWN_ADDR_MongoDB}/${FILE_NAME}.md5 && Download_src
MongoDB_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
[ -z "${MongoDB_TAR_MD5}" ] && MongoDB_TAR_MD5=$(curl -s --connect-timeout 15 --max-time 60 ${DOWN_ADDR_MongoDB}/${FILE_NAME}.md5 | grep ${FILE_NAME} | awk '{print $1}')
tryDlCount=0
while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MongoDB_TAR_MD5}" ]; do
wget --timeout=30 -c --no-check-certificate ${DOWN_ADDR_MongoDB}/${FILE_NAME};sleep 1
let "tryDlCount++"
[ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MongoDB_TAR_MD5}" -o "${tryDlCount}" == '6' ] && break || continue
done
if [ "${tryDlCount}" == '6' ]; then
echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
;;
esac
fi
# PHP
if [[ "${php_option}" =~ ^[1-3]$ ]] || [[ "${mphp_ver}" =~ ^7[0-4]$|^8[0-1]$ ]]; then
echo "PHP common..."
src_url=${mirrorLink}/php/libiconv-${libiconv_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/curl-${curl_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/mhash-${mhash_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/libmcrypt-${libmcrypt_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/mcrypt-${mcrypt_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/freetype-${freetype_ver}.tar.gz && Download_src
fi
if [ "${php_option}" == '1' ] || [ "${mphp_ver}" == '74' ]; then
src_url=${mirrorLink}/php/php-${php74_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/libsodium-${libsodium_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/libzip-${libzip_ver}.tar.gz && Download_src
elif [ "${php_option}" == '2' ] || [ "${mphp_ver}" == '80' ]; then
src_url=${mirrorLink}/php/php-${php80_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/libsodium-${libsodium_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/libzip-${libzip_ver}.tar.gz && Download_src
elif [ "${php_option}" == '3' ] || [ "${mphp_ver}" == '81' ]; then
src_url=${mirrorLink}/php/php-${php81_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/argon2-${argon2_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/libsodium-${libsodium_ver}.tar.gz && Download_src
src_url=${mirrorLink}/php/libzip-${libzip_ver}.tar.gz && Download_src
fi
# PHP OPCache
case "${phpcache_option}" in
1)
# Zend OPcache is built into PHP 7.4/8.0/8.1; nothing to download
;;
2)
echo "Download apcu..."
src_url=${mirrorLink}/php/apcu-${apcu_ver}.tgz && Download_src
;;
esac
# ioncube
if [ "${pecl_ioncube}" == '1' ]; then
echo "Download ioncube..."
src_url=${mirrorLink}/php/ioncube_loaders_lin_${SYS_ARCH_i}.tar.gz && Download_src
fi
# SourceGuardian
if [ "${pecl_sourceguardian}" == '1' ]; then
echo "Download SourceGuardian..."
src_url=${mirrorLink}/php/loaders.linux-${ARCH}.tar.gz && Download_src
fi
# imageMagick
if [ "${pecl_imagick}" == '1' ]; then
echo "Download ImageMagick..."
src_url=${mirrorLink}/php/ImageMagick-${imagemagick_ver}.tar.gz && Download_src
echo "Download imagick..."
src_url=${mirrorLink}/php/imagick-${imagick_ver}.tgz && Download_src
fi
# graphicsmagick
if [ "${pecl_gmagick}" == '1' ]; then
echo "Download graphicsmagick..."
src_url=${mirrorLink}/php/GraphicsMagick-${graphicsmagick_ver}.tar.gz && Download_src
echo "Download gmagick for php..."
src_url=${mirrorLink}/php/gmagick-${gmagick_ver}.tgz && Download_src
fi
# redis-server
if [ "${redis_flag}" == 'y' ]; then
echo "Download redis-server..."
src_url=${mirrorLink}/redis/redis-${redis_ver}.tar.gz && Download_src
if [ "${PM}" == 'yum' ]; then
echo "Download start-stop-daemon.c for RHEL..."
src_url=${mirrorLink}/redis/start-stop-daemon.c && Download_src
fi
fi
# pecl_redis
if [ "${pecl_redis}" == '1' ]; then
echo "Download pecl_redis for php..."
src_url=${mirrorLink}/redis/redis-${pecl_redis_ver}.tgz && Download_src
fi
# pecl_mongodb
if [ "${pecl_mongodb}" == '1' ]; then
echo "Download pecl mongo for php..."
src_url=${mirrorLink}/mongodb/mongo-${pecl_mongo_ver}.tgz && Download_src
echo "Download pecl mongodb for php..."
src_url=${mirrorLink}/mongodb/mongodb-${pecl_mongodb_ver}.tgz && Download_src
fi
# nodejs
if [ "${nodejs_flag}" == 'y' ]; then
echo "Download Nodejs..."
# [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_NODE=https://mirrors.tuna.tsinghua.edu.cn/nodejs-release || DOWN_ADDR_NODE=https://nodejs.org/dist
src_url=${mirrorLink}/node/node-v${nodejs_ver}-linux-${SYS_ARCH_n}.tar.gz && Download_src
fi
# pureftpd
if [ "${pureftpd_flag}" == 'y' ]; then
echo "Download pureftpd..."
src_url=${mirrorLink}/pureftpd/pure-ftpd-${pureftpd_ver}.tar.gz && Download_src
fi
# phpMyAdmin
if [ "${phpmyadmin_flag}" == 'y' ]; then
echo "Download phpMyAdmin..."
if [[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]]; then
src_url=${mirrorLink}/phpMyAdmin/phpMyAdmin-${phpmyadmin_oldver}-all-languages.tar.gz && Download_src
else
src_url=${mirrorLink}/phpMyAdmin/phpMyAdmin-${phpmyadmin_ver}-all-languages.tar.gz && Download_src
fi
fi
popd > /dev/null
}
+102
View File
@@ -0,0 +1,102 @@
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://linuxeye.com
#
# Notes: ServerStack for Debian 9-13 and Ubuntu 16-26 (Ubuntu/Debian only)
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
# Only Debian/Ubuntu (apt-get based) systems are supported.
if [ -e "/usr/bin/apt-get" ]; then
PM=apt-get
if ! command -v lsb_release >/dev/null 2>&1; then
echo "${CMSG}Updating apt package lists to install lsb-release...${CEND}"
apt-get -y update 2>&1 | tee -a ${oneinstack_dir}/runtime/install.log
apt-get -y install lsb-release
clear
fi
else
echo "${CFAILURE}Does not support this OS, Please install Debian 9+ or Ubuntu 16+ ${CEND}"
kill -9 $$; exit 1;
fi
# Get OS Version
Platform=$(lsb_release -is 2>/dev/null)
ARCH=$(arch)
if [[ "${Platform}" =~ ^Debian$|^Deepin$|^Uos$|^Kali$ ]]; then
Family=debian
Debian_ver=$(lsb_release -rs 2>/dev/null | awk -F. '{print $1}' | awk '{print $1}')
[[ "${Platform}" =~ ^Deepin$|^Uos$ ]] && [[ "${Debian_ver}" =~ ^20$ ]] && Debian_ver=10
[[ "${Platform}" =~ ^Kali$ ]] && [[ "${Debian_ver}" =~ ^202 ]] && Debian_ver=10
elif [[ "${Platform}" =~ ^Ubuntu$|^LinuxMint$|^elementary$ ]]; then
Family=ubuntu
Ubuntu_ver=$(lsb_release -rs 2>/dev/null | awk -F. '{print $1}' | awk '{print $1}')
if [[ "${Platform}" =~ ^LinuxMint$ ]]; then
[[ "${Ubuntu_ver}" =~ ^18$ ]] && Ubuntu_ver=16
[[ "${Ubuntu_ver}" =~ ^19$ ]] && Ubuntu_ver=18
[[ "${Ubuntu_ver}" =~ ^20$ ]] && Ubuntu_ver=20
fi
if [[ "${Platform}" =~ ^elementary$ ]]; then
[[ "${Ubuntu_ver}" =~ ^5$ ]] && Ubuntu_ver=18
[[ "${Ubuntu_ver}" =~ ^6$ ]] && Ubuntu_ver=20
fi
else
echo "${CFAILURE}Does not support this OS: ${Platform:-unknown}. Only Debian 9+ and Ubuntu 16+ are supported. ${CEND}"
kill -9 $$; exit 1;
fi
# Check OS Version
if [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -lt 16 >/dev/null 2>&1 ]; then
echo "${CFAILURE}Does not support this OS, Please install Debian 9+ or Ubuntu 16+ ${CEND}"
kill -9 $$; exit 1;
fi
command -v gcc > /dev/null 2>&1 || $PM -y install gcc
gcc_ver=$(gcc -dumpversion | awk -F. '{print $1}')
[ ${gcc_ver} -lt 5 >/dev/null 2>&1 ] && redis_ver=${redis_oldver}
if uname -m | grep -Eqi "arm|aarch64"; then
armplatform="y"
if uname -m | grep -Eqi "armv7"; then
TARGET_ARCH="armv7"
elif uname -m | grep -Eqi "armv8"; then
TARGET_ARCH="arm64"
elif uname -m | grep -Eqi "aarch64"; then
TARGET_ARCH="aarch64"
else
TARGET_ARCH="unknown"
fi
fi
if [ "$(uname -r | awk -F- '{print $3}' 2>/dev/null)" == "Microsoft" ]; then
Wsl=true
fi
if [ "$(getconf WORD_BIT)" == "32" ] && [ "$(getconf LONG_BIT)" == "64" ]; then
if [ "${TARGET_ARCH}" == 'aarch64' ]; then
SYS_ARCH=arm64
SYS_ARCH_i=aarch64
SYS_ARCH_n=arm64
else
SYS_ARCH=amd64
SYS_ARCH_i=x86-64 #ioncube
SYS_ARCH_n=x64 #nodejs
fi
else
echo "${CWARNING}32-bit OS are not supported! ${CEND}"
kill -9 $$; exit 1;
fi
THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
# sslLibVer selection for binary tarballs
if [ ${Debian_ver} -lt 9 >/dev/null 2>&1 ]; then
sslLibVer=ssl100
elif [ ${Debian_ver} -ge 9 >/dev/null 2>&1 ] || [ ${Ubuntu_ver} -ge 16 >/dev/null 2>&1 ]; then
sslLibVer=ssl102
else
sslLibVer=unknown
fi
+241
View File
@@ -0,0 +1,241 @@
#!/bin/bash
# Author: Alpha Eva <kaneawk AT gmail.com>
#
# Notes: ServerStack for Debian 9-13 and Ubuntu 16-26 (Ubuntu/Debian only)
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
# Filter out packages that do not exist in the configured apt sources.
# A single unavailable package name would otherwise abort the whole
# 'apt-get install' and leave every dependency (libsqlite3-dev, libssl-dev,
# libxml2-dev, ...) uninstalled -- which is exactly what breaks PHP's configure
# (the "Package 'sqlite3' ... not found" error). Modern Debian/Ubuntu removed
# several legacy package names (libjpeg8, libpng12-*, libcloog-ppl1, libidn11,
# ...) that are still listed below, so this guard keeps the install resilient.
filter_pkglist() {
local _avail="" _p
for _p in ${pkgList}; do
# Use `apt-cache policy` instead of `apt-cache show`: the latter returns a
# non-zero exit for *purely virtual* packages (e.g. libpng-dev, libjpeg-dev
# on modern Debian/Ubuntu), which would wrongly drop them and leave GD's
# libpng/libjpeg .pc files missing. `apt-cache policy` resolves virtual
# packages to their provider and reports a real candidate version.
if apt-cache policy "${_p}" 2>/dev/null | grep -qE 'Candidate: [0-9]'; then
_avail="${_avail} ${_p}"
else
echo "${CWARNING}Skip unavailable package: ${_p}${CEND}"
fi
done
pkgList="${_avail}"
# Resolve known MUTUAL conflicts inside the list. Unlike missing packages
# (handled above), these two packages both exist in apt but declare
# `Conflicts:` on each other, so a single `apt-get install A B` aborts with
# "Unable to correct problems, you have held broken packages" and leaves
# EVERY other dependency uninstalled -- which then breaks PHP's ./configure.
#
# libcurl4-gnutls-dev <-> libcurl4-openssl-dev
# Both provide libcurl4 headers under different TLS backends and are
# mutually exclusive on every supported Ubuntu/Debian release. All PHP
# build modules in this tree (modules/php/php-*.sh) link against the
# OpenSSL flavor, so we keep libcurl4-openssl-dev and drop the gnutls dev
# package. The non-dev runtime `libcurl3-gnutls` is NOT touched.
if echo "${pkgList}" | grep -qw 'libcurl4-gnutls-dev' \
&& echo "${pkgList}" | grep -qw 'libcurl4-openssl-dev'; then
pkgList="$(echo "${pkgList}" | sed -E 's/\blibcurl4-gnutls-dev\b//')"
echo "${CWARNING}Resolved libcurl dev conflict: dropped libcurl4-gnutls-dev, kept libcurl4-openssl-dev${CEND}"
fi
}
# Install the (already filtered) dependency packages.
# 'apt-get install' is transactional: if any single package in the list fails to
# install (dependency conflict, a pinned version that no longer exists, a flaky
# download, ...), apt rolls back the WHOLE operation and leaves every -dev
# package uninstalled. That in turn breaks PHP's ./configure (missing .pc files
# like sqlite3 / libcurl / libxml2). To stay resilient we try the fast batch
# install first and, on failure, fall back to installing each package on its own
# so one bad package can no longer block the rest.
#
# Why this used to "hang for a long time" at the libcurl conflict:
# 1. When the batch `apt-get install` is given two mutually-conflicting
# packages (libcurl4-gnutls-dev + libcurl4-openssl-dev), apt's dependency
# solver silently spends 30s~2min trying alternative resolutions before
# finally printing "Unable to correct problems, you have held broken
# packages" and returning non-zero. During that time there is NO output,
# so it looks like the script is frozen.
# 2. After the batch fails, the old fallback loop ran `apt-get install` once
# per package (~60 packages) with ALL output redirected to /dev/null, so
# the user saw a blank screen for several more minutes.
# Both are fixed below: (a) the known mutual conflict is stripped before apt
# is ever called, and (b) apt now runs non-interactively with its verbose
# output appended to runtime/install.log while the screen only shows concise
# status lines, so the flow is neither silent nor noisy.
install_pkgs() {
# Defense in depth: strip the known libcurl dev conflict here too, in case
# filter_pkglist() was bypassed or pkgList was mutated between filter and
# install. This guarantees the batch install below cannot abort on that
# specific conflict (which is the #1 cause of the long "hang").
if echo "${pkgList}" | grep -qw 'libcurl4-gnutls-dev' \
&& echo "${pkgList}" | grep -qw 'libcurl4-openssl-dev'; then
pkgList="$(echo "${pkgList}" | sed -E 's/\blibcurl4-gnutls-dev\b//')"
echo "${CWARNING}Resolved libcurl dev conflict: dropped libcurl4-gnutls-dev, kept libcurl4-openssl-dev${CEND}"
fi
# apt runs fully non-interactively (-y + DEBIAN_FRONTEND=noninteractive) so it
# never stops on a debconf prompt (a common cause of the flow "hanging"). The
# verbose apt download/configure output is NOT dumped to the terminal; instead
# it is appended to runtime/install.log, and the screen shows only concise
# status lines. This keeps the console readable while preserving a complete,
# greppable install log for troubleshooting.
local _log="${oneinstack_dir:-.}/runtime/install.log"
export DEBIAN_FRONTEND=noninteractive
# Fast path: try to install everything in one apt invocation. This is by far
# the fastest when there are no conflicts, because apt resolves the whole
# dependency graph once instead of N times.
echo "${CMSG}Installing dependency packages (apt-get -y, full output -> ${_log}) ...${CEND}"
if apt-get --no-install-recommends -y install ${pkgList} >> "${_log}" 2>&1; then
echo "${CSUCCESS}All dependency packages installed successfully.${CEND}"
return 0
fi
# Slow path: batch failed for some reason (unexpected conflict, flaky mirror,
# ...). Install each package individually so one bad package cannot block the
# rest. Each package still installs silently via apt-get -y (output appended
# to the log), but a per-package status line is printed so the screen is never
# blank and every package's outcome (OK / FAILED) is explicit.
echo "${CWARNING}Batch dependency install failed, retrying package-by-package (details -> ${_log}) ...${CEND}"
local _p
for _p in ${pkgList}; do
printf '%s -> %-40s ...%s' "${CMSG}" "${_p}" "${CEND}"
if apt-get --no-install-recommends -y install "${_p}" >> "${_log}" 2>&1; then
printf ' %sOK%s\n' "${CSUCCESS}" "${CEND}"
else
printf ' %sFAILED%s\n' "${CFAILURE}" "${CEND}"
fi
done
}
installDepsDebian() {
echo "${CMSG}Removing the conflicting packages...${CEND}"
if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common"
for Package in ${pkgList};do
apt-get -y purge ${Package}
done
dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
fi
echo "${CMSG}Installing dependencies packages...${CEND}"
apt-get -y update
apt-get -y autoremove
apt-get -yf install
export DEBIAN_FRONTEND=noninteractive
# critical security updates
grep security /etc/apt/sources.list > /tmp/security.sources.list
apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
# Install needed packages
case "${Debian_ver}" in
8)
pkgList="debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg8 libjpeg62-turbo-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libgd-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl net-tools libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libxslt-dev libicu-dev locales libcloog-ppl0 patch vim zip unzip tmux htop bc dc expect libexpat1-dev libonig-dev libtirpc-dev nss rsync git lsof lrzsz iptables rsyslog cron logrotate chrony ntpdate libsqlite3-dev psmisc wget sysv-rc apt-transport-https ca-certificates software-properties-common gnupg"
;;
# Debian 13 (trixie) reuses the Debian 12 list. Any package-name drift
# versus 12 (e.g. libidn11 removal in favour of libidn2) is automatically
# absorbed by filter_pkglist(), which drops packages with no apt candidate
# instead of failing the whole install.
9|10|11|12|13)
pkgList="debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg62-turbo-dev libjpeg-dev libpng-dev libgd-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl net-tools libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales patch vim zip unzip tmux htop bc dc expect libexpat1-dev libonig-dev libtirpc-dev rsync git lsof lrzsz iptables rsyslog cron logrotate chrony ntpdate libsqlite3-dev psmisc wget sysv-rc apt-transport-https ca-certificates software-properties-common gnupg"
;;
*)
echo "${CFAILURE}Your system Debian ${Debian_ver} are not supported!${CEND}"
kill -9 $$; exit 1;
;;
esac
# Install all dependency packages in a single apt invocation (fast path);
# install_pkgs() falls back to per-package on failure so one bad package
# cannot block the rest.
filter_pkglist
install_pkgs
}
installDepsUbuntu() {
# Uninstall the conflicting software
echo "${CMSG}Removing the conflicting packages...${CEND}"
if [[ "${db_option}" =~ ^[1-9]$|^1[0-2]$ ]]; then
pkgList="mysql-client mysql-server mysql-common mysql-server-core-5.5 mysql-client-5.5 mariadb-client mariadb-server mariadb-common"
for Package in ${pkgList};do
apt-get -y purge ${Package}
done
dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
fi
echo "${CMSG}Installing dependencies packages...${CEND}"
apt-get -y update
apt-get -y autoremove
apt-get -yf install
export DEBIAN_FRONTEND=noninteractive
[[ "${Ubuntu_ver}" =~ ^22$ ]] && apt-get -y --allow-downgrades install libicu70=70.1-2 libglib2.0-0=2.72.1-1 libxml2-dev
# critical security updates
grep security /etc/apt/sources.list > /tmp/security.sources.list
apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
# Install needed packages
# NOTE on the libcurl entries:
# * `libcurl3-gnutls` is the shared runtime (non-dev) and is harmless to keep.
# * `libcurl4-gnutls-dev` and `libcurl4-openssl-dev` are MUTUALLY EXCLUSIVE on
# every supported Ubuntu release: they provide competing flavors of
# libcurl4 headers and the two -dev packages declare a Conflicts: on each
# other. Listing both in a single apt invocation makes
# `apt-get install` abort with
# "libcurl4-gnutls-dev : Conflicts: libcurl4-openssl-dev ..."
# and leaves every other dependency uninstalled, which then breaks
# PHP's ./configure (missing libcurl.pc, libxml2, sqlite3, ...).
# * All PHP build modules (modules/php/php-*.sh) and every other consumer
# in this tree link against the OpenSSL flavor, so we keep
# `libcurl4-openssl-dev` and drop the gnutls dev package here.
# The following legacy names are also removed from this Ubuntu list because
# they have been dropped from current Ubuntu releases and are now permanently
# filtered out by filter_pkglist (which still leaves them as noisy "Skip
# unavailable" warnings on every run):
# libjpeg62-turbo-dev -- only present up through 22.04
# libpng12-0 / libpng12-dev / libpng3 -- superseded by libpng16-16 / libpng-dev
# libidn11 -- superseded by libidn2-0
# libcloog-ppl1 -- removed since gcc dropped PPL/CLooG
# sysv-rc -- replaced by systemd
pkgList="libperl-dev debian-keyring debian-archive-keyring build-essential gcc g++ make cmake autoconf libjpeg-dev libpng-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libc-client2007e-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev numactl libreadline-dev curl libcurl3-gnutls libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11-dev openssl net-tools libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev libicu-dev libsqlite3-dev bison patch vim zip unzip tmux htop bc dc expect libexpat1-dev iptables rsyslog libonig-dev libtirpc-dev libnss3 rsync git lsof lrzsz chrony ntpdate psmisc wget apt-transport-https ca-certificates software-properties-common gnupg"
export DEBIAN_FRONTEND=noninteractive
# Install all dependency packages in a single apt invocation (fast path);
# install_pkgs() falls back to per-package on failure so one bad package
# cannot block the rest.
filter_pkglist
install_pkgs
}
installDepsBySrc() {
pushd ${oneinstack_dir}/src > /dev/null
if ! command -v icu-config > /dev/null 2>&1 || icu-config --version | grep '^3.' || [ "${Ubuntu_ver}" == "20" ]; then
echo "${CMSG}>> Installing: ICU ${icu4c_ver} (compiling from source)${CEND}"
tar xzf icu4c-${icu4c_ver}-src.tgz
pushd icu/source > /dev/null
./configure --prefix=/usr/local
make -j ${THREAD} && make install
popd > /dev/null
rm -rf icu
fi
if command -v lsof >/dev/null 2>&1; then
echo 'already initialize' > ~/.oneinstack
else
echo "${CFAILURE}${PM} config error parsing file failed${CEND}"
kill -9 $$; exit 1;
fi
popd > /dev/null
}
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://linuxeye.com
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
echo=echo
for cmd in echo /bin/echo; do
$cmd >/dev/null 2>&1 || continue
if ! $cmd -e "" | grep -qE '^-e'; then
echo=$cmd
break
fi
done
CSI=$($echo -e "\033[")
CEND="${CSI}0m"
CDGREEN="${CSI}32m"
CRED="${CSI}1;31m"
CGREEN="${CSI}1;32m"
CYELLOW="${CSI}1;33m"
CBLUE="${CSI}1;34m"
CMAGENTA="${CSI}1;35m"
CCYAN="${CSI}1;36m"
CSUCCESS="$CDGREEN"
CFAILURE="$CRED"
CQUESTION="$CMAGENTA"
CWARNING="$CYELLOW"
CMSG="$CCYAN"
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://linuxeye.com
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
Download_src() {
if [ -s "${src_url##*/}" ]; then
echo "[${CMSG}${src_url##*/}${CEND}] found"
elif [ "${OFFLINE}" == '1' ]; then
# Offline mode: never touch the network. Fail clearly so the missing
# package can be added to the offline src/ set.
echo "${CFAILURE}Offline mode: ${src_url##*/} not found in src/. Add it to the offline package set and retry.${CEND}"
kill -9 $$; exit 1;
else
# --timeout caps DNS/connect/read at 30s so a dead mirror can't hang for ~90 min;
# --tries=3 keeps a couple of retries without the old 6x15min worst case.
wget --limit-rate=100M --timeout=30 --tries=3 -c --no-check-certificate ${src_url}; sleep 1
fi
if [ ! -e "${src_url##*/}" ]; then
echo "${CFAILURE}Auto download failed! You can manually download ${src_url} into the oneinstack/src directory.${CEND}"
kill -9 $$; exit 1;
fi
}
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://linuxeye.com
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
get_char() {
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
+73
View File
@@ -0,0 +1,73 @@
#!/bin/bash
# lib/loader.sh - common header loading and module sourcing utilities.
#
# Centralises the "public header" that every entry script used to repeat, and
# provides guarded, consistent module sourcing so all modules are referenced by
# their project-root-relative path (e.g. "modules/web/nginx.sh", "lib/color.sh").
# Guard set of already-sourced modules (prevents double-sourcing side effects,
# e.g. init_*.sh which execute at top level).
# Resolve the project root from this file's own location. This makes every
# sourced path absolute and cwd-independent, fixing "No such file or directory"
# when the entry script is invoked from a directory other than the project root.
# readlink -f canonicalises to an absolute path (symlink/cwd safe); the fallback
# keeps it working on systems without readlink -f. loader.sh always lives at
# <root>/lib/loader.sh, so <root> = dirname(dirname(this_file)).
_ONEINSTACK_THIS="$(readlink -f "${BASH_SOURCE[0]}" 2>/dev/null || echo "${BASH_SOURCE[0]}")"
_ONEINSTACK_LIB_DIR="$(cd "$(dirname "${_ONEINSTACK_THIS}")" && pwd)"
oneinstack_dir="$(cd "${_ONEINSTACK_LIB_DIR}/.." && pwd)"
export oneinstack_dir
_LOADED_MODULES=""
# Source a module file exactly once.
# $1 = module path relative to the project root (e.g. "modules/web/nginx.sh")
source_module() {
local mod="$1"
local path="${oneinstack_dir:-.}/${mod}"
case ";${_LOADED_MODULES};" in
*";${mod};"*) return 0 ;;
esac
[ -f "${path}" ] || { echo "${CFAILURE}ERROR: module not found: ${mod}${CEND}" >&2; return 1; }
. "${path}" || return 1
_LOADED_MODULES="${_LOADED_MODULES};${mod}"
}
# Load the common header exactly as the legacy top of install.sh did:
# config/versions.txt, config/options.conf, color, check_os, check_dir, download, get_char
load_common() {
. "${oneinstack_dir}/config/versions.txt"
. "${oneinstack_dir}/config/options.conf"
. "${oneinstack_dir}/lib/color.sh"
. "${oneinstack_dir}/lib/check_os.sh"
. "${oneinstack_dir}/lib/check_dir.sh"
. "${oneinstack_dir}/lib/download.sh"
. "${oneinstack_dir}/lib/get_char.sh"
}
# Entry-point wrapper used by the workflow (see install.sh / workflow.sh).
load_configs() {
load_common
}
# Run a module's install function. Mirrors the legacy pattern
# . modules/X.sh; Func 2>&1 | tee -a runtime/install.log
# so every call site stays consistent (and is trivially de-duplicated).
#
# A visible "installing" banner is printed up front so the user always knows
# which component is being built/installed at any moment. This matters because
# the install runs many long compilations (nginx, php, mysql, ...) back-to-back;
# without a per-component header the screen just shows a wall of `make` output
# and it is impossible to tell what is currently running (or whether it hung).
# ${func} 2>&1 | tee -a ... keeps the real build output on screen AND in the log,
# so nothing is silent.
run_install() {
local module="$1" func="$2"
echo ""
echo "${CMSG}================================================================${CEND}"
echo "${CMSG}>> Installing: ${func}${CEND}"
echo "${CMSG} (module: ${module})${CEND}"
echo "${CMSG}================================================================${CEND}"
. "${module}" || { echo "${CFAILURE}ERROR: failed to load ${module}${CEND}" >&2; return 1; }
${func} 2>&1 | tee -a "${oneinstack_dir}/runtime/install.log"
}
+69
View File
@@ -0,0 +1,69 @@
#!/bin/bash
# lib/log.sh - unified logging and error handling.
#
# Replaces the scattered `echo ...; exit 1` and ad-hoc `tee -a install.log`
# patterns with a single, consistent interface. The legacy install steps
# keep their own `tee -a ${oneinstack_dir}/runtime/install.log` pipes (preserved
# verbatim in the migrated modules); these helpers are used by the framework
# layer and are safe to call before/after that log file exists.
# Resolve the install log path (falls back to ./runtime/install.log before
# oneinstack_dir is known).
_log_path() {
echo "${oneinstack_dir:-.}/runtime/install.log"
}
log_info() {
echo -e "${CQUESTION}[INFO]${CEND} $*" | tee -a "$(_log_path)"
}
log_success() {
echo -e "${CMSG}[OK]${CEND} $*" | tee -a "$(_log_path)"
}
log_warn() {
echo -e "${CWARNING}[WARN]${CEND} $*" | tee -a "$(_log_path)"
}
log_error() {
echo -e "${CFAILURE}[ERROR]${CEND} $*" | tee -a "$(_log_path)"
}
# Unified fatal exit: log the error, run cleanup, then exit.
error_exit() {
local msg="$1"
log_error "${msg:-An unexpected error occurred.}"
cleanup
exit 1
}
# Alias kept for readability at call sites.
die() {
error_exit "$@"
}
# Conservative cleanup: removes only temporary build extraction dirs.
# Intentionally does NOT remove installed software, so behavior is unchanged.
cleanup() {
return 0
}
# Lightweight rollback hook. Default: no-op to avoid changing install behavior.
# Real rollback can be implemented here without affecting the happy path.
rollback() {
return 0
}
# Unified exception handler. Bound from install.sh to EXIT/INT/TERM.
#
# Deliberately does NOT auto-log: any automatic [ERROR]/[INFO] write here would
# change the contents of install.log relative to the original oneinstack script
# (which had no trap). Logging is performed explicitly by call sites via
# log_error / error_exit. This handler only guarantees best-effort cleanup and
# rollback hooks run on exit / interrupt / terminate. cleanup and rollback are
# currently no-ops so installed state and logs are untouched on the happy path.
trap_handler() {
local rc=$?
rollback
cleanup
}
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://linuxeye.com
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
Mem=`free -m | awk '/Mem:/{print $2}'`
Swap=`free -m | awk '/Swap:/{print $2}'`
if [ $Mem -le 640 ]; then
Mem_level=512M
Memory_limit=64
THREAD=1
elif [ $Mem -gt 640 -a $Mem -le 1280 ]; then
Mem_level=1G
Memory_limit=128
elif [ $Mem -gt 1280 -a $Mem -le 2500 ]; then
Mem_level=2G
Memory_limit=192
elif [ $Mem -gt 2500 -a $Mem -le 3500 ]; then
Mem_level=3G
Memory_limit=256
elif [ $Mem -gt 3500 -a $Mem -le 4500 ]; then
Mem_level=4G
Memory_limit=320
elif [ $Mem -gt 4500 -a $Mem -le 8000 ]; then
Mem_level=6G
Memory_limit=384
elif [ $Mem -gt 8000 ]; then
Mem_level=8G
Memory_limit=448
fi
# add swapfile
if [ ! -e ~/.oneinstack ] && [ "${Swap}" == '0' ] && [ ${Mem} -le 4096 ]; then
echo "${CWARNING}Add Swap file, It may take a few minutes... ${CEND}"
dd if=/dev/zero of=/swapfile count=2048 bs=1M
mkswap /swapfile
swapon /swapfile
chmod 600 /swapfile
[ -z "`grep swapfile /etc/fstab`" ] && echo '/swapfile swap swap defaults 0 0' >> /etc/fstab
fi
+147
View File
@@ -0,0 +1,147 @@
#!/bin/bash
# Author: yeho <lj2007331 AT gmail.com>
# BLOG: https://linuxeye.com
#
# Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
#
# Project home page:
# https://oneinstack.com
# https://github.com/oneinstack/oneinstack
if openssl version | grep -Eqi 'OpenSSL 1.0.2*'; then
php5_with_openssl="--with-openssl"
php70_with_openssl="--with-openssl"
php71_with_openssl="--with-openssl"
php72_with_openssl="--with-openssl"
php73_with_openssl="--with-openssl"
php74_with_openssl="--with-openssl"
php80_with_openssl="--with-openssl"
php81_with_openssl="--with-openssl"
php5_with_ssl="--with-ssl"
php70_with_ssl="--with-ssl"
php71_with_ssl="--with-ssl"
php72_with_ssl="--with-ssl"
php73_with_ssl="--with-ssl"
php74_with_ssl="--with-ssl"
php80_with_ssl="--with-ssl"
php81_with_ssl="--with-ssl"
php5_with_curl="--with-curl"
php70_with_curl="--with-curl"
php71_with_curl="--with-curl"
php72_with_curl="--with-curl"
php73_with_curl="--with-curl"
php74_with_curl="--with-curl"
php80_with_curl="--with-curl"
php81_with_curl="--with-curl"
elif openssl version | grep -Eqi 'OpenSSL 1.1.*'; then
php5_with_openssl="--with-openssl=${openssl_install_dir}"
php70_with_openssl="--with-openssl"
php71_with_openssl="--with-openssl"
php72_with_openssl="--with-openssl"
php73_with_openssl="--with-openssl"
php74_with_openssl="--with-openssl"
php80_with_openssl="--with-openssl"
php81_with_openssl="--with-openssl"
php5_with_ssl="--with-ssl=${openssl_install_dir}"
php70_with_ssl="--with-ssl"
php71_with_ssl="--with-ssl"
php72_with_ssl="--with-ssl"
php73_with_ssl="--with-ssl"
php74_with_ssl="--with-ssl"
php80_with_ssl="--with-ssl"
php81_with_ssl="--with-ssl"
php5_with_curl="--with-curl=${curl_install_dir}"
php70_with_curl="--with-curl"
php71_with_curl="--with-curl"
php72_with_curl="--with-curl"
php73_with_curl="--with-curl"
php74_with_curl="--with-curl"
php80_with_curl="--with-curl"
php81_with_curl="--with-curl"
[[ "${mphp_ver}" =~ ^5[3-6]$ ]] && with_old_openssl_flag=y
elif openssl version | grep -Eqi 'OpenSSL 3.*'; then
php5_with_openssl="--with-openssl=${openssl_install_dir}"
php70_with_openssl="--with-openssl=${openssl_install_dir}"
php71_with_openssl="--with-openssl"
php72_with_openssl="--with-openssl"
php73_with_openssl="--with-openssl"
php74_with_openssl="--with-openssl"
php80_with_openssl="--with-openssl"
php81_with_openssl="--with-openssl"
php5_with_ssl="--with-ssl=${openssl_install_dir}"
php70_with_ssl="--with-ssl=${openssl_install_dir}"
php71_with_ssl="--with-ssl"
php72_with_ssl="--with-ssl"
php73_with_ssl="--with-ssl"
php74_with_ssl="--with-ssl"
php80_with_ssl="--with-ssl"
php81_with_ssl="--with-ssl"
php5_with_curl="--with-curl=${curl_install_dir}"
php70_with_curl="--with-curl=${curl_install_dir}"
php71_with_curl="--with-curl"
php72_with_curl="--with-curl"
php73_with_curl="--with-curl"
php74_with_curl="--with-curl"
php80_with_curl="--with-curl"
php81_with_curl="--with-curl"
[[ "${mphp_ver}" =~ ^5[3-6]$|^70$ ]] && with_old_openssl_flag=y
else
php5_with_openssl="--with-openssl=${openssl_install_dir}"
php70_with_openssl="--with-openssl=${openssl_install_dir}"
php71_with_openssl="--with-openssl=${openssl_install_dir}"
php72_with_openssl="--with-openssl=${openssl_install_dir}"
php73_with_openssl="--with-openssl=${openssl_install_dir}"
php74_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
php80_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
php81_with_openssl="--with-openssl=${openssl_install_dir} --with-openssl-dir=${openssl_install_dir}"
php5_with_ssl="--with-ssl=${openssl_install_dir}"
php70_with_ssl="--with-ssl=${openssl_install_dir}"
php71_with_ssl="--with-ssl=${openssl_install_dir}"
php72_with_ssl="--with-ssl=${openssl_install_dir}"
php73_with_ssl="--with-ssl=${openssl_install_dir}"
php74_with_ssl="--with-ssl=${openssl_install_dir}"
php80_with_ssl="--with-ssl=${openssl_install_dir}"
php81_with_ssl="--with-ssl=${openssl_install_dir}"
php5_with_curl="--with-curl=${curl_install_dir}"
php70_with_curl="--with-curl=${curl_install_dir}"
php71_with_curl="--with-curl=${curl_install_dir}"
php72_with_curl="--with-curl=${curl_install_dir}"
php73_with_curl="--with-curl=${curl_install_dir}"
php74_with_curl="--with-curl=${curl_install_dir}"
php80_with_curl="--with-curl=${curl_install_dir}"
php81_with_curl="--with-curl=${curl_install_dir}"
with_old_openssl_flag=y
fi
Install_openSSL() {
if [ "${with_old_openssl_flag}" == 'y' ]; then
if [ ! -e "${openssl_install_dir}/lib/libssl.a" ]; then
echo "${CMSG}>> Installing: openSSL ${openssl_ver} (compiling from source)${CEND}"
pushd ${oneinstack_dir}/src > /dev/null
tar xzf openssl-${openssl_ver}.tar.gz
pushd openssl-${openssl_ver} > /dev/null
make clean
./config -Wl,-rpath=${openssl_install_dir}/lib -fPIC --prefix=${openssl_install_dir} --openssldir=${openssl_install_dir}
make depend
make -j ${THREAD} && make install
popd > /dev/null
if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then
echo "${CSUCCESS}openSSL installed successfully! ${CEND}"
/bin/cp cacert.pem ${openssl_install_dir}/cert.pem
rm -rf openssl-${openssl_ver}
else
echo "${CFAILURE}openSSL install failed, Please contact the author! ${CEND}" && lsb_release -a
kill -9 $$; exit 1;
fi
popd > /dev/null
fi
fi
}
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env python
import sys,os,socket
def IsOpen(ip,port):
socket.setdefaulttimeout(5)
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
try:
s.connect((ip,int(port)))
s.shutdown(2)
print(True)
except:
print(False)
if __name__ == '__main__':
IsOpen(sys.argv[1],int(sys.argv[2]))
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env python
import socket
def Get_local_ip():
"""
Returns the actual ip of the local machine.
This code figures out what source address would be used if some traffic
were to be sent out to some well known address on the Internet. In this
case, a Google DNS server is used, but the specific address does not
matter much. No traffic is actually sent.
"""
try:
socket.setdefaulttimeout(5)
csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
csock.connect(('1.1.1.1', 80))
(addr, port) = csock.getsockname()
csock.close()
return addr
except socket.error:
return "127.0.0.1"
if __name__ == "__main__":
IPADDR = Get_local_ip()
print(IPADDR)
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env python
#coding:utf-8
import sys,socket,json
if sys.version_info[0] == 2:
import urllib2 as request
else:
import urllib.request as request
try:
socket.setdefaulttimeout(5)
if len(sys.argv) == 1:
apiurl = "http://ip-api.com/json"
elif len(sys.argv) == 2:
apiurl = "http://ip-api.com/json/%s" % sys.argv[1]
content = request.urlopen(apiurl).read().decode('utf-8')
content = json.JSONDecoder().decode(content)
#print(content)
if content['status'] == 'success':
if content['country'] == 'China':
print("CN")
else:
print(content['country'])
except:
print("Usage:%s IP" % sys.argv[0])
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env python
import sys,re,socket
if sys.version_info[0] == 2:
import urllib2 as request
else:
import urllib.request as request
class Get_public_ip:
socket.setdefaulttimeout(5)
def getip(self):
try:
myip = self.visit("http://ipv4.icanhazip.com/")
except:
try:
myip = self.visit("http://pv.sohu.com/cityjson?ie=utf-8")
except:
myip = "So sorry!!!"
return myip
def visit(self,url):
opener = request.urlopen(url)
if url == opener.geturl():
str = opener.read().decode('utf-8')
return re.search('\d+\.\d+\.\d+\.\d+',str).group(0)
if __name__ == "__main__":
getmyip = Get_public_ip()
print(getmyip.getip())