install.sh 700 B

1234567891011121314151617181920212223242526
  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. tar zxf ./watch-daemon.tar.gz -C $root_dir
  14. cp -f watch-daemon.service /usr/lib/systemd/system/
  15. if [ ! -r /opt/watch-daemon/watch-daemon ];then
  16. echo "安装失败!"
  17. exit
  18. else
  19. echo "安装成功!"
  20. fi
  21. chmod +x /opt/watch-daemon/watch-daemon/*.sh
  22. chmod +x /opt/watch-daemon/watch-daemon/lib/*
  23. systemctl daemon-reload