980  
查询码:00000006
一键卸载及相关目录删除脚本,可选卸载或保留程序
作者: wyasw 于 2020年03月29日 发布在分类 / Linux / 常用shell脚本 下,并于 2020年03月29日 编辑
shell

需求:一键卸载程序及相关目录删除,可选卸载或保留程序

#!/usr/bin/env bash

##uninstall

##stop bcchain

function StopBcchain(){

if $(systemctl -q is-active bcchain.service) ; then

  systemctl stop bcchain.service

fi

uid=$(id -u bcchain 2>/dev/null)

if [[ "${uid:-}" != "0" ]];then

  pid=$(ps -fubcchain 2>/dev/null|grep 'bcchain'|awk '$0 !~/grep/ {print $2}'|sed -e 's/\n/ /')

  if [[ "${pid:-}" != "" ]]; then

      echo "kill old process. ${pid}"

      kill -9 ${pid}

  fi

fi

}

###

echo ""

echo "Do you want to uninstall & remove all of this bcb node?"

options=("yes" "no")

select opt in "${options[@]}" ; do

case ${opt} in

  "yes")

    echo ""

    echo "Yes, uninstall & remove all of this bcb node"    

    StopBcchain

    systemctl disable bcchain.service

    rm -fr /etc/bcchain

    rm -fr /home/bcchain

    echo "The deleted directories are /etc/bcchain,/home/bcchain."

    echo ""

    break

    ;;

  "no")

    echo ""

    echo "No, keep the old bcb node"

    echo ""

    exit 1

    break

    ;;

  *) echo "Invalid choice.";;

  esac

done



 推荐知识

 历史版本

修改日期 修改人 备注
2020-03-29 21:03:16[当前版本] wyasw 创建版本

文艺知识分享平台 -V 4.9.5 -wcp
京公网安备100012199188号 京ICP备2021030911号