HFish/install

130 lines
3.8 KiB
Plaintext
Raw Normal View History

2021-06-23 22:47:17 +08:00
#!/bin/bash
#初始化
initVar() {
installType='yum -y install'
removeType='yum -y remove'
upgrade="yum -y update"
echoType='echo -e'
2021-08-03 17:46:26 +08:00
version='2.5.0'
2021-06-23 22:47:17 +08:00
}
initVar
export LANG=en_US.UTF-8
#字体颜色
echoContent() {
case $1 in
# 红色
"red")
# shellcheck disable=SC2154
${echoType} "\033[31m${printN}$2 \033[0m"
;;
# 天蓝色
"skyBlue")
${echoType} "\033[1;36m${printN}$2 \033[0m"
;;
# 绿色
"green")
${echoType} "\033[32m${printN}$2 \033[0m"
;;
# 白色
"white")
${echoType} "\033[37m${printN}$2 \033[0m"
;;
"magenta")
${echoType} "\033[31m${printN}$2 \033[0m"
;;
# 黄色
"yellow")
${echoType} "\033[33m${printN}$2 \033[0m"
;;
esac
}
#首页菜单
menu() {
echoContent red "\n==============================================================\n"
2021-08-03 17:46:26 +08:00
echoContent green "当前版本v${version}"
2021-06-23 22:47:17 +08:00
echoContent green "HFish官网 https://hfish.io "
echoContent red "\n==============================================================\n"
echoContent skyBlue "-------------------------安装部署-----------------------------\n"
echoContent yellow "1.安装并运行HFish单机版"
echoContent yellow "2.安装并运行HFish集群版控制端"
2021-08-02 17:56:47 +08:00
echoContent yellow "3.退出安装"
# echoContent yellow "4.用Docker运行HFish控制端"
2021-06-23 22:47:17 +08:00
# echoContent skyBlue "\n-------------------------配置管理-----------------------------\n"
# echoContent yellow "5.防火墙放通控制端端口coming soon"
# echoContent yellow "6.将HFish添加为系统服务coming soon"
# echoContent yellow "7.将控制端数据库替换为MariaDBcoming soon"
# echoContent skyBlue "\n-------------------------运维管理-----------------------------\n"
# echoContent yellow "8.将错误日志反馈给开发者coming soon"
# echoContent yellow "9.卸载HFishcoming soon"
echoContent red "\n=============================================================="
read -r -p "请选择:" selectMenuType
case ${selectMenuType} in
1):
standaloneInstall
;;
2):
serverInstall
;;
2021-08-02 17:56:47 +08:00
3)
exitInstall
2021-06-23 22:47:17 +08:00
;;
*)
echoContent red ' ---> 选择错误,重新选择'
selectMenuType
;;
esac
}
standaloneInstall(){
2021-08-03 17:46:26 +08:00
cd /opt
2021-06-23 22:47:17 +08:00
if [ $(uname -s) = 'Linux' ] && [ $(uname -m) = 'x86_64' ] && [ $(getconf LONG_BIT) = '64' ]; then
2021-08-03 17:46:26 +08:00
wget -N --no-check-certificate http://hfish.cn-bj.ufileos.com/hfish-standalone-${version}-linux-amd64.tar.gz
2021-06-23 22:47:17 +08:00
elif [ $(uname -m) = 'aarch64' ] && [ $(getconf LONG_BIT) = '64' ]; then
2021-08-03 17:46:26 +08:00
wget -N --no-check-certificate http://hfish.cn-bj.ufileos.com/hfish-standalone-${version}-linux-arm64.tar.gz
2021-06-23 22:47:17 +08:00
else
echoContent red "未检测到系统版本,请参阅 https://hfish.io 官网文档手动安装!\n" && exit 1
fi
2021-08-03 17:46:26 +08:00
tar -zxvf /opt/hfish-standalone*.tar.gz
2021-06-23 22:47:17 +08:00
cd /opt/hfish && nohup ./server &
sleep 2
cd /opt/hfish/client && nohup ./client &
}
serverInstall() {
2021-08-03 17:46:26 +08:00
cd /opt
2021-06-23 22:47:17 +08:00
if [ $(uname -s) = 'Linux' ] && [ $(uname -m) = 'x86_64' ] && [ $(getconf LONG_BIT) = '64' ]; then
2021-08-03 17:46:26 +08:00
wget -N --no-check-certificate http://hfish.cn-bj.ufileos.com/hfish-${version}-linux-amd64.tar.gz
2021-06-23 22:47:17 +08:00
elif [ $(uname -m) = 'aarch64' ] && [ $(getconf LONG_BIT) = '64' ]; then
2021-08-03 17:46:26 +08:00
wget -N --no-check-certificate http://hfish.cn-bj.ufileos.com/hfish-${version}-linux-arm64.tar.gz
2021-06-23 22:47:17 +08:00
else
echoContent red "未检测到系统版本,请参阅 https://hfish.io 官网文档手动安装!\n" && exit 1
fi
2021-08-02 17:56:47 +08:00
mkdir -p hfish
2021-08-03 17:46:26 +08:00
tar -zxvf /opt/hfish*.tar.gz -C hfish
2021-06-23 22:47:17 +08:00
cd hfish
nohup ./server &
}
2021-08-02 17:56:47 +08:00
exitInstall() {
exit 1
2021-06-23 22:47:17 +08:00
}
2021-08-02 17:56:47 +08:00
# selectServiceInstall() {
# if [ -d "/opt/hfish/packages" ]; then
# cd /opt/hfish/packages
# wget http://img.threatbook.cn/hfish/svc/services-2.4.0.tar.gz
# tar zxvf services*.tar.gz
# rm -f services-2.4.0.tar.gz
# else
# echoContent red "未检测到安装目录,请参阅 https://hfish.io 官网文档手动安装!\n" && exit 1
# fi
# }
2021-08-03 17:46:26 +08:00
cd /opt
2021-06-23 22:47:17 +08:00
menu