12345678910111213141516171819202122232425262728293031323334 |
- #!/bin/bash
- if [ $UID -ne 0 ]; then
- echo "请用root用户运行当前脚本 (su root)" && exit 1
- fi
- APP_COMPARTMENT="nginx-green"
- APP_MODULE="nginx-ui-green"
- root_dir=/opt/$APP_COMPARTMENT/$APP_MODULE
- if [ ! -d "$root_dir" ]; then
- mkdir -p $root_dir
- fi
- # Don't delete `/`
- if [[ $root_dir == "/" ]]; then
- echo "root_dir is /, exit"
- exit 1
- fi
- systemctl stop $APP_MODULE
- rm -rf $root_dir
- rm -f /usr/lib/systemd/system/$APP_MODULE.service
- if [ -d "/opt/$APP_COMPARTMENT" ] && [ -z "$(ls -A /opt/$APP_COMPARTMENT)" ]; then
- rmdir /opt/$APP_COMPARTMENT
- else
- echo "目录 /opt/$APP_COMPARTMENT 非空,不删除"
- fi
- echo "卸载成功!"
- systemctl daemon-reload
|