btpanel/bt.sh
cnb.ZYsjO8G6wGA a2d3171ef5 chore: 更新 bt.sh 脚本以增强系统安全和功能
在 bt.sh 脚本中,已进行以下修改:
1. 将 `/sbin/crond` 更新为 `/usr/sbin/crond`,以确保使用正确的 crond 路径。
2. 新增 `ssh-keygen -A` 命令,用于生成 SSH 密钥对,增强系统安全性。
这些修改旨在提升脚本的稳定性和安全性。
2024-12-05 15:52:49 +08:00

77 lines
1.7 KiB
Bash

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
init_path=/etc/init.d
Root_Path=`cat /var/bt_setupPath.conf`
Setup_Path=$Root_Path/server/mysql
Data_Path=$Root_Path/server/data
O_pl=$(cat /www/server/panel/data/o.pl)
soft_start(){
# 扫描并启动所有服务
init_scripts=$(ls ${init_path})
for script in ${init_scripts}; do
case "${script}" in
"bt"|"mysqld"|"nginx"|"httpd")
continue
;;
esac
${init_path}/${script} start
done
if [ -f ${init_path}/nginx ]; then
${init_path}/nginx start
elif [ -f ${init_path}/httpd ]; then
${init_path}/httpd start
fi
${init_path}/bt stop
${init_path}/bt start
pkill crond
/usr/sbin/crond
ssh-keygen -A
chmod 600 /etc/ssh/ssh_host_*
/usr/sbin/sshd &
}
init_mysql(){
if [ "${O_pl}" != "docker_btlamp_r9" ] && [ "${O_pl}" != "docker_btlnmp_r9" ];then
return
fi
if [ -d "${Data_Path}" ]; then
check_z=$(ls "${Data_Path}")
echo "check_z:"
echo ${check_z}
if [[ ! -z "${check_z}" ]]; then
echo "check_z is not empty"
return
fi
fi
if [ -f /init_mysql.sh ] && [ -d "${Setup_Path}" ];then
bash /init_mysql.sh
rm -f /init_mysql.sh
fi
}
is_empty_Data(){
return "$(ls -A ${Data_Path}/|wc -w)"
}
start_mysql(){
if [ -d "${Setup_Path}" ] && [ -f "${init_path}/mysqld" ];then
chown -R mysql:mysql ${Data_Path}
chgrp -R mysql ${Setup_Path}/.
${init_path}/mysqld start
fi
}
is_empty_Data > /dev/null
init_mysql > /dev/null
start_mysql > /dev/null
soft_start > /dev/null
#tail -f /dev/null
${init_path}/bt log