github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/images/scripts/ubuntu/update.sh (about)

     1  #!/bin/sh -eux
     2  
     3  ubuntu_version="`lsb_release -r | awk '{print $2}'`";
     4  ubuntu_major_version="`echo $ubuntu_version | awk -F. '{print $1}'`";
     5  
     6  # Work around bad cached lists on Ubuntu 12.04
     7  if [ "$ubuntu_version" = "12.04" ]; then
     8      apt-get clean;
     9      rm -rf /var/lib/apt/lists;
    10  fi
    11  
    12  # Update the package list
    13  apt-get update;
    14  
    15  # Upgrade all installed packages incl. kernel and kernel headers
    16  if [ "$ubuntu_major_version" -lt 14 ]; then
    17      apt-get -y upgrade linux-server linux-headers-server;
    18  else
    19      apt-get -y upgrade linux-generic;
    20  fi
    21  
    22  # ensure the correct kernel headers are installed
    23  apt-get -y install linux-headers-`uname -r`;
    24  
    25  # update package index on boot
    26  cat <<EOF >/etc/init/refresh-apt.conf;
    27  description "update package index"
    28  start on networking
    29  task
    30  exec /usr/bin/apt-get update
    31  EOF
    32  
    33  # Manage broken indexes on distro disc 12.04.5
    34  if [ "$ubuntu_version" = "12.04" ]; then
    35      apt-get -y install libreadline-dev dpkg;
    36  fi