Loading... ``` import commands import sys import os Error = "\033[1;31;40m" Through = "\033[1;32;40m" Tail = "\033[0m" def fen(x): status, result = commands.getstatusoutput( 'ps aux|grep fen.py|grep -v grep') if status == 0: if x == "k": return 1 return Through + "运行中" + Tail else: if x== "g": return 1 return Error + "未运行" + Tail def xunlei(x): status, result = commands.getstatusoutput( 'ps aux|grep xunlei|grep -v grep') if status == 0: if x == "k": return 1 return Through + "运行中" + Tail else: if x== "g": return 1 return Error + "未运行" + Tail def frp(x): status, result = commands.getstatusoutput( 'ps aux|grep frp|grep -v grep') if status == 0: if x == "k": return 1 return Through + "运行中" + Tail else: if x== "g": return 1 return Error + "未运行" + Tail def state(): f = open("/etc/startup-script/state.txt") for line in f: line = line.strip('\n') v = line.split(':') if v[0] == "fen_state": return fen_state(v[1]) return Error + "Error" + Tail def fen_state(stat): if stat == "1": return "风扇开启中\n" else: return "风扇已关闭\n" def help(): print(" _____ _ _ _ ") print(" | __ \ | | | | | | ") print(" | |__) |___| |__ | |_| |_ ") print(" | _ // _ \ '_ \| __| __|") print(" | | \ \ __/ | | | |_| |_ ") print(" |_| \_\___|_| |_|\__|\__|") print print("-h | help 显示帮助") print("-f 开启温控风扇") print("-df 关闭温控风扇") print("-x 开启迅雷远程下载") print("-dx 关闭迅雷远程下载") print("-frp 开启frpc") print("-dfrp 关闭frpc") print("-ls 显示服务状态") def show(): print("cpu温控风扇:" + fen(0)) print("迅雷远程下载:" + xunlei(0)) print("frp:"+frp(0)) print print("状态:" + state()) if __name__ == '__main__': arg=sys.argv k="k" g="g" try: if arg[1] == "help" and arg[1] == "-h": help() elif arg[1] == "-f": if fen(k) == 1: os.system('sudo python /etc/startup-script/fen.py &') print("开启成功") else: print("温控风扇已在运行状态") elif arg[1] == "-df": if fen(g) ==1: os.system('sudo killall python /etc/startup-script/fen.py') print("关闭成功") else: print("温控风扇未运行") elif arg[1] == "-x": if fen(k) == 1: os.system('sudo python /etc/startup-script/xunlei/setup.py') print("开启成功") else: print("迅雷远程下载已在运行状态") elif arg[1] == "-dx": if fen(g) ==1: os.system('sudo /etc/startup-script/xunlei/portal -s') print("关闭成功") else: print("迅雷远程下载未运行") elif arg[1]=="-frp": if frp(k) ==1: os.system('sudo screen -dmS frp /etc/startup-script/frp_0.20.0_linux_arm/frpc -c /etc/startup-script/frp_0.20.0_linux_arm/frpc.ini') print("开启成功") else: print("frp已在运行状态") elif arg[1]=="-dfrp": if frp(g)==1: os.system('sudo screen -d frp') print("关闭成功") else: print("frp未运行") elif arg[1] =="-ls": show() else: help() except: help() ``` Last modification:October 24, 2019 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 如果觉得我的文章对你有用,请随意赞赏