#!/bin/bash
##全局变量
launchctl list|grep -n 'com.paragon.*agent'
pService1=`ls /System/Library/LaunchAgents|grep  'paragon'`
pService2=`ls /Library/LaunchAgents/ |grep  'paragon'`
trashFilePath=/Library/Application\ Support/
##

function checkService() {
  if [[ $pService1 != "" ]]; then
      launchctl unload $pService1
  fi
  if [[ $pService2 != "" ]]; then
      launchctl unload $pService2
  fi
}

function cleanTrash() {
    if [ -e $trashFilePath/$pService1 ]; then
        rm -rf $trashFilePath/$pService1
    fi
    if [ -e $trashFilePath/$pService2 ]; then
        rm -rf $trashFilePath/$pService2
    fi
    if [ -d $$trashFilePath/Paragon\ Software ]; then
        rm -rf $$trashFilePath/Paragon\ Software
    fi
}


function main() {
  isRoot
  checkService
  cleanTrash
}

#检查用户是否为root用户.不是则退出。
function isRoot() {
    CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1`
    if [ $CUSER != root ];then
        echo "请用 <su - root> 命令切换到root权限"
        exit 1
    fi
}
#日志输出
function log_err() {
	message=$1
	logger "ERROR" "$message"
}

function log_info() {
	message=$1
	logger "INFO" "$message"
}
function log_pwd() {
    message=`pwd`
    logger "PATH" "$message"
}
function logger() {
	lvl=$1
	message=$2
	echo "[$lvl] [`date "+%Y-%m-%d %H:%M:%S"`] $message"
}

#脚本入口
main
Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐