imports/README.md
2025-05-20 17:25:20 +02:00

1.7 KiB

imports

distros.sh

Import the script inside your own script like this:

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 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..

if $arch; then
    echo "This system is using arch!"
elif $debian; then
    echo "This system is using debian!"
fi

or..

case "$distros" in
    ubuntu)
        echo "Using ubuntu!"
    ;;
    arch)
        echo "Using archlinux!"
    ;;
    opensuse)
        echo "Using opensuse!"
    ;;
esac
variable values
$arch boolean: true/false
$debian boolean: true/false
$ubuntu boolean: true/false
$fedora boolean: true/false
$opensuse boolean: true/false
$alpine boolean: true/false
$distros One value of arch, debian, ubuntu, fedora, opensuse, alpine