alanhe421 / alfred-workflows

Save time, Improve life.🚀 ☕️ 💻
https://alfred.1991421.cn
MIT License
659 stars 63 forks source link

check openconnect-install? #276

Closed alanhe421 closed 2 years ago

alanhe421 commented 2 years ago

Workflow Name: [e.g. Surge] vpn

检查本地是否安装,没有的话,直接执行安装。

好处就是workflow自动实现安装,降低使用成本

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

alanhe421 commented 2 years ago

针对查询命令没有安装也可以形成通用解决方案

alanhe421 commented 2 years ago

如果命令存在,-z为false z是判断是否为0

#!/bin/bash
OPENCONNECT_CMD=$(which openconnect)
 if [  -z  $OPENCONNECT_CMD  ];  then
  echo "<?xml version='1.0'?><items><item arg='openconnect'><title>OpenConnect is required</title><subtitle>enter to install</subtitle></item></items>"
else
  echo "<?xml version='1.0'?><items><item arg=''><title>OpenConnect VPN</title><subtitle>enter to connect</subtitle></item></items>"
 fi