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,21 +199,34 @@ 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
read -e -r -p "是否快速配置MariaDB? [Y/n] 默认 Y(es)" input if [[ $autoFlag == "0" ]]; then
case $input in read -e -r -p "是否快速配置MariaDB? [Y/n] 默认 Y(es)" input
[yY][eE][sS] | [yY]) case $input in
echo "开始快速配置MariaDB" [yY][eE][sS] | [yY])
mysql_secure_installation echo "开始快速配置MariaDB"
;; mysql_secure_installation
;;
[nN][oO] | [nN])
echo "不快速配置MariaDB"
;;
*)
echo "开始快速配置MariaDB"
mysql_secure_installation
;;
esac
else
PWD = "$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
mysql_secure_installation <<EOF
[nN][oO] | [nN]) y
echo "不快速配置MariaDB" $PWD
;; $PWD
*) y
echo "开始快速配置MariaDB" y
mysql_secure_installation y
;; y
esac EOF
fi
} }
install_php install_php
@ -209,16 +236,22 @@ install_maraidb
setup_database() { setup_database() {
echo -e "${green}开始配置数据库${plain}" echo -e "${green}开始配置数据库${plain}"
echo -e "${yellow}请无比妥善保存以下信息${plain}" echo -e "${yellow}请无比妥善保存以下信息${plain}"
echo "自动生成数据库信息请输入1手动输入请输入2其他情况自动生成" if [[ $autoFlag == "0" ]]; then
read -e -r -p "请输入您的选择: " dbFlag echo "自动生成数据库信息请输入1手动输入请输入2其他情况自动生成"
if [[ $dbFlag == "1" ]]; then read -e -r -p "请输入您的选择: " dbFlag
db_user="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)" if [[ $dbFlag == "1" ]]; then
db_name="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)" db_user="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_name="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)"
elif [[ $dbFlag == "2" ]]; then db_password="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
read -e -r -p "请输入数据库用户名: " db_user elif [[ $dbFlag == "2" ]]; then
read -e -r -p "请输入数据库名称: " db_name read -e -r -p "请输入数据库用户名: " db_user
read -e -r -p "请输入数据库密码: " db_password read -e -r -p "请输入数据库名称: " db_name
read -e -r -p "请输入数据库密码: " db_password
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
else else
db_user="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)" 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_name="lsky_$(openssl rand -base64 12 | tr -dc 'a-z0-9' | fold -w 8 | head -n 1)"
@ -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}"