Created
February 5, 2024 21:52
-
-
Save cjemorton/20a5af1576635d065becfa039836e0ec to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
# Detect the shell | |
if [ -n "$BASH_VERSION" ]; then | |
SHELL_NAME="bash" | |
elif [ -n "$ZSH_VERSION" ]; then | |
SHELL_NAME="zsh" | |
else | |
SHELL_NAME="unknown" | |
fi | |
# Detect the package manager | |
case "$SHELL_NAME" in | |
"bash" | "zsh") | |
if command -v pkg &> /dev/null; then | |
echo "FreeBSD system using pkg" | |
elif command -v apt-get &> /dev/null; then | |
echo "Debian-based system using apt-get" | |
elif command -v yum &> /dev/null; then | |
echo "Red Hat-based system using yum" | |
elif command -v dnf &> /dev/null; then | |
echo "Red Hat-based system using dnf" | |
else | |
echo "Unsupported or unknown package manager" | |
fi | |
;; | |
*) | |
echo "Unsupported shell: $SHELL_NAME" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment