-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall-services.sh
More file actions
executable file
·46 lines (37 loc) · 1.32 KB
/
Copy pathuninstall-services.sh
File metadata and controls
executable file
·46 lines (37 loc) · 1.32 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
#!/bin/bash
# Telegram 监控系统 - Systemd 服务卸载脚本
set -e
# 颜色输出
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}==================================${NC}"
echo -e "${YELLOW} 卸载 Systemd 服务${NC}"
echo -e "${YELLOW}==================================${NC}"
echo ""
# 检查是否有 sudo 权限
if ! sudo -n true 2>/dev/null; then
echo -e "${YELLOW}需要 sudo 权限来卸载系统服务...${NC}"
sudo -v || exit 1
fi
# 停止并禁用服务
echo -e "${YELLOW}停止并禁用服务...${NC}"
sudo systemctl stop tg-monitor-backend.service 2>/dev/null || true
sudo systemctl stop tg-monitor-frontend.service 2>/dev/null || true
sudo systemctl disable tg-monitor-backend.service 2>/dev/null || true
sudo systemctl disable tg-monitor-frontend.service 2>/dev/null || true
# 删除服务文件
echo -e "${YELLOW}删除服务文件...${NC}"
sudo rm -f /etc/systemd/system/tg-monitor-backend.service
sudo rm -f /etc/systemd/system/tg-monitor-frontend.service
# 重新加载 systemd
echo -e "${YELLOW}重新加载 systemd 配置...${NC}"
sudo systemctl daemon-reload
sudo systemctl reset-failed
echo ""
echo -e "${GREEN}服务已成功卸载!${NC}"
echo ""
echo -e "${YELLOW}如需使用 start.sh 脚本启动服务,请运行:${NC}"
echo " ./start.sh start"
echo ""