batman
This commit is contained in:
parent
5dd4e7adf0
commit
fda65be110
1 changed files with 60 additions and 0 deletions
60
README.md
60
README.md
|
@ -1,2 +1,62 @@
|
||||||
# imports
|
# 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` |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue