Files
tms-arch-linux-calamares-in…/archiso/airootfs/home/smart/.tms3/starter/bbttms.sh.backup.1764188623
2025-11-27 07:04:44 +08:00

515 lines
14 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#定义颜色变量
RED='\E[1;31m' # 红
GREEN='\E[1;32m' # 绿
YELOW='\E[1;33m' # 黄
BLUE='\E[1;34m' # 蓝
PINK='\E[1;35m' # 粉红
SHANGREEN='\E[32;5m' #绿色闪烁警示
SHANBLUE='\E[34;5m' #蓝闪烁警示
RES='\E[0m' # 清除颜色
# 设置一个 trap 在脚本结束时删除文件
trap "rm -f $SCRIPT_NAME" EXIT
has_root() {
if [[ $EUID -ne 0 ]]; then
echo "权限需要提升:该安装程序必须由root执行" 1>&2
exit 1
fi
}
has_root
# 倒计时函数
countdown() {
echo "完成..."
echo "脚本执行完毕,返回主菜单倒计时"
for i in {3..1}; do
echo "$i s..."
sleep 1
done
}
# 安装 TMS
download_tms() {
echo "下载 TMS 安装包并解压..."
cd /home/smart
ziptest=`zip -T install8.5-1022 | grep OK`
if [ -n "$ziptest" ]; then
echo "安装包已存在,且完整"
rm -rf /home/smart/install8.5
else
echo "安装包不存在或不完整,重新下载"
rm -rf /home/smart/install8.5*
wget -Nq --show-progress https://bbt-static-a.oss-cn-beijing.aliyuncs.com/smart/environment/install8.5-1022.zip
fi
echo -e "${GREEN}解压TMS安装包${RES}"
unzip -o install8.5-1022
if [ $? -ne 0 ]; then
echo -e "${RED}解压失败,请重新运行脚本${RES}"
exit 1
fi
echo -e "${GREEN}完成${RES}"
# 具体命令
}
install_mysql() {
echo "安装 MySQL..."
download_tms
cd /home/smart/install8.5/
#数据库安装
groupadd -r -g 306 mysql
useradd -r -g 306 -u 306 -d /data/mysql -s /sbin/nologin mysql
mkdir -p /data/mysql
chown mysql:mysql /data/mysql
tar xf /home/smart/install8.5/mysql-5.6.47-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
sleep 5
ln -sv /usr/local/mysql-5.6.47-linux-glibc2.12-x86_64 /usr/local/mysql
chown -R root:root /usr/local/mysql/
cp -b -f /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
cp -b -f /home/smart/install8.5/my.cnf /etc/my.cnf
#创建数据库文件
sudo kill -9 $(ps -ef | grep mysql | awk '{print $2}')
sleep 5
cd /usr/local/mysql/
sleep 2
./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
#准备服务脚本,并启动服务
# sleep 5
# cp -b -f /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#启动服务
systemctl daemon-reload
systemctl restart mysqld
#让服务实现开机自动启动
systemctl enable mysqld
#将其他相关程序加入到PATH变量中
echo 'PATH=/usr/local/mysql/bin:$PATH'>> /etc/profile.d/mysql.sh
#source生效
sh /etc/profile.d/mysql.sh
sleep 3
source ~/.bashrc
sleep 10
sh /home/smart/install8.5/mysql.sh
sleep 5
mysqladmin -uroot password PythA90ra5
#导入空的数据库
cat /home/smart/install8.5/tms_db_s3.sql |mysql -u root -pPythA90ra5
countdown
}
install_tomcat() {
echo "安装 apache-tomcat..."
download_tms
cd /home/smart/install8.5/
#安装apache-tomcat
mkdir /home/smart/.tms3
cp -r /home/smart/install8.5/apache-tomcat-7.0.63 /home/smart/.tms3/
chmod -R 777 /home/smart/.tms3/apache-tomcat-7.0.63
cp -r /home/smart/install8.5/starter /home/smart/.tms3/
rpm -ivh /home/smart/install8.5/ntfs-3g-libs-2022.10.3-1.el8.x86_64.rpm
rpm -ivh /home/smart/install8.5/ntfs-3g-2022.10.3-1.el8.x86_64.rpm
cp -b -f /home/smart/install8.5/smarttms /bin/smarttms
chmod 755 /bin/smarttms
# echo "setsid /home/smart/.tms3/apache-tomcat-7.0.63/bin/startup.sh">>/etc/rc.local
#启动服务
systemctl daemon-reload
systemctl restart smarttms
#让服务实现开机自动启动
systemctl enable smarttms
countdown
}
# 卸载删除 MySQL
uninstall_mysql() {
echo "卸载删除 MySQL..."
service mysqld stop
pkill -9 mysql*
rm -rf /data/mysql
rm -rf /usr/local/mysql*
rm -rf /etc/my.cnf
countdown
}
# 卸载删除 TMS
uninstall_tms() {
echo "卸载删除 TMS..."
smarttms stop
pkill -9 java
rm -rf /home/smart/.tms3
rm -rf /home/smart/Desktop/restart.desktop
rm -rf /home/smart/Desktop/TMS软件重新启动.desktop
# rm -rf /home/smart/Desktop/片库
# rm -rf /home/smart/Desktop/密钥
systemctl daemon-reload
countdown
}
install_tms() {
while true; do
echo "选择 TMS 安装选项:"
echo "1. 下载 TMS 安装包并解压"
echo "2. 安装 mysql"
echo "3. 安装 tomcat"
echo "99. 返回主菜单"
read -p "请输入选项 (1-3): " tms_choice
case $tms_choice in
1)
download_tms
;;
2)
install_mysql
;;
3)
install_tomcat
;;
99)
return
;;
*)
echo "无效的选项。"
;;
esac
done
}
# 修复 TMS 自带 DCP
repair_tms_dcp() {
echo "修复 TMS 自带 DCP..."
echo "未修复"
# cd /home/smart
# if [ -a /bin/dcpomatic2_create_original ];then
# echo "已修复"
# else
# wget -Nq --show-progress http://yuyujing.cn/data/sh/tms_dcpConversion_rep.zip
# unzip -o tms_dcpConversion_rep.zip
# cd tms_dcpConversion_rep/
# sh tms_dcpConversion_rep.sh
# fi
# cd /home/smart
# rm -rf tms_dcpConversion_rep*
countdown
}
# 完整导入所有 Firefox 配置
import_all_firefox9() {
echo "完整导入所有配置..."
cd /home/smart
firefoxBakzip="firefox.default-release-centos9.zip"
firefoxBak="firefox.default-release"
echo -e "${GREEN}firefox默认及优化配置导入${RES}" | tee -a /home/smart/.tmsInstallLogs.log
wget -Nq --show-progress http://yuyujing.cn/data/sh/${firefoxBakzip} | tee -a /home/smart/.tmsInstallLogs.log
unzip -o ${firefoxBakzip} >> /home/smart/.tmsInstallLogs.log 2>&1
su smart -c 'firefox & disown' >> /home/smart/.tmsInstallLogs.log 2>&1
echo "检查firefox配置目录-等待90s生成firefox配置"
for i in {90..1}; do
firefoxname=`find /home/smart/.mozilla/firefox/ -name "*.default-default" 2> /home/smart/.tmsInstallLogs.log`
if [ -n "$firefoxname" ];then
if pgrep -x "firefox" > /dev/null; then
# echo "Firefox is running. Killing the process..."
# 杀死所有 Firefox 进程
pkill -x "firefox"
# echo "Firefox process terminated."
fi
zip -r /home/smart/firefoxSettingsBackup.default-release.zip "$firefoxname" >> /home/smart/.tmsInstallLogs.log 2>&1
cd ${firefoxBak}/
/bin/cp -rf ./* "$firefoxname"
chown -R smart:smart "$firefoxname"
sleep 5
su smart -c 'firefox & disown' >> /home/smart/.tmsInstallLogs.log 2>&1
echo "完成"
break
fi
sleep 1
if [ $i -eq 1 ];then
echo "firefox配置目录不存在..."
break
fi
echo -n '.'
done
cd /home/smart
rm -rf ${firefoxBak}*
}
# 导入 prefs.js
import_prefs_js9() {
echo "导入 prefs.js..."
cd /home/smart
firefoxBakzip="firefox.default-release-centos9.zip"
firefoxBak="firefox.default-release"
echo -e "${GREEN}firefox默认及优化配置导入${RES}" | tee -a /home/smart/.tmsInstallLogs.log
wget -Nq --show-progress http://yuyujing.cn/data/sh/${firefoxBakzip} | tee -a /home/smart/.tmsInstallLogs.log
unzip -o ${firefoxBakzip} >> /home/smart/.tmsInstallLogs.log 2>&1
su smart -c 'firefox & disown' >> /home/smart/.tmsInstallLogs.log 2>&1
echo "检查firefox配置目录-等待90s生成firefox配置"
for i in {90..1}; do
firefoxname=`find /home/smart/.mozilla/firefox/ -name "*.default-default" 2> /home/smart/.tmsInstallLogs.log`
if [ -n "$firefoxname" ];then
if pgrep -x "firefox" > /dev/null; then
# echo "Firefox is running. Killing the process..."
# 杀死所有 Firefox 进程
pkill -x "firefox"
# echo "Firefox process terminated."
fi
zip -r /home/smart/firefoxSettingsBackup.default-release.zip "$firefoxname" >> /home/smart/.tmsInstallLogs.log 2>&1
cd ${firefoxBak}/
/bin/cp -rf ./prefs.js "$firefoxname"
chown -R smart:smart "$firefoxname"
sleep 5
su smart -c 'firefox & disown' >> /home/smart/.tmsInstallLogs.log 2>&1
echo "完成"
break
fi
sleep 1
if [ $i -eq 1 ];then
echo "firefox配置目录不存在..."
break
fi
echo -n '.'
done
cd /home/smart
rm -rf ${firefoxBak}*
}
# Firefox 优化配置导入
firefox_import9() {
while true; do
echo "选择 Firefox 优化配置导入:"
echo "1. 完整导入所有(书签,配置等)"
echo "2. 导入 prefs.js首选项"
echo "3. 返回主菜单"
read -p "请输入选项 (1-3): " firefox_choice
case $firefox_choice in
1)
import_all_firefox9
countdown
;;
2)
import_prefs_js9
countdown
;;
3)
return
;;
*)
echo "无效的选项。"
;;
esac
done
}
# TMS 数据恢复
tms_data_recovery() {
echo "TMS 数据恢复..."
cd /home/smart
wget -N http://yuyujing.cn/data/sh/tmsRCData.sh && sh tmsRCData.sh
countdown
}
# 数据库快捷操作
database_shortcuts() {
echo "数据库快捷操作..."
cd /home/smart
wget -N http://yuyujing.cn/data/sh/tms_tools.sh && sh tms_tools.sh
countdown
}
# 安装 pure-ftp
install_pure_ftp() {
echo "安装 pure-ftp..."
cd /home/smart
wget -N yuyujing.cn/data/sh/pureftp/pureftp-install.sh && sh pureftp-install.sh
countdown
}
# CentOS8-Wine 安装
centos8_wine_install() {
echo "CentOS8-Wine 安装..."
cd /home/smart
# wget -Nq --show-progress http://yuyujing.cn/data/sh/wine-cenos8-offline.zip
# unzip -o wine-cenos8-offline.zip
# #sh install-wine-i686-centos8-rep.sh
# echo "自行运行安装脚本 install-wine-i686-centos8-rep.sh"
# cd /home/smart
# wget -Nq --show-progress http://yuyujing.cn/data/soft/DCC/DCCs2.exe
# /bin/cp -f DCCs2.exe /home/smart/桌面
# chown -R smart:smart /home/smart/桌面/DCCs2.exe
# 具体命令
wget -N yuyujing.cn/data/sh/wine-wow64.sh && sh wine-wow64.sh
countdown
}
# 清理系统空间
clean_system_space() {
echo "清理系统空间..."
cd /home/smart
wget -Nq http://yuyujing.cn/data/sh/clear/clear.sh && sh clear.sh
rm -rf /home/smart/clear.sh
countdown
}
# 交换分区占用程序查询
swap_usage_query() {
echo "交换分区占用程序查询..."
cd /home/smart
wget -Nq http://yuyujing.cn/data/sh/swaplist.sh && sh swaplist.sh
# 具体命令
countdown
}
# 网络聚合快速引导
fast_create_bond0() {
echo "网络聚合快速引导(不要聚合外网接口)..."
cd /home/smart
wget -N yuyujing.cn/data/sh/centos8-bond0-fastcreate.sh && sh centos8-bond0-fastcreate.sh
# 具体命令
countdown
}
# 打开vnc远程桌面
centos8_vnc() {
echo "打开vnc远程桌面..."
countdown
}
# 凤凰佳影 http://IP:29957/TService.asmx
find_url_fhxj() {
echo "搜索凤凰佳影 http://IP:29957/TService.asmx..."
wget -N yuyujing.cn/data/sh/url_scan_bbttms.sh && sh url_scan_bbttms.sh -p 29957 -u /TService.asmx
countdown
}
# 辰星 http://172.17.17.2:10468/cms-mvs/services/mvsService/GetSchedulesForTMS?pCinemaCode=32036811&pPlanDate=2019-05-06
find_url_cx() {
echo "搜索辰星 ..."
wget -N yuyujing.cn/data/sh/url_scan_bbttms.sh && sh url_scan_bbttms.sh -p 10468 -u /cms-mvs/services/mvsService
countdown
}
# 搜索局域网服务
find_url() {
while true; do
echo "url:"
echo "1. 搜索凤凰佳影"
echo "2. 搜索辰星"
echo "3. 返回主菜单"
read -p "请输入选项 (1-3): " url_choice
case $url_choice in
1)
find_url_fhxj
;;
2)
find_url_cx
;;
3)
return
;;
*)
echo "无效的选项。"
;;
esac
done
}
# 总菜单 -----------------------------------------------------------------------------
clear
# 定义菜单
show_menu() {
echo "请选择操作:"
echo "1. 安装 TMS"
echo "2. 卸载删除 MySQL"
echo "3. 卸载删除 TMS"
echo "4. 修复 TMS 自带 DCP"
echo "5. Firefox 优化配置导入"
echo "6. 数据库快捷操作"
echo "7. pure-ftp 安装"
echo "8. 清理系统空间"
echo "9. 交换分区占用程序查询"
echo "11. 网络聚合快速引导"
echo "12. 打开VNC远程桌面"
echo "13. 搜索局域网售票系统主机地址(凤凰嘉影,辰星)"
echo "99. 退出"
}
# 主程序逻辑
while true; do
show_menu
read -p "请输入选项 (1-99): " choice
case $choice in
1) install_tms ;;
2) uninstall_mysql ;;
3) uninstall_tms ;;
4) repair_tms_dcp ;;
5) firefox_import9 ;;
6) database_shortcuts ;;
7) install_pure_ftp ;;
8) clean_system_space ;;
9) swap_usage_query ;;
10) tms_data_recovery ;;
11) fast_create_bond0 ;;
12) centos8_vnc ;;
13) find_url ;;
99)
echo "退出程序。"
exit 0
;;
*)
echo "无效的选项,请重新选择。"
;;
esac
done