#!/bin/bash if [ $UID -ne 0 ]; then echo "请用root用户运行当前脚本 (su root)" && exit 1 fi if [ -r /opt/watch-daemon/watch-daemon ];then echo "/opt/watch-daemon/watch-daemon文件夹已存在,请重命名旧版本文件后再尝试" exit fi root_dir=/opt/watch-daemon if [ ! -d "$root_dir" ]; then mkdir -p $root_dir fi ARCH="`uname -m`" PKG_NAME="watch-daemon" if [ "$ARCH" == "aarch64" ]; then echo "安装arm64版本" PKG_NAME="watch-daemon-arm64" elif [ "$ARCH" == "x86_64" ]; then echo "安装x64版本" PKG_NAME="watch-daemon-x64" else echo "不支持的架构: $ARCH" exit fi tar zxf ./$PKG_NAME.tar.gz -C $root_dir cp -f watch-daemon.service /etc/systemd/system/ if [ ! -r /opt/watch-daemon/watch-daemon ];then echo "安装失败!" exit else echo "安装成功!" fi chmod +x /opt/watch-daemon/watch-daemon/*.sh DATA_DIR=/var/lib/tsdb_data/ echo -n "初始化数据目录 $DATA_DIR..." mkdir -p $DATA_DIR chmod 777 $DATA_DIR echo " 完成" systemctl daemon-reload systemctl enable watch-daemon systemctl start watch-daemon echo "watch-daemon已启动"