install.sh 833 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # NOTE: App is installed to /opt/$APP_COMPARTMENT/$APP_MODULE
  3. APP_COMPARTMENT="nginx-green"
  4. APP_MODULE="nginx-green"
  5. if [ $UID -ne 0 ]; then
  6. echo "请用root用户运行当前脚本 (su root)" && exit 1
  7. fi
  8. if [ -r /opt/$APP_COMPARTMENT/$APP_MODULE ];then
  9. echo "/opt/$APP_COMPARTMENT/$APP_MODULE 文件夹已存在,请重命名旧版本文件后再尝试"
  10. exit
  11. fi
  12. root_dir=/opt/$APP_COMPARTMENT
  13. if [ ! -d "$root_dir" ]; then
  14. mkdir -p $root_dir
  15. fi
  16. tar zxf ./$APP_MODULE.tar.gz -C $root_dir
  17. cp -f $APP_MODULE.service /usr/lib/systemd/system/
  18. if [ ! -r /opt/$APP_COMPARTMENT/$APP_MODULE ];then
  19. echo "安装失败!"
  20. exit
  21. else
  22. echo "安装成功!"
  23. fi
  24. chmod +x /opt/$APP_COMPARTMENT/$APP_MODULE/*.sh
  25. chmod +x /opt/$APP_COMPARTMENT/$APP_MODULE/bin/*
  26. systemctl daemon-reload