62 lines
1.7 KiB
Markdown
62 lines
1.7 KiB
Markdown
# 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 | 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` |
|