美文网首页
linux通过shell判断 centos ubuntu deb

linux通过shell判断 centos ubuntu deb

作者: 许吉华 | 来源:发表于2020-05-20 11:09 被阅读0次

参考资料: https://github.com/angristan/openvpn-install
https://blog.csdn.net/violet_echo_0908/article/details/52056071Linux下source命令详解

function checkOS () {
    if [[ -e /etc/debian_version ]]; then
        OS="debian"
        # shellcheck disable=SC1091
        source /etc/os-release

        if [[ "$ID" == "debian" || "$ID" == "raspbian" ]]; then
            if [[ ! $VERSION_ID =~ (8|9|10) ]]; then
                echo "⚠️ Your version of Debian is not supported."
                echo ""
                echo "However, if you're using Debian >= 9 or unstable/testing then you can 
        ........
}

/etc/os-release 说明:

  1. os-release — 操作系统标识

/etc/os-release 与/usr/lib/os-release 文件里包含了操作系统相关的识别数据, 文件内的基本格式是一系列换行符分隔的 VAR=VALUE 行(每行一个变量),可直接嵌入到shell 脚本中使用,
/etc/os-release 与 /usr/lib/os-release 可以是软连接, 但是必须全部位于根文件系统上, 以确保在系统刚启动时即可读取其内容。仅在 /etc/os-release 不存在的情况下, 才可以读取 /usr/lib/os-release 文件。

source 命令说明

1.source命令用法

source FileName

作用是在当前bash环境下读取并执行FileName中的命令。该命令通常用命令“.”来替代。

相关文章

网友评论

      本文标题:linux通过shell判断 centos ubuntu deb

      本文链接:https://www.haomeiwen.com/subject/dsjgohtx.html