forked from aws/aws-parallelcluster-cookbook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
centos-upgrade-second-stage.sh
53 lines (41 loc) · 1.36 KB
/
centos-upgrade-second-stage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#
# Script to run the second stage (everything after rebooting into the
# newest kernel) for upgrading the CenOS AMIs from the imported
# version to the latest in that major release series.
#
if test "`sed -n '/CentOS release 6\..*/p' /etc/centos-release`" != ""; then
is_centos6=1
else
is_centos6=0
fi
if ! sudo modprobe ena; then
set -e
# upgrade to latest ENA
echo "Installing ENA module"
echo "Getting ENA source"
git clone https://github.com/amzn/amzn-drivers.git
cd amzn-drivers
git checkout ena_linux_1.3.0
echo "Building ENA source"
BUILD_KERNEL=`uname -r`
cd kernel/linux/ena
make
echo "Installing ENA source"
sudo make -C /lib/modules/${BUILD_KERNEL}/build M=`pwd` modules_install
sudo depmod -a
set +e
else
echo "Not installing ENA module"
fi
echo "Cleaning out old kernels"
sudo package-cleanup -y --oldkernels --count=1
if test $is_centos6 -eq 1; then
sudo yum install -y cloud-init cloud-utils dracut-modules-growroot cloud-utils-growpart
rpm -qa kernel-lt | sed 's/^kernel-lt-//' | xargs -I {} sudo dracut -f /boot/initramfs-{}.img {}
fi
echo "Cleaning up filesystem"
sudo rm -rf /tmp/* /var/tmp/* /var/log/* /etc/ssh/ssh_host*
sudo rm -rf /root/* /root/.ssh /root/.history /root/.bash_history
sudo rm -rf ~/* ~/.ssh ~/.history ~/.bash_history ~/.cache
echo "All done!"