201 lines
5.2 KiB
Bash
201 lines
5.2 KiB
Bash
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
#--------[ Detect Bootloader Type ]--------#
|
|
if [ -d "/sys/firmware/efi" ]; then
|
|
export ENV_BOOTLOADER="UEFI"
|
|
else
|
|
export ENV_BOOTLOADER="BIOS"
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Detect Motherboard Chipset ]--------#
|
|
if [ -d "/sys/devices/virtual/dmi/id" ]; then
|
|
export ENV_MAKE=$(cat /sys/devices/virtual/dmi/id/sys_vendor)
|
|
export ENV_MODEL=$(cat /sys/devices/virtual/dmi/id/product_family)
|
|
elif [ -f "/proc/device-tree/model" ]; then
|
|
if [ "$(tr -d '\0' < /proc/device-tree/model | grep -a PineTab)" ]; then
|
|
export ENV_MAKE="Pine64"
|
|
export ENV_MODEL="PineTab"
|
|
elif [ "$(tr -d '\0' < /proc/device-tree/model | grep -a PinePhone)" ]; then
|
|
export ENV_MAKE="Pine64"
|
|
export ENV_MODEL="PinePhonePro"
|
|
elif [ "$(tr -d '\0' < /proc/device-tree/model | grep -a 'Zero W')" ]; then
|
|
export ENV_MAKE="RaspberryPi"
|
|
export ENV_MODEL="RPi-Zero-W"
|
|
elif [ "$(tr -d '\0' < /proc/device-tree/model | grep -a 'Pi 2')" ]; then
|
|
export ENV_MAKE="RaspberryPi"
|
|
export ENV_MODEL="RPi-2"
|
|
elif [ "$(tr -d '\0' < /proc/device-tree/model | grep -a 'Pi 4')" ]; then
|
|
export ENV_MAKE="RaspberryPi"
|
|
export ENV_MODEL="RPi-4"
|
|
else
|
|
export ENV_MAKE="unknown"
|
|
export ENV_MODEL="unknown"
|
|
fi
|
|
else
|
|
export ENV_MAKE="unknown"
|
|
export ENV_MODEL="unknown"
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Detect CPU Architecture ]--------#
|
|
export ENV_ARCH="$(uname -m)"
|
|
|
|
|
|
|
|
#--------[ Detect CPU Make ]--------#
|
|
if [ "$(command -v lscpu)" ]; then
|
|
if [ "$(lscpu | grep Intel)" ]; then
|
|
export ENV_CPU="intel";
|
|
elif [ "$(lscpu | grep AMD)" ]; then
|
|
export ENV_CPU="amd";
|
|
elif [ "$(lscpu | grep ARM)" ]; then
|
|
export ENV_CPU="arm";
|
|
else
|
|
export ENV_CPU="unkown";
|
|
fi
|
|
else export ENV_CPU="unkown"; fi
|
|
|
|
|
|
|
|
#--------[ Detect GPU Make ]--------#
|
|
if [ -d "/proc/bus/pci" ] && [ "$(command -v lspci)" ]; then
|
|
if [ "$(lspci | grep VGA | grep Intel)" ]; then
|
|
export ENV_GPU="intel";
|
|
elif [ "$(lspci | grep VGA | grep GeForce)" ]; then
|
|
export ENV_GPU="nvidia";
|
|
elif [ "$(lspci | grep VGA | grep AMD)" ]; then
|
|
export ENV_GPU="amd";
|
|
else
|
|
export ENV_GPU="unkown"
|
|
fi
|
|
else export ENV_GPU="unknown"; fi
|
|
|
|
|
|
|
|
#--------[ Memory Amount ]--------#
|
|
export ENV_MEMORY=$(free -h | grep 'Mem\|Speicher' | awk '{print $2}')
|
|
|
|
|
|
|
|
#--------[ Detect Bluetooth ]--------#
|
|
#if [ "$(dmesg | grep -i bluetooth)" ]; then
|
|
# export ENV_BLUETOOTH="true"
|
|
#else
|
|
# export ENV_BLUETOOTH="false"
|
|
#fi
|
|
|
|
|
|
|
|
#--------[ Detect Camera(s) ]--------#
|
|
if [ -f /dev/video0 ]; then
|
|
export ENV_CAMERA="true"
|
|
else
|
|
export ENV_CAMERA="false"
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Detect Network Type ]--------#
|
|
export ENV_NETWORK="none"
|
|
if [ "$(ip addr | grep inet | grep wlan)" ]; then export ENV_NETWORK="wlan"; fi
|
|
if [ "$(ip addr | grep inet | grep eth)" ]; then export ENV_NETWORK="eth"; fi
|
|
if [ "$(ip addr | grep inet | grep enp)" ]; then export ENV_NETWORK="eth"; fi
|
|
|
|
|
|
|
|
#--------[ Detect Virtual/Container Environment ]--------#
|
|
if [ ! "$(cat /proc/1/environ 2>&1 | tr -d '\0' | grep -e denied -e Berechtigung )" ]; then
|
|
if [ "$(cat /proc/1/environ | tr -d '\0' | grep lxc)" ]; then
|
|
export ENV_VIRTUAL="lxc"
|
|
elif [ "$ENV_MAKE" == "QEMU" ]; then
|
|
export ENV_VIRTUAL="vm"
|
|
else
|
|
export ENV_VIRTUAL="real"
|
|
fi
|
|
else
|
|
export ENV_VIRTUAL="unknown"
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Detect Live Environment ]--------#
|
|
if [ "$(lsblk | grep sr0 | grep run)" ] || [ "$(lsblk | grep loop0 | grep run)" ]; then
|
|
ENV_LIVE="true"
|
|
else
|
|
ENV_LIVE="false"
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Detect Init System ]--------#
|
|
if [ "$(command -v systemctl)" ]; then
|
|
export ENV_INIT="systemd";
|
|
elif [ "$(command -v rc-service)" ]; then
|
|
export ENV_INIT="openrc";
|
|
else
|
|
export ENV_INIT="unknown";
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Detect Operating System Distro ]--------#
|
|
export ENV_DISTRO=$(cat /etc/os-release | grep "^NAME=" | sed 's/^NAME="\(.*\)"$/\1/g')
|
|
if [ "$(command -v proxmox-boot-tool)" ]; then export ENV_DISTRO="Proxmox (Debian)"; fi
|
|
if [ "$(command -v raspi-config)" ]; then export ENV_DISTRO="RaspberryOS (Debian)"; fi
|
|
|
|
|
|
|
|
#--------[ Detect Init System ]--------#
|
|
if [ "$(command -v systemctl)" ]; then export ENV_INIT="systemd";
|
|
elif [ "$(command -v rc-service)" ]; then export ENV_INIT="openrc";
|
|
else export ENV_INIT="unknown";
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Package Manager ]--------#
|
|
if [ "$(command -v paru)" ]; then export ENV_MANAGER="paru";
|
|
elif [ "$(command -v pacman)" ]; then export ENV_MANAGER="pacman";
|
|
elif [ "$(command -v apt)" ]; then export ENV_MANAGER="apt";
|
|
elif [ "$(command -v apk)" ]; then export ENV_MANAGER="apk";
|
|
elif [ "$(command -v dnf)" ]; then export ENV_MANAGER="dnf";
|
|
elif [ "$(command -v yum)" ]; then export ENV_MANAGER="yum";
|
|
else export ENV_MANAGER="unknown"; fi
|
|
|
|
|
|
|
|
#--------[ Detect System Hostname ]--------#
|
|
export ENV_HOSTNAME=$(uname -n)
|
|
|
|
|
|
|
|
#--------[ Dettect Session Login Type ]--------#
|
|
if [ "$SSH_TTY" ]; then
|
|
ENV_LOGIN="ssh";
|
|
else
|
|
ENV_LOGIN="local";
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Check Root ]--------#
|
|
if [ "$EUID" -ne 0 ]; then
|
|
ENV_ROOT="false"
|
|
else
|
|
ENV_ROOT="true"
|
|
fi
|
|
|
|
|
|
|
|
#--------[ Detect Shell ]--------#
|
|
export ENV_SHELL="$(echo $SHELL | sed 's/^\/.*\///g')"
|
|
|
|
|
|
|
|
#--------[ Detect System Users ]--------#
|
|
export ENV_USERS=$( echo root $(ls /home/))
|