2020-10-07 13:49:40 +05:00
#!/bin/bash -e
2023-11-22 21:49:23 +01:00
################################################################################
## File: configure-environment.sh
## Desc: Configure system and environment
################################################################################
2020-10-07 13:49:40 +05:00
2022-05-06 12:54:50 +02:00
# Source the helpers for use with the script
source $HELPER_SCRIPTS /os.sh
2023-11-28 15:19:44 +01:00
source $HELPER_SCRIPTS /etc-environment.sh
2022-05-06 12:54:50 +02:00
2021-03-15 11:17:57 +03:00
# Set ImageVersion and ImageOS env variables
2023-12-26 12:50:52 +01:00
set_etc_environment_variable "ImageVersion" " ${ IMAGE_VERSION } "
set_etc_environment_variable "ImageOS" " ${ IMAGE_OS } "
2020-03-12 23:46:11 +03:00
2021-03-15 11:17:57 +03:00
# Set the ACCEPT_EULA variable to Y value to confirm your acceptance of the End-User Licensing Agreement
2023-12-26 12:50:52 +01:00
set_etc_environment_variable "ACCEPT_EULA" "Y"
2021-03-15 11:17:57 +03:00
2022-08-10 13:55:34 +01:00
# This directory is supposed to be created in $HOME and owned by user(https://github.com/actions/runner-images/issues/491)
2020-03-12 23:46:11 +03:00
mkdir -p /etc/skel/.config/configstore
2023-12-26 12:50:52 +01:00
set_etc_environment_variable "XDG_CONFIG_HOME" '$HOME/.config'
2020-06-04 15:09:41 +03:00
2024-03-14 10:53:11 +01:00
# Change waagent entries to use /mnt for swap file
2020-06-18 22:13:09 +03:00
sed -i 's/ResourceDisk.Format=n/ResourceDisk.Format=y/g' /etc/waagent.conf
sed -i 's/ResourceDisk.EnableSwap=n/ResourceDisk.EnableSwap=y/g' /etc/waagent.conf
sed -i 's/ResourceDisk.SwapSizeMB=0/ResourceDisk.SwapSizeMB=4096/g' /etc/waagent.conf
2020-06-25 18:56:42 +03:00
# Add localhost alias to ::1 IPv6
sed -i 's/::1 ip6-localhost ip6-loopback/::1 localhost ip6-localhost ip6-loopback/g' /etc/hosts
2020-06-04 15:09:41 +03:00
# Prepare directory and env variable for toolcache
AGENT_TOOLSDIRECTORY = /opt/hostedtoolcache
mkdir $AGENT_TOOLSDIRECTORY
2023-12-26 12:50:52 +01:00
set_etc_environment_variable "AGENT_TOOLSDIRECTORY" " ${ AGENT_TOOLSDIRECTORY } "
2020-06-04 15:09:41 +03:00
chmod -R 777 $AGENT_TOOLSDIRECTORY
2020-08-21 18:59:49 +03:00
# https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
# https://www.suse.com/support/kb/doc/?id=000016692
2020-10-07 13:49:40 +05:00
echo 'vm.max_map_count=262144' | tee -a /etc/sysctl.conf
2020-12-30 09:57:11 +03:00
2022-08-24 10:46:37 +02:00
# https://kind.sigs.k8s.io/docs/user/known-issues/#pod-errors-due-to-too-many-open-files
echo 'fs.inotify.max_user_watches=655360' | tee -a /etc/sysctl.conf
echo 'fs.inotify.max_user_instances=1280' | tee -a /etc/sysctl.conf
2024-03-15 11:06:43 +01:00
# https://github.com/actions/runner-images/issues/9491
echo 'vm.mmap_rnd_bits=28' | tee -a /etc/sysctl.conf
2023-07-24 00:44:55 -07:00
# https://github.com/actions/runner-images/pull/7860
netfilter_rule = '/etc/udev/rules.d/50-netfilter.rules'
2023-12-29 12:36:27 +01:00
rules_directory = " $( dirname " ${ netfilter_rule } " ) "
mkdir -p $rules_directory
2023-07-24 00:44:55 -07:00
touch $netfilter_rule
echo 'ACTION=="add", SUBSYSTEM=="module", KERNEL=="nf_conntrack", RUN+="/usr/sbin/sysctl net.netfilter.nf_conntrack_tcp_be_liberal=1"' | tee -a $netfilter_rule
2020-12-30 09:57:11 +03:00
# Create symlink for tests running
chmod +x $HELPER_SCRIPTS /invoke-tests.sh
2022-01-13 11:23:56 +03:00
ln -s $HELPER_SCRIPTS /invoke-tests.sh /usr/local/bin/invoke_tests
# Disable motd updates metadata
sed -i 's/ENABLED=1/ENABLED=0/g' /etc/default/motd-news
if [[ -f "/etc/fwupd/daemon.conf" ]] ; then
sed -i 's/UpdateMotd=true/UpdateMotd=false/g' /etc/fwupd/daemon.conf
systemctl mask fwupd-refresh.timer
fi
2022-05-06 12:54:50 +02:00
# Disable to load providers
# https://github.com/microsoft/azure-pipelines-agent/issues/3834
2023-12-26 12:50:52 +01:00
if is_ubuntu22; then
2022-05-06 12:54:50 +02:00
sed -i 's/openssl_conf = openssl_init/#openssl_conf = openssl_init/g' /etc/ssl/openssl.cnf
fi