76 lines
1.5 KiB
Bash
76 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
arch () {
|
|
uname -m
|
|
}
|
|
|
|
function get_chip_type() {
|
|
|
|
local ARCH
|
|
|
|
case $(arch) in
|
|
"x86_64")
|
|
ARCH=amd64
|
|
;;
|
|
"aarch64")
|
|
ARCH=arm64
|
|
;;
|
|
"armv8")
|
|
ARCH=arm64
|
|
;;
|
|
.*386.*)
|
|
ARCH=amd32
|
|
;;
|
|
*)
|
|
ARCH=arm32
|
|
;;
|
|
esac
|
|
|
|
echo $ARCH
|
|
}
|
|
|
|
function get_platform() {
|
|
|
|
echo $(uname -s)-$(get_chip_type)
|
|
|
|
}
|
|
|
|
hostinfo () {
|
|
hostnamectl
|
|
echo -e "--------------------------"
|
|
echo kernel: $(uname -r)
|
|
echo chip architecture: $(uname -m)
|
|
echo -e "--------------------------"
|
|
cat /etc/os-release
|
|
echo -e "--------------------------"
|
|
[[ -f /etc/upstream-release/lsb-release ]] && cat /etc/upstream-release/lsb-release
|
|
}
|
|
|
|
|
|
function get_distro() {
|
|
source /etc/os-release
|
|
declare valid=${@:-"arch alpine debian ubuntu"}
|
|
# echo $ID $ID_LIKE
|
|
[[ "${valid}" =~ $ID ]] && echo $ID && return 0
|
|
[[ "${valid}" =~ $ID_LIKE ]] && echo $ID_LIKE && return 0
|
|
return 1
|
|
}
|
|
|
|
# function get_release() {
|
|
|
|
# }
|
|
|
|
# get_distro() {
|
|
# local file=/etc/upstream-release/lsb-release
|
|
# local distro
|
|
# if [[ -f $file ]]; then
|
|
# echo $(cat $file | tr [:upper:] [:lower:] | grep -Poi '(debian|ubuntu|red hat|centos|arch|alpine)' | uniq)
|
|
# return 0
|
|
# else
|
|
# file=/etc/os-release
|
|
# if [[ -f $file ]]; then
|
|
# echo $(cat $file | tr [:upper:] [:lower:] | grep -Poi '(debian|ubuntu|red hat|centos|arch|alpine)' | uniq)
|
|
# fi
|
|
# fi
|
|
# }
|