From 09d4d15f727165c718f282c62ce87f28b96b6895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=97=E5=AD=90?= Date: Sat, 15 Jul 2023 04:09:46 +0800 Subject: [PATCH] feat: update scripts --- app/services/website.go | 1 + scripts/mysql/install.sh | 290 +++++++++++++++++++ scripts/mysql/uninstall.sh | 41 +++ scripts/{plugins => }/openresty/install.sh | 30 +- scripts/{plugins => }/openresty/uninstall.sh | 1 + scripts/php/install.sh | 247 ++++++++++++++++ scripts/php/uninstall.sh | 35 +++ scripts/php_extensions/exif.sh | 80 +++++ scripts/php_extensions/imagemagick.sh | 91 ++++++ scripts/php_extensions/ioncube.sh | 73 +++++ scripts/php_extensions/opcache.sh | 68 +++++ scripts/php_extensions/pdo_pgsql.sh | 80 +++++ scripts/php_extensions/redis.sh | 88 ++++++ scripts/phpmyadmin/install.sh | 111 +++++++ scripts/phpmyadmin/uninstall.sh | 30 ++ scripts/postgresql/install.sh | 27 ++ scripts/postgresql/uninstall.sh | 0 17 files changed, 1281 insertions(+), 12 deletions(-) create mode 100644 scripts/mysql/install.sh create mode 100644 scripts/mysql/uninstall.sh rename scripts/{plugins => }/openresty/install.sh (89%) rename scripts/{plugins => }/openresty/uninstall.sh (91%) create mode 100644 scripts/php/install.sh create mode 100644 scripts/php/uninstall.sh create mode 100644 scripts/php_extensions/exif.sh create mode 100644 scripts/php_extensions/imagemagick.sh create mode 100644 scripts/php_extensions/ioncube.sh create mode 100644 scripts/php_extensions/opcache.sh create mode 100644 scripts/php_extensions/pdo_pgsql.sh create mode 100644 scripts/php_extensions/redis.sh create mode 100644 scripts/phpmyadmin/install.sh create mode 100644 scripts/phpmyadmin/uninstall.sh create mode 100644 scripts/postgresql/install.sh create mode 100644 scripts/postgresql/uninstall.sh diff --git a/app/services/website.go b/app/services/website.go index 4d15417c..5eaa349d 100644 --- a/app/services/website.go +++ b/app/services/website.go @@ -206,6 +206,7 @@ server error_log /dev/null; access_log /dev/null; } + access_log /www/wwwlogs/%s.log; error_log /www/wwwlogs/%s.log; } diff --git a/scripts/mysql/install.sh b/scripts/mysql/install.sh new file mode 100644 index 00000000..a7f15df6 --- /dev/null +++ b/scripts/mysql/install.sh @@ -0,0 +1,290 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH + +: ' +Copyright 2022 HaoZi Technology Co., Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +' + +HR="+----------------------------------------------------" +ARCH=$(uname -m) +memTotal=$(LC_ALL=C free -m | grep Mem | awk '{print $2}') +OS=$(source /etc/os-release && { [[ "$ID" == "debian" ]] && echo "debian"; } || { [[ "$ID" == "centos" ]] || [[ "$ID" == "rhel" ]] || [[ "$ID" == "rocky" ]] || [[ "$ID" == "almalinux" ]] && echo "centos"; } || echo "unknown") +downloadUrl="https://dl.cdn.haozi.net/panel/mysql" +setupPath="/www" +mysqlPath="${setupPath}/server/mysql" +mysqlVersion="" +mysqlPassword=$(cat /dev/urandom | head -n 16 | md5sum | head -c 16) + +if [[ "${1}" == "8.0" ]]; then + mysqlVersion="8.0.33" +elif [[ "${1}" == "5.7" ]]; then + mysqlVersion="5.7.42" +else + echo -e $HR + echo "错误:不支持的 MySQL 版本!" + exit 1 +fi + +if [[ "${memTotal}" -lt "4096" ]] && [[ "${1}" == "8.0" ]]; then + echo -e $HR + echo "错误:这点内存(${memTotal}M)还想装 MySQL 8.0?洗洗睡吧!" + exit 1 +fi + +# 安装依赖 +if [ "${OS}" == "centos" ]; then + dnf install dnf-plugins-core -y + dnf install epel-release -y + dnf config-manager --set-enabled epel + dnf config-manager --set-enabled PowerTools + dnf config-manager --set-enabled powertools + dnf config-manager --set-enabled CRB + dnf config-manager --set-enabled Crb + dnf config-manager --set-enabled crb + /usr/bin/crb enable + dnf makecache + dnf groupinstall "Development Tools" -y + dnf install cmake bison ncurses-devel libtirpc-devel openssl-devel pkg-config openldap-devel libudev-devel cyrus-sasl-devel patchelf -y +elif [ "${OS}" == "debian" ]; then + apt update + apt install build-essential cmake bison libncurses5-dev libtirpc-dev libssl-dev pkg-config libldap2-dev libudev-dev libsasl2-dev patchelf -y +else + echo -e $HR + echo "错误:耗子Linux面板不支持该系统" + exit 1 +fi + +mysqlUserCheck=$(cat /etc/passwd | grep mysql) +if [ "${mysqlUserCheck}" == "" ]; then + groupadd mysql + useradd -s /sbin/nologin -g mysql mysql +fi + +# 准备目录 +rm -rf ${mysqlPath} +mkdir -p ${mysqlPath} +cd ${mysqlPath} + +# 下载源码 +wget -T 120 -O ${mysqlPath}/mysql-${mysqlVersion}.tar.gz ${downloadUrl}/mysql-boost-${mysqlVersion}.tar.gz +tar -zxvf mysql-${mysqlVersion}.tar.gz +rm -f mysql-${mysqlVersion}.tar.gz +mv mysql-${mysqlVersion} src + +# openssl +wget -T 120 -O ${mysqlPath}/openssl-1.1.1u.tar.gz ${downloadUrl}/openssl/openssl-1.1.1u.tar.gz +tar -zxvf openssl-1.1.1u.tar.gz +rm -f openssl-1.1.1u.tar.gz +mv openssl-1.1.1u openssl +cd openssl +./config --prefix=/usr/local/openssl-1.1 --openssldir=/usr/local/openssl-1.1 +make -j$(nproc) +make install +echo "/usr/local/openssl-1.1/lib" > /etc/ld.so.conf.d/openssl-1.1.conf +ldconfig +cd .. +rm -rf openssl + +# 编译 +cd src +mkdir build +cd build +cmake .. -DCMAKE_INSTALL_PREFIX=${mysqlPath} -DMYSQL_DATADIR=${mysqlPath}/data -DSYSCONFDIR=${mysqlPath}/conf -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_EXTRA_CHARSETS=all -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DENABLED_LOCAL_INFILE=1 -DWITH_SYSTEMD=1 -DSYSTEMD_PID_DIR=${mysqlPath} -DWITH_SSL=/usr/local/openssl-1.1 -DWITH_BOOST=../boost +make -j$(nproc) + +# 安装 +make install + +# 配置 +mkdir ${mysqlPath}/conf +cat > ${mysqlPath}/conf/my.cnf << EOF +[client] +port = 3306 +socket = /tmp/mysql.sock + +[mysqld] +port = 3306 +socket = /tmp/mysql.sock +datadir = ${mysqlPath}/data +default_storage_engine = InnoDB +skip-external-locking +table_definition_cache = 400 +performance_schema_max_table_instances = 400 +key_buffer_size = 8M +max_allowed_packet = 1G +table_open_cache = 32 +sort_buffer_size = 256K +net_buffer_length = 4K +read_buffer_size = 128K +read_rnd_buffer_size = 256K +myisam_sort_buffer_size = 4M +thread_cache_size = 4 +query_cache_size = 4M +tmp_table_size = 8M +explicit_defaults_for_timestamp = 1 +#skip-name-resolve +max_connections = 500 +max_connect_errors = 100 +open_files_limit = 65535 +early-plugin-load = "" + +log-bin = mysql-bin +binlog_format = mixed +server-id = 1 +slow_query_log = 1 +slow-query-log-file = ${mysqlPath}/mysql-slow.log +long_query_time = 3 +log-error = ${mysqlPath}/mysql-error.log + +innodb_data_home_dir = ${mysqlPath}/data +innodb_data_file_path = ibdata1:10M:autoextend +innodb_log_group_home_dir = ${mysqlPath}/data +innodb_buffer_pool_size = 16M +innodb_redo_log_capacity = 5M +innodb_log_buffer_size = 8M +innodb_flush_log_at_trx_commit = 1 +innodb_lock_wait_timeout = 50 +innodb_max_dirty_pages_pct = 90 +innodb_read_io_threads = 4 +innodb_write_io_threads = 4 + +[mysqldump] +quick +max_allowed_packet = 500M + +[myisamchk] +key_buffer_size = 20M +sort_buffer_size = 20M +read_buffer = 2M +write_buffer = 2M + +[mysqlhotcopy] +interactive-timeout +EOF + +# 根据CPU核心数确定写入线程数 +cpuCore=$(cat /proc/cpuinfo | grep "processor" | wc -l) +sed -i 's/innodb_write_io_threads = 4/innodb_write_io_threads = '${cpuCore}'/g' ${mysqlPath}/conf/my.cnf +sed -i 's/innodb_read_io_threads = 4/innodb_read_io_threads = '${cpuCore}'/g' ${mysqlPath}/conf/my.cnf + +if [[ "${1}" == "8.0" ]]; then + sed -i '/query_cache_size/d' ${mysqlPath}/conf/my.cnf +fi +if [[ "${1}" == "5.7" ]]; then + sed -i '/innodb_redo_log_capacity/d' ${mysqlPath}/conf/my.cnf +fi + +# 根据内存大小调参 +if [[ ${memTotal} -gt 1024 && ${memTotal} -lt 2048 ]]; then + sed -i "s#^key_buffer_size.*#key_buffer_size = 32M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^table_open_cache.*#table_open_cache = 128#" ${mysqlPath}/conf/my.cnf + sed -i "s#^sort_buffer_size.*#sort_buffer_size = 768K#" ${mysqlPath}/conf/my.cnf + sed -i "s#^read_buffer_size.*#read_buffer_size = 768K#" ${mysqlPath}/conf/my.cnf + sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 8M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^thread_cache_size.*#thread_cache_size = 16#" ${mysqlPath}/conf/my.cnf + sed -i "s#^query_cache_size.*#query_cache_size = 16M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^tmp_table_size.*#tmp_table_size = 32M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 128M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_redo_log_capacity.*#innodb_redo_log_capacity = 64M" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 16M#" ${mysqlPath}/conf/my.cnf +elif [[ ${memTotal} -ge 2048 && ${memTotal} -lt 4096 ]]; then + sed -i "s#^key_buffer_size.*#key_buffer_size = 64M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^table_open_cache.*#table_open_cache = 256#" ${mysqlPath}/conf/my.cnf + sed -i "s#^sort_buffer_size.*#sort_buffer_size = 1M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^read_buffer_size.*#read_buffer_size = 1M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 16M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^thread_cache_size.*#thread_cache_size = 32#" ${mysqlPath}/conf/my.cnf + sed -i "s#^query_cache_size.*#query_cache_size = 32M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 256M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_redo_log_capacity.*#innodb_redo_log_capacity = 128M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 32M#" ${mysqlPath}/conf/my.cnf +elif [[ ${memTotal} -ge 4096 && ${memTotal} -lt 8192 ]]; then + sed -i "s#^key_buffer_size.*#key_buffer_size = 128M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^table_open_cache.*#table_open_cache = 512#" ${mysqlPath}/conf/my.cnf + sed -i "s#^sort_buffer_size.*#sort_buffer_size = 2M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^read_buffer_size.*#read_buffer_size = 2M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 32M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^thread_cache_size.*#thread_cache_size = 64#" ${mysqlPath}/conf/my.cnf + sed -i "s#^query_cache_size.*#query_cache_size = 64M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 512M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_redo_log_capacity.*#innodb_redo_log_capacity = 256M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 64M#" ${mysqlPath}/conf/my.cnf +elif [[ ${memTotal} -ge 8192 && ${memTotal} -lt 16384 ]]; then + sed -i "s#^key_buffer_size.*#key_buffer_size = 256M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^table_open_cache.*#table_open_cache = 1024#" ${mysqlPath}/conf/my.cnf + sed -i "s#^sort_buffer_size.*#sort_buffer_size = 4M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^read_buffer_size.*#read_buffer_size = 4M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 64M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^thread_cache_size.*#thread_cache_size = 128#" ${mysqlPath}/conf/my.cnf + sed -i "s#^query_cache_size.*#query_cache_size = 128M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^tmp_table_size.*#tmp_table_size = 128M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 1024M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_redo_log_capacity.*#innodb_redo_log_capacity = 512M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 128M#" ${mysqlPath}/conf/my.cnf +elif [[ ${memTotal} -ge 16384 && ${memTotal} -lt 32768 ]]; then + sed -i "s#^key_buffer_size.*#key_buffer_size = 512M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^table_open_cache.*#table_open_cache = 2048#" ${mysqlPath}/conf/my.cnf + sed -i "s#^sort_buffer_size.*#sort_buffer_size = 8M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^read_buffer_size.*#read_buffer_size = 8M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 128M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^thread_cache_size.*#thread_cache_size = 256#" ${mysqlPath}/conf/my.cnf + sed -i "s#^query_cache_size.*#query_cache_size = 256M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^tmp_table_size.*#tmp_table_size = 256M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 2048M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_redo_log_capacity.*#innodb_redo_log_capacity = 1G#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 256M#" ${mysqlPath}/conf/my.cnf +elif [[ ${memTotal} -ge 32768 ]]; then + sed -i "s#^key_buffer_size.*#key_buffer_size = 1024M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^table_open_cache.*#table_open_cache = 4096#" ${mysqlPath}/conf/my.cnf + sed -i "s#^sort_buffer_size.*#sort_buffer_size = 16M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^read_buffer_size.*#read_buffer_size = 16M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 256M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^thread_cache_size.*#thread_cache_size = 512#" ${mysqlPath}/conf/my.cnf + sed -i "s#^query_cache_size.*#query_cache_size = 512M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^tmp_table_size.*#tmp_table_size = 512M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 4096M#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_redo_log_capacity.*#innodb_redo_log_capacity = 2G#" ${mysqlPath}/conf/my.cnf + sed -i "s#^innodb_log_buffer_size.*#innodb_log_buffer_size = 512M#" ${mysqlPath}/conf/my.cnf +fi + +chmod 644 ${mysqlPath}/conf/my.cnf +chown -R mysql:mysql ${mysqlPath} +chmod -R 755 ${mysqlPath} + +# 初始化 +rm -rf ${mysqlPath}/src +rm -rf ${mysqlPath}/data +mkdir -p ${mysqlPath}/data +chown -R mysql:mysql ${mysqlPath}/data +chmod -R 755 ${mysqlPath}/data + +${mysqlPath}/bin/mysqld --initialize-insecure --user=mysql --basedir=${mysqlPath} --datadir=${mysqlPath}/data + +echo "export PATH=${mysqlPath}/bin:\$PATH" >> /etc/profile +source /etc/profile + +# 启动 +cp ${mysqlPath}/lib/systemd/system/mysqld.service /etc/systemd/system/mysqld.service +sed -i "#ExecStartPre#d" /etc/systemd/system/mysqld.service + +systemctl daemon-reload +systemctl enable mysqld +systemctl start mysqld + +${mysqlPath}/bin/mysqladmin -u root password ${mysqlPassword} + +echo "mysql root password: ${mysqlPassword}" diff --git a/scripts/mysql/uninstall.sh b/scripts/mysql/uninstall.sh new file mode 100644 index 00000000..1e13cd6f --- /dev/null +++ b/scripts/mysql/uninstall.sh @@ -0,0 +1,41 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH + +: ' +Copyright 2022 HaoZi Technology Co., Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +' + +HR="+----------------------------------------------------" + +systemctl stop mysqld +systemctl disable mysqld +rm -rf /etc/systemd/system/mysqld.service +systemctl daemon-reload +pkill -9 mysqld +rm -rf /www/server/mysql + +rm -f /usr/bin/mysql* +rm -f /usr/lib/libmysql* +rm -f /usr/lib64/libmysql* + +userdel -r mysql +groupdel mysql + +sed -i '#export PATH=/www/server/mysql#d' /etc/profile +source /etc/profile + +panel deletePlugin mysql + +echo -e "${HR}\nMySQL uninstall completed.\n${HR}" diff --git a/scripts/plugins/openresty/install.sh b/scripts/openresty/install.sh similarity index 89% rename from scripts/plugins/openresty/install.sh rename to scripts/openresty/install.sh index 2d2e8806..47207837 100644 --- a/scripts/plugins/openresty/install.sh +++ b/scripts/openresty/install.sh @@ -20,22 +20,28 @@ limitations under the License. HR="+----------------------------------------------------" ARCH=$(uname -m) OS=$(source /etc/os-release && { [[ "$ID" == "debian" ]] && echo "debian"; } || { [[ "$ID" == "centos" ]] || [[ "$ID" == "rhel" ]] || [[ "$ID" == "rocky" ]] || [[ "$ID" == "almalinux" ]] && echo "centos"; } || echo "unknown") -downloadUrl="https://raw.githubusercontent.com/HaoZi-Team/Panel_Assets/main/openresty" +downloadUrl="https://dl.cdn.haozi.net/panel/openresty" setupPath="/www" openrestyPath="${setupPath}/server/openresty" openrestyVersion="1.21.4.1" -# Check use proxy -useProxy=${1} -if [ "${useProxy}" == "--proxy" ]; then - downloadUrl="https://ghproxy.com/${downloadUrl}" -fi - # 安装依赖 if [ "${OS}" == "centos" ]; then - dnf install gcc gcc-c++ make tar unzip gd gd-devel git-core flex perl perl-CPAN oniguruma oniguruma-devel libsodium-devel libxml2-devel libxslt-devel GeoIP-devel bison yajl yajl-devel curl curl-devel libtermcap-devel ncurses-devel libevent-devel readline-devel libuuid-devel brotli-devel icu libicu libicu-devel openssl openssl-devel -y + dnf install dnf-plugins-core -y + dnf install epel-release -y + dnf config-manager --set-enabled epel + dnf config-manager --set-enabled PowerTools + dnf config-manager --set-enabled powertools + dnf config-manager --set-enabled CRB + dnf config-manager --set-enabled Crb + dnf config-manager --set-enabled crb + /usr/bin/crb enable + dnf makecache + dnf groupinstall "Development Tools" -y + dnf install tar unzip gd gd-devel git-core flex perl perl-CPAN oniguruma oniguruma-devel libsodium-devel libxml2-devel libxslt-devel GeoIP-devel bison yajl yajl-devel curl curl-devel libtermcap-devel ncurses-devel libevent-devel readline-devel libuuid-devel brotli-devel icu libicu libicu-devel openssl openssl-devel -y elif [ "${OS}" == "debian" ]; then - apt install gcc g++ make tar unzip libgd3 libgd-dev git flex perl perl-modules libonig-dev libsodium-dev libxml2-dev libxslt1-dev libgeoip-dev bison libyajl-dev curl libcurl4-openssl-dev libncurses5-dev libevent-dev libreadline-dev uuid-dev libbrotli-dev icu-devtools libicu-dev openssl libssl-dev -y + apt update + apt install build-essential tar unzip libgd3 libgd-dev git flex perl perl-modules libonig-dev libsodium-dev libxml2-dev libxslt1-dev libgeoip-dev bison libyajl-dev curl libcurl4-openssl-dev libncurses5-dev libevent-dev libreadline-dev uuid-dev libbrotli-dev icu-devtools libicu-dev openssl libssl-dev -y else echo -e $HR echo "错误:耗子Linux面板不支持该系统" @@ -49,7 +55,7 @@ cd ${openrestyPath} # 下载源码 wget -T 120 -O ${openrestyPath}/openresty-${openrestyVersion}.tar.gz ${downloadUrl}/openresty-${openrestyVersion}.tar.gz -tar -xvf openresty-${openrestyVersion}.tar.gz +tar -zxvf openresty-${openrestyVersion}.tar.gz rm -f openresty-${openrestyVersion}.tar.gz mv openresty-${openrestyVersion} src cd src @@ -173,7 +179,7 @@ cat >${openrestyPath}/conf/nginx.conf < /etc/ld.so.conf.d/openssl-1.1.conf + ldconfig + cd .. + rm -rf openssl + + export CFLAGS="-I/usr/local/openssl-1.1/include -I/usr/local/curl/include" + export LIBS="-L/usr/local/openssl-1.1/lib -L/usr/local/curl/lib" +fi + +# 配置 +cd src +./configure --prefix=${phpPath} --with-config-file-path=${phpPath}/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-freetype --with-jpeg --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --with-gettext --enable-fileinfo --enable-opcache --with-sodium --with-webp + +# 编译安装 +make -j${nproc} +make install +if [ ! -f "${phpPath}/bin/php" ]; then + echo -e $HR + echo "错误:PHP-${phpVersion}安装失败,请截图错误信息寻求帮助!" + rm -rf ${phpPath} + exit 1 +fi + +# 创建php配置 +mkdir -p ${phpPath}/etc +\cp php.ini-production ${phpPath}/etc/php.ini + +# 安装zip拓展 +cd ${phpPath}/src/ext/zip +${phpPath}/bin/phpize +./configure --with-php-config=${phpPath}/bin/php-config +make -j${cpuCore} +make install +if [ "$?" != "0" ]; then + echo -e $HR + echo "错误:PHP-${phpVersion} zip拓展安装失败,请截图错误信息寻求帮助。" + exit 1 +fi +cd ../../ + +# 写入拓展标记位 +echo ";下方标记位禁止删除,否则将导致PHP拓展无法正常安装!" >>${phpPath}/etc/php.ini +echo ";haozi" >>${phpPath}/etc/php.ini +# 写入zip拓展到php配置 +echo "extension=zip" >>${phpPath}/etc/php.ini + +# 设置软链接 +rm -f /usr/bin/php-${phpVersion} +rm -f /usr/bin/pear +rm -f /usr/bin/pecl +ln -sf ${phpPath}/bin/php /usr/bin/php +ln -sf ${phpPath}/bin/php /usr/bin/php-${phpVersion} +ln -sf ${phpPath}/bin/phpize /usr/bin/phpize +ln -sf ${phpPath}/bin/pear /usr/bin/pear +ln -sf ${phpPath}/bin/pecl /usr/bin/pecl +ln -sf ${phpPath}/sbin/php-fpm /usr/bin/php-fpm-${phpVersion} + +# 设置fpm +cat >${phpPath}/etc/php-fpm.conf </www/server/openresty/conf/enable-php-${phpVersion}.conf </www/server/vhost/openresty/phpmyadmin.conf </dev/null 2>&1 +firewall-cmd --reload + +panel writePlugin phpmyadmin +systemctl reload openresty diff --git a/scripts/phpmyadmin/uninstall.sh b/scripts/phpmyadmin/uninstall.sh new file mode 100644 index 00000000..9d0b53bc --- /dev/null +++ b/scripts/phpmyadmin/uninstall.sh @@ -0,0 +1,30 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH + +: ' +Copyright 2022 HaoZi Technology Co., Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +' + +HR="+----------------------------------------------------" +setupPath="/www" +phpmyadminPath="${setupPath}/wwwroot/phpmyadmin" + + +rm -rf /www/server/vhost/openresty/phpmyadmin.conf +rm -rf ${phpmyadminPath} +panel deletePlugin phpmyadmin +systemctl reload openresty + +echo -e "${HR}\phpMyAdmin uninstall completed.\n${HR}" diff --git a/scripts/postgresql/install.sh b/scripts/postgresql/install.sh new file mode 100644 index 00000000..06108411 --- /dev/null +++ b/scripts/postgresql/install.sh @@ -0,0 +1,27 @@ +#!/bin/bash +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH + +: ' +Copyright 2022 HaoZi Technology Co., Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +' + +HR="+----------------------------------------------------" +postgresqlVersion="$1" +setup_Path="/www" +postgresqlPath="${setup_Path}/server/postgresql" +os_Version=$(cat /etc/redhat-release | sed -r 's/.* ([0-9]+)\.?.*/\1/') +ipLocation=$(curl -s https://ip.ping0.cc/geo) # 获取IP位置 + +# TODO diff --git a/scripts/postgresql/uninstall.sh b/scripts/postgresql/uninstall.sh new file mode 100644 index 00000000..e69de29b