Created
April 18, 2023 23:46
-
-
Save eplord/c39ebb75fd8c318e207f7ece60d3cddb to your computer and use it in GitHub Desktop.
basic bash script helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| success() { | |
| printf "\\033[32m ✔ \\033[0m\\n" | |
| } | |
| fail() { | |
| printf "\\n\\033[31m ✖ \\033[0m $1\\n" | |
| exit 1 | |
| } | |
| doing() { | |
| printf "\\033[33m ➜ \\033[0m $1" | |
| } | |
| success_msg() { | |
| printf "\\033[33m ➜ \\033[0m $1 \\033[32m ✔ \\033[0m\\n" | |
| } | |
| key_missing() { | |
| [[ $(apt-key list 2>/dev/null | | |
| grep -i $1) ]] && | |
| return 1 || return 0 | |
| } | |
| repo_missing() { | |
| [[ $(find /etc/apt/ -name '*.list' | | |
| xargs cat | | |
| grep '^[[:space:]]*deb' | | |
| grep "$1") ]] && | |
| return 1 || return 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment