install.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. if [ $UID -ne 0 ]; then
  3. echo "请用root用户运行当前脚本 (su root)" && exit 1
  4. fi
  5. if [ -r /opt/watch-daemon/watch-daemon ];then
  6. echo "/opt/watch-daemon/watch-daemon文件夹已存在,请重命名旧版本文件后再尝试"
  7. exit
  8. fi
  9. root_dir=/opt/watch-daemon
  10. if [ ! -d "$root_dir" ]; then
  11. mkdir -p $root_dir
  12. fi
  13. ARCH="`uname -m`"
  14. PKG_NAME="watch-daemon"
  15. if [ "$ARCH" == "aarch64" ]; then
  16. echo "安装arm64版本"
  17. PKG_NAME="watch-daemon-arm64"
  18. elif [ "$ARCH" == "x86_64" ]; then
  19. echo "安装x64版本"
  20. PKG_NAME="watch-daemon-x64"
  21. else
  22. echo "不支持的架构: $ARCH"
  23. exit
  24. fi
  25. tar zxf ./$PKG_NAME.tar.gz -C $root_dir
  26. cp -f watch-daemon.service /etc/systemd/system/
  27. if [ ! -r /opt/watch-daemon/watch-daemon ];then
  28. echo "安装失败!"
  29. exit
  30. else
  31. echo "安装成功!"
  32. fi
  33. chmod +x /opt/watch-daemon/watch-daemon/*.sh
  34. DATA_DIR=/var/lib/tsdb_data/
  35. echo -n "初始化数据目录 $DATA_DIR..."
  36. mkdir -p $DATA_DIR
  37. chmod 777 $DATA_DIR
  38. echo " 完成"
  39. systemctl daemon-reload
  40. systemctl enable watch-daemon
  41. systemctl start watch-daemon
  42. echo "watch-daemon已启动"