-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
65 lines (49 loc) · 1.36 KB
/
Copy pathinstall.sh
File metadata and controls
65 lines (49 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -e
APP_DIR="/opt/pingmonitor"
echo "=============================="
echo " PingMonitor 安装开始"
echo "=============================="
apt update -y
apt install -y \
python3 \
python3-pip \
iputils-ping \
sudo
echo "安装Python依赖"
pip3 install flask requests --break-system-packages || pip3 install flask requests
echo "创建目录与初始化日志文件"
mkdir -p $APP_DIR/templates
mkdir -p $APP_DIR/logs
touch $APP_DIR/logs/monitor.log
chmod 666 $APP_DIR/logs/monitor.log
echo "复制程序文件"
cp monitor.py $APP_DIR/
cp web.py $APP_DIR/
cp config.json $APP_DIR/
cp templates/index.html $APP_DIR/templates/
cp pingmonitor.service /etc/systemd/system/
cp pingmonitor-web.service /etc/systemd/system/
echo "配置 sudo 权限"
mkdir -p /etc/sudoers.d
cp sudoers/pingmonitor /etc/sudoers.d/pingmonitor
chmod 440 /etc/sudoers.d/pingmonitor
echo "设置目录文件权限"
chown -R www-data:www-data $APP_DIR
chmod -R 777 $APP_DIR/logs
chmod 666 $APP_DIR/logs/monitor.log
echo "启动服务"
systemctl daemon-reload
systemctl enable pingmonitor
systemctl enable pingmonitor-web
systemctl restart pingmonitor
systemctl restart pingmonitor-web
IP=$(hostname -I | awk '{print $1}')
echo ""
echo "=============================="
echo "安装完成"
echo ""
echo "Web管理地址:"
echo "http://${IP}:5000"
echo ""
echo "=============================="