如果超过一定数量,如何使发行版自动安装

问题描述 投票:0回答:1

我有这个shell脚本,它将检查版本号为linux的发行版。

  if [ -e /etc/os-release ]; then
    source /etc/os-release
    DISTRO=$ID
    DISTRO_VERSION=$VERSION_ID
  fi

发行:

    if [ "$DISTRO" == "ubuntu" ] && ([ "$DISTRO_VERSION" == "20.04" ] || [ "$DISTRO_VERSION" == "19.10" ]); then
      apt-get install netdata
    fi

另一个脚本

    if [ "$DISTRO" == "ubuntu" ] && ([ "$DISTRO_VERSION" == "16.04" ] || [ "$DISTRO_VERSION" == "18.04" ]); then
      apt-get install unzip
    fi

我如何从为每个发行版添加新的DISTRO_VERSION变成类似的东西

if DISTRO = ubuntu && => 19.10 than 
apt-get install netdata
fi 

if DISTRO = ubuntu && <= 19.10 than 
apt-get install unzip
fi 

重点是我不想继续添加发行版版本号。

linux bash shell sh
1个回答
0
投票

[在Linux中,通常通过cron作业解决基本的自动化,但是在这种情况下,在Debian中,因此在Ubuntu中,具有“无人值守升级”功能可以帮助您管理此工作。

您可以在下面的链接中了解更多信息:

  1. Debian Unattended Upgrades
  2. Ubuntu Unattended Upgrades
  3. Previously answered Ask Ubuntu SO question
  4. Kali tut guide
© www.soinside.com 2019 - 2024. All rights reserved.