| 1 |
#!/bin/sh |
| 2 |
# image-customize script to prepare a bots VM for testing cockpit |
| 3 |
# The cockpit packages will be installed separately |
| 4 |
set -eu |
| 5 |
|
| 6 |
if type firewall-cmd >/dev/null 2>&1; then |
| 7 |
firewall-cmd --add-service=cockpit --permanent |
| 8 |
fi |
| 9 |
|
| 10 |
. /usr/lib/os-release |
| 11 |
|
| 12 |
# our tests expect cockpit.socket to not be running after boot, only after start_cockpit() |
| 13 |
# socket isn't present on CoreOS or with cockpit/ws scenario |
| 14 |
HAVE_COCKPIT_SOCKET= |
| 15 |
if [ -n "$(systemctl --no-legend list-unit-files cockpit.socket || true)" ]; then |
| 16 |
HAVE_COCKPIT_SOCKET=1 |
| 17 |
fi |
| 18 |
|
| 19 |
if [ -n "$HAVE_COCKPIT_SOCKET" ]; then |
| 20 |
systemctl disable cockpit.socket |
| 21 |
fi |
| 22 |
|
| 23 |
# OS specific hacks |
| 24 |
|
| 25 |
if [ "$ID" = "debian" ] || [ "$ID" = "ubuntu" ]; then |
| 26 |
# avoid random dpkg database locks, they break our package related tests |
| 27 |
systemctl disable apt-daily-upgrade.timer |
| 28 |
# takes a lot of memory and does not have a chance of working anyway |
| 29 |
systemctl disable apt-listchanges.timer || true |
| 30 |
|
| 31 |
# create public firewalld zone for our firewall tests |
| 32 |
systemctl start firewalld |
| 33 |
firewall-cmd --zone=public --permanent --add-interface=eth1 |
| 34 |
|
| 35 |
# disarm 10-cloudimg-settings.conf |
| 36 |
sed -i '/.*PasswordAuthentication no/d' /etc/ssh/sshd_config $(ls /etc/ssh/sshd_config.d/* 2>/dev/null || true) |
| 37 |
fi |
| 38 |
|
| 39 |
if [ "$ID" = "debian" ]; then |
| 40 |
# make libpwquality less aggressive, so that our "foobar" password works |
| 41 |
printf 'dictcheck = 0\nminlen = 6\n' >> /etc/security/pwquality.conf |
| 42 |
|
| 43 |
# Allow libvirtd coredumps |
| 44 |
echo '* soft core unlimited' >> /etc/security/limits.conf |
| 45 |
fi |
| 46 |
|
| 47 |
if [ "$ID" = "opensuse-tumbleweed" ]; then |
| 48 |
# Zypper will take forever to work out these don't have net access |
| 49 |
# Let's lo them |
| 50 |
echo "127.0.1.1 download.opensuse.org" >> /etc/hosts |
| 51 |
echo "127.0.1.1 codecs.opensuse.org" >> /etc/hosts |
| 52 |
fi |
| 53 |
|
| 54 |
if [ "$ID" = "ubuntu" ] && [ "$VERSION_ID" = "26.04" ]; then |
| 55 |
# HACK: https://launchpad.net/bugs/2151857 |
| 56 |
echo '/usr/share/coreutils/locales/** r,' > /etc/apparmor.d/local/who |
| 57 |
fi |
| 58 |
|
| 59 |
PLATFORM_ID="${PLATFORM_ID:-}" |
| 60 |
if [ "${PLATFORM_ID#platform:el}" != "$PLATFORM_ID" ]; then |
| 61 |
# allow /usr/local/bin/ in sudo shells, to use our installed tools like the Python bridge |
| 62 |
# Fedora, Debian etc. do that |
| 63 |
echo 'Defaults secure_path = /sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin' > /etc/sudoers.d/usr-local |
| 64 |
fi |
| 65 |
|
| 66 |
# HACK: unbreak subuid assignment for current and new users; see |
| 67 |
# https://bugzilla.redhat.com/show_bug.cgi?id=2382662 |
| 68 |
# https://issues.redhat.com/browse/RHEL-103765 |
| 69 |
if [ -e /etc/login.defs ]; then |
| 70 |
sed -i '/^SUB_.ID_COUNT/ s/\b0/65536/' /etc/login.defs |
| 71 |
fi |
| 72 |
if ! grep -q admin /etc/subuid; then |
| 73 |
usermod --add-subuids 100000-165535 admin |
| 74 |
usermod --add-subgids 100000-165535 admin |
| 75 |
fi |
| 76 |
|
| 77 |
# start cockpit once to ensure it works, and generate the certificate (to avoid re-doing that for each test) |
| 78 |
if [ -n "$HAVE_COCKPIT_SOCKET" ]; then |
| 79 |
systemctl start cockpit |
| 80 |
systemctl stop cockpit |
| 81 |
fi |
| 82 |
|
| 83 |
# clean out the journal |
| 84 |
journalctl --flush |
| 85 |
journalctl --sync || killall systemd-journald |
| 86 |
rm -rf /var/log/journal/* |
| 87 |
rm -rf /var/lib/NetworkManager/dhclient-*.lease |