update.sh 734 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. set -e
  3. if [ $UID -ne 0 ]; then
  4. echo "请用root用户运行当前脚本 (su root)" && exit 1
  5. fi
  6. config_dir="/opt/watch-daemon/watch-daemon/config"
  7. if [ ! -d "$config_dir" ]; then
  8. echo "配置文件夹不存在,请检查是否安装了watch-daemon"
  9. exit
  10. fi
  11. echo "正在更新watch-daemon..."
  12. rm -rf /tmp/watch-daemon-tmp
  13. mkdir -p /tmp/watch-daemon-tmp
  14. cp -rf $config_dir /tmp/watch-daemon-tmp
  15. ./uninstall.sh
  16. ./install.sh
  17. echo "正在恢复配置文件..."
  18. # cp -rf /tmp/watch-daemon-tmp/config $config_dir
  19. rsync -a --delete /tmp/watch-daemon-tmp/config/ "$config_dir"
  20. chmod 777 -R $config_dir
  21. rm -rf /tmp/watch-daemon-tmp
  22. echo "更新完成!"
  23. systemctl start watch-daemon
  24. echo "watch-daemon已启动"