aboutsummaryrefslogtreecommitdiff
path: root/contrib/cirrus/packer/systemd_banish.sh
blob: 2219f2a4f17d4e99171a2a7e70f5d31729b98a4f (plain)
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
#!/usr/bin/env bash

set +e  # Not all of these exist on every platform

# This is intended to be executed on VMs as a startup script on initial-boot.
# Alternatively, it may be executed with the '--list' option to return the list
# of systemd units defined for disablement (useful for testing).

EVIL_UNITS="cron crond atd apt-daily-upgrade apt-daily fstrim motd-news systemd-tmpfiles-clean"

if [[ "$1" == "--list" ]]
then
    echo "$EVIL_UNITS"
    exit 0
fi

echo "Disabling periodic services that could destabilize testing:"
for unit in $EVIL_UNITS
do
    echo "Banishing $unit (ignoring errors)"
    (
        sudo systemctl stop $unit
        sudo systemctl disable $unit
        sudo systemctl disable $unit.timer
        sudo systemctl mask $unit
        sudo systemctl mask $unit.timer
    ) &> /dev/null
done