Skip to content
Snippets Groups Projects
test_apt.sh 700 B
#!/bin/bash
# Criticality: Normal
# Check that updates can be installed and that automatic security updates are enabled.
set -e

echo "Testing apt-get install"

echo "Clean repository"
apt-get clean

#Testing if sl package exists and remove it

if ( dpkg -s sl >/dev/null 2>&1 ); then
    echo "Removing already installed testing package"
    apt-get remove -y sl
fi

# Installation testing package sl
apt-get update
apt-get install -y sl
apt-get remove -y sl

if [ ! -f /etc/apt/apt.conf.d/20auto-upgrades ]; then
    if [ ! -f /etc/apt/apt.conf.d/50unattended-upgrades ]; then
        echo "Automatic security updates not enabled"
        exit 1
    fi
fi
echo "Automatic security updates enabled"