Update of Packer builder for Vagrant and various clouds
[osm/devops.git] / packer / packer_templates / osm / scripts / update.sh
1 #!/bin/sh -eux
2
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 export DEBIAN_FRONTEND=noninteractive
16
17 ubuntu_version="`lsb_release -r | awk '{print $2}'`";
18 major_version="`echo $ubuntu_version | awk -F. '{print $1}'`";
19
20 # Disable release-upgrades
21 sed -i.bak 's/^Prompt=.*$/Prompt=never/' /etc/update-manager/release-upgrades;
22
23 # Disable systemd apt timers/services
24 if [ "$major_version" -ge "16" ]; then
25 systemctl stop apt-daily.timer;
26 systemctl stop apt-daily-upgrade.timer;
27 systemctl disable apt-daily.timer;
28 systemctl disable apt-daily-upgrade.timer;
29 systemctl mask apt-daily.service;
30 systemctl mask apt-daily-upgrade.service;
31 systemctl daemon-reload;
32 fi
33
34 # Disable periodic activities of apt to be safe
35 cat <<EOF >/etc/apt/apt.conf.d/10periodic;
36 APT::Periodic::Enable "0";
37 APT::Periodic::Update-Package-Lists "0";
38 APT::Periodic::Download-Upgradeable-Packages "0";
39 APT::Periodic::AutocleanInterval "0";
40 APT::Periodic::Unattended-Upgrade "0";
41 EOF
42
43 # Clean and nuke the package from orbit
44 rm -rf /var/log/unattended-upgrades;
45 apt-get -y purge unattended-upgrades;
46
47 # Update the package list
48 apt-get -y update;
49
50 # Upgrade all installed packages
51 #DEBIAN_FRONTEND=noninteractive sudo apt-get -y upgrade;
52
53 # Upgrade all installed packages incl. kernel and kernel headers
54 apt-get -y dist-upgrade -o Dpkg::Options::="--force-confnew";
55
56 reboot