update.sh 844 B

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