Skip to content

Commit acd3a27

Browse files
author
ubuntu
committed
增加客户端自动部署脚本: client-auto.sh,代码所有: https://github.com/dovela
1 parent 87d0e92 commit acd3a27

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

autodeploy/client-auto.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
# author: https://github.com/dovela/ServerStatus1Click
3+
# 支持操作系统:centos,debian,ubuntu,redhat 其它未测试
4+
# 时间: 20180626
5+
6+
[ $(id -u) != "0" ] && { echo "Error: You must be root to run this script"; exit 1; }
7+
install_sss(){
8+
clear
9+
stty erase '^H' && read -p " 服务端地址:" sserver
10+
stty erase '^H' && read -p " 客户端username:" suser
11+
stty erase '^H' && read -p " 客户端password:" spasswd
12+
clear
13+
git clone https://github.com/dovela/ServerStatus.git
14+
rm -rf oneclick.sh
15+
echo 'ServerStatus客户端安装完成'
16+
cd ServerStatus/clients
17+
sed -i -e "s/sserver/$sserver/g" client-linux.py
18+
sed -i -e "s/suser/$suser/g" client-linux.py
19+
sed -i -e "s/spasswd/$spasswd/g" client-linux.py
20+
sed -i -e "s/sserver/$sserver/g" client-psutil.py
21+
sed -i -e "s/suser/$suser/g" client-psutil.py
22+
sed -i -e "s/spasswd/$spasswd/g" client-psutil.py
23+
clear
24+
echo ' ServerStatus客户端配置完成,请进行下一步'
25+
echo ' 1. 运行 client-linux'
26+
echo ' 2. 运行 client-psutil'
27+
stty erase '^H' && read -p " 请输入数字 [1-2]:" num
28+
case "$num" in
29+
1)
30+
run_linux
31+
;;
32+
2)
33+
run_psutil
34+
;;
35+
esac
36+
}
37+
38+
run_linux(){
39+
nohup python client-linux.py >> serverstatus.log 2>&1 &
40+
cd ../..
41+
echo 'ServerStatus-linux客户端已开始运行'
42+
}
43+
44+
run_psutil(){
45+
nohup python client-psutil.py >> serverstatus.log 2>&1 &
46+
cd ../..
47+
echo 'ServerStatus-psutil客户端已开始运行'
48+
}
49+
50+
install_env(){
51+
clear
52+
yum install -y git lsof
53+
apt-get install -y git lsof
54+
yum -y install epel-release
55+
yum clean all
56+
yum -y install python-pip gcc python-devel
57+
apt-get -y install python-setuptools python-dev build-essential python-pip
58+
pip install --upgrade
59+
pip install psutil
60+
clear
61+
echo '依赖环境安装完成,请再次运行脚本'
62+
}
63+
64+
clear
65+
echo -e " 注意:此脚本基于centos7编写,默认端口35601,出现问题请在 @dovela 处提issue
66+
67+
————————————
68+
1.首次安装并启动 ServerStatus客户端
69+
2.运行 client_linux
70+
3.运行 client_psutil
71+
4.停止运行
72+
5.首次安装依赖,直接安装失败请执行
73+
————————————
74+
输入数字开始,或ctrl + c退出
75+
"
76+
echo && stty erase '^H' && read -p " 请输入数字[1-5]:" num
77+
case "$num" in
78+
1)
79+
install_sss
80+
;;
81+
2)
82+
cd ServerStatus/clients
83+
run_linux
84+
;;
85+
3)
86+
cd ServerStatus/clients
87+
run_psutil
88+
;;
89+
4)
90+
kill -9 $(lsof -i:35601 |awk '{print $2}' | tail -n 1)
91+
;;
92+
5)
93+
install_env
94+
;;
95+
*)
96+
echo -e "${Error} 请输入正确的数字 [1-5]!"
97+
;;
98+
esac
99+

0 commit comments

Comments
 (0)