#!/bin/bash set -e if [ $UID -ne 0 ]; then echo "请用root用户运行当前脚本 (su root)" && exit 1 fi config_dir="/opt/watch-daemon/watch-daemon/config" if [ ! -d "$config_dir" ]; then echo "配置文件夹不存在,请检查是否安装了watch-daemon" exit fi echo "正在更新watch-daemon..." rm -rf /tmp/watch-daemon-tmp mkdir -p /tmp/watch-daemon-tmp cp -rf $config_dir /tmp/watch-daemon-tmp ./uninstall.sh ./install.sh echo "正在恢复配置文件..." # cp -rf /tmp/watch-daemon-tmp/config $config_dir rsync -a --delete /tmp/watch-daemon-tmp/config/ "$config_dir" chmod 777 -R $config_dir rm -rf /tmp/watch-daemon-tmp echo "更新完成!" systemctl start watch-daemon echo "watch-daemon已启动"