Skip to content

Instantly share code, notes, and snippets.

@Gnnng
Last active March 17, 2018 15:27
Show Gist options
  • Save Gnnng/3011b7aca8c1be4f3f27e1002cd5bb9c to your computer and use it in GitHub Desktop.
Save Gnnng/3011b7aca8c1be4f3f27e1002cd5bb9c to your computer and use it in GitHub Desktop.
Bitbar plugin for start/stop openfortivpn (brew service)
#!/bin/bash
sudo=/usr/bin/sudo
brew=/usr/local/bin/brew
icon_off='iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAAXNSR0IArs4c6QAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABYlAAAWJQFJUiTwAAACZmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MzY8L2V4aWY6UGl4ZWxZRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFhEaW1lbnNpb24+MzY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpDb2xvclNwYWNlPjE8L2V4aWY6Q29sb3JTcGFjZT4KICAgICAgICAgPHRpZmY6UmVzb2x1dGlvblVuaXQ+MjwvdGlmZjpSZXNvbHV0aW9uVW5pdD4KICAgICAgICAgPHRpZmY6T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yvxfS2Kuw99TPO/3Id9TMqBUpe8Y5CGxsh5hGlwvTp6FzTIoq9xKOB2/flu3lutTiXtuHgwfnDEZz5gSJDHphDr+5YJWXu9h6uorYnQ2ic50f3vj8RPtcrtop7HA+OiZCjaUPTNDQ8FpSfvKu7kSH5rqUKZF5IcLJb3LpvPYL15UR+lYB4oXtUpJk7BFjzqtRzUtQSfHju9U7s6TqC39RLYqvUoyQgZj87Zee1M8vw7e5zsnbVptlUgWa2u1Inz1qsme6XFKeJ+FwUvFbTssEnUNwYudRnPzENrYuCuHEpWgqLjI1NGQ9n01bm9+Dxta2jiznsXIEcalKR1PEkVxT/MxA+OpiHrlTWmaKXIV5WVPmwbvMCJGNO5WUp6KrKuzQgmmKnXM4zOupGF9RT5bm3S45OJEx3KBIBwdaLPZBSfziOu8w/muYozaEoNS1wSJ2m6i2WkiljJUkbGWiZV4M3P1kNj1encvePNkM+NF98ZwlGqNw5klwIo3jIufQzKv2uvWvlbHPSZsNHuls+WiktIjTLqcS8gI5DakHkdG0+IjrXtIoDPhRdUYgXbYupedI7TePFFcNRY3LPX9Esa5lfLKwXmlWFpjnVsjkmv+7JpXjcCLmOuSeNpFLyk0HkCx+2LMXjrg6DSsZpLS3LPyYYXJpvphTSQov5Zc+rnT/XXu6dzQWrFMh44/lKJXUYoaMkbtku/bOqzrn2GCZMk25sFnOcZ/ItPsRvcsVY+BD2kH/moe71enDh4gmoZ4fpKhuiS36K8EwMIj4z+R5vK3EcP9MD30aTr9GWfeyP3xG+ek2a2Zi0PMQAsWlOU4aqeVqoAUuXLGVAEw3h/3coVWZZfDZNTJrGg8NxUeniP+kiNO7RMd5OHvb4I0APivB/24yCm9+LXcYAAAAASUVORK5CYII='
function display() {
ifconfig -l | grep ppp0 > /dev/null && icon="$icon_on" || icon="$icon_off"
echo "| image=$icon"
echo "---"
echo "Start | bash=$sudo param1=$0 param2=start terminal=false"
echo "Stop | bash=$sudo param1=$0 param2=stop terminal=false"
}
# change to a real file for debugging
log=/dev/null
case $1 in
start)
sudo $brew services restart openfortivpn >> $log 2>&1
;;
stop)
sudo $brew services stop openfortivpn >> $log 2>&1
;;
*)
display
;;
esac
@Gnnng
Copy link
Author

Gnnng commented Mar 17, 2018

It requires password-less sudo to run in order to achieve terminal=false, so the script path needs to be added correctly in sudoers file via sudo visudo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment