Compare commits

...

9 Commits

View File

@ -102,12 +102,26 @@ install_soft() {
install_base() { install_base() {
echo -e "${green}开始安装基础组件${plain}" echo -e "${green}开始安装基础组件${plain}"
(command -v git >/dev/null 2>&1 && command -v curl >/dev/null 2>&1 && command -v wget >/dev/null 2>&1 && command -v unzip >/dev/null 2>&1 && command -v getenforce >/dev/null 2>&1 && command -v gnupg >/dev/null 2>&1 && command -v lsb_release >/dev/null) || (command -v git >/dev/null 2>&1 && command -v curl >/dev/null 2>&1 && command -v wget >/dev/null 2>&1 && command -v unzip >/dev/null 2>&1 && command -v getenforce >/dev/null 2>&1 && command -v gnupg >/dev/null 2>&1 && command -v lsb_release >/dev/null) ||
(install_soft curl wget git unzip gnupg lsb-release ca-certificates) (install_soft curl wget git unzip gnupg lsb-release apt-transport-https ca-certificates)
} }
install_base install_base
pre_check pre_check
echo -e "${yellow}是否进行全自动安装?${plain}"
read -e -r -p "[Y/n]:" autoFlag
case $autoFlag in
[yY][eE][sS] | [yY])
autoFlag="1"
;;
[nN][oO] | [nN])
autoFlag="0"
;;
*)
autoFlag="1"
;;
esac
install_php() { install_php() {
echo -e "${green}开始安装PHP${plain}" echo -e "${green}开始安装PHP${plain}"
echo "默认安装php8.1" echo "默认安装php8.1"
@ -185,13 +199,13 @@ install_maraidb() {
dnf install ${MARIADB_PACKAGE_URL}/yum/10.6/centos/${os_version}/x86_64/mariadb-release-10.6-1.el8.noarch.rpm -y dnf install ${MARIADB_PACKAGE_URL}/yum/10.6/centos/${os_version}/x86_64/mariadb-release-10.6-1.el8.noarch.rpm -y
dnf install MariaDB-server MariaDB-client -y dnf install MariaDB-server MariaDB-client -y
fi fi
if [[ $autoFlag == "0" ]]; then
read -e -r -p "是否快速配置MariaDB? [Y/n] 默认 Y(es)" input read -e -r -p "是否快速配置MariaDB? [Y/n] 默认 Y(es)" input
case $input in case $input in
[yY][eE][sS] | [yY]) [yY][eE][sS] | [yY])
echo "开始快速配置MariaDB" echo "开始快速配置MariaDB"
mysql_secure_installation mysql_secure_installation
;; ;;
[nN][oO] | [nN]) [nN][oO] | [nN])
echo "不快速配置MariaDB" echo "不快速配置MariaDB"
;; ;;
@ -200,6 +214,19 @@ install_maraidb() {
mysql_secure_installation mysql_secure_installation
;; ;;
esac esac
else
PWD = "$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
mysql_secure_installation <<EOF
y
$PWD
$PWD
y
y
y
y
EOF
fi
} }
install_php install_php
@ -209,6 +236,7 @@ install_maraidb
setup_database() { setup_database() {
echo -e "${green}开始配置数据库${plain}" echo -e "${green}开始配置数据库${plain}"
echo -e "${yellow}请无比妥善保存以下信息${plain}" echo -e "${yellow}请无比妥善保存以下信息${plain}"
if [[ $autoFlag == "0" ]]; then
echo "自动生成数据库信息请输入1手动输入请输入2其他情况自动生成" echo "自动生成数据库信息请输入1手动输入请输入2其他情况自动生成"
read -e -r -p "请输入您的选择: " dbFlag read -e -r -p "请输入您的选择: " dbFlag
if [[ $dbFlag == "1" ]]; then if [[ $dbFlag == "1" ]]; then
@ -224,6 +252,11 @@ setup_database() {
db_name="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)" db_name="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)"
db_password="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)" db_password="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
fi fi
else
db_user="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)"
db_name="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)"
db_password="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
fi
echo -e "${yellow}数据库用户名: ${db_user}${plain}" echo -e "${yellow}数据库用户名: ${db_user}${plain}"
echo -e "${yellow}数据库名称: ${db_name}${plain}" echo -e "${yellow}数据库名称: ${db_name}${plain}"
echo -e "${yellow}数据库密码: ${db_password}${plain}" echo -e "${yellow}数据库密码: ${db_password}${plain}"
@ -278,4 +311,5 @@ download_lsky
setup_apache setup_apache
echo -e "${green}安装完成${plain}" echo -e "${green}安装完成${plain}"
echo -e "${green}请访问 http://${domain} 完成后续配置 ${plain}" echo -e "${green}请访问 http://${domain} 完成后续配置 ${plain}"