diff --git a/README.md b/README.md index 28ba300..4894367 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,62 @@ # imports +## `distros.sh` + +Import the script inside your own script like this: + +```bash +url="https://git.k4li.de/scripts/imports/raw/branch/main/distros.sh" +import="$(mktemp)" +if command_exists curl; then + curl -fsSL $url -o $import +else + echo "curl is required, but missing.." + exit 1 +fi + +source "$import" +sleep 0.3 +rm "$import" +``` + +So now that you have imported the [distros.sh](distros.sh) script, you can run some fancy things in your script.. + +### `distro-variables` + +There are most of the big linux distros as a variable which contains boolean values. + +For example, you can run things like.. + +```bash +if $arch; then + echo "This system is using arch!" +elif $debian; then + echo "This system is using debian!" +fi +``` + +> or.. + +```bash +case "$distros" in + ubuntu) + echo "Using ubuntu!" + ;; + arch) + echo "Using archlinux!" + ;; + opensuse) + echo "Using opensuse!" + ;; +esac +``` + +| variable | values | +| --------- | ----------------------------------------------------------------------- | +| $arch | `true/false` | +| $debian | `true/false` | +| $ubuntu | `true/false` | +| $fedora | `true/false` | +| $opensuse | `true/false` | +| $alpine | `true/false` | +| $distros | One value of `arch`, `debian`, `ubuntu`, `fedora`, `opensuse`, `alpine` |