os judge
# OS bit
# 32bit: i686
# 64bit: x86_64
function get_os_bit() {
echo "$(uname -m)"
}
# Linux distribution名の取得
# debian,ubuntu: debian
# redhat,fedora,centos: redhat
# gentoo,chromeos: gentoo
# other: unknown
function get_linux_distribution() {
# Debian系
if [ -e /etc/debian_version ] || [ -e /etc/debian_release ]; then
distri_name="debian"
# redhat系
elif [ -e /etc/redhat-release ] || [ -e /etc/fedora-release ]; then
distri_name="redhat"
# Gentoo系
elif [ -e /etc/gentoo-release ]; then
distri_name="gentoo"
# その他
else
distri_name="unknown"
fi
echo ${distri_name}
}
# OS名の取得
# mac,osx: mac
# linux: linux
# windows: cygwin
# other: unknown
function get_os() {
get_uname="$(uname -s)"
if [ ${get_uname} == "Darwin" ]; then
os_name="mac"
elif [ "$(expr substr ${get_uname} 1 5)" == "Linux" ]; then
os_name="linux"
elif [ "$(expr substr ${get_uname} 1 10)" == "MINGW32_NT" ]; then
os_name="cygwin"
else
os_name="unknown"
fi
echo ${os_name}
}