2021-11-26 00:33:21 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
enable_apt_cache() {
|
|
|
|
local apt_caching_server="http://172.16.230.100:3142";
|
|
|
|
|
|
|
|
task_begin "Configuring ${apt_caching_server} as apt cache";
|
|
|
|
|
|
|
|
subtask_begin "Updating apt configuration";
|
2021-11-26 22:08:07 +00:00
|
|
|
echo "Acquire::http { Proxy \"${apt_caching_server}\"; }" >/etc/apt/apt.conf.d/proxy
|
2021-11-26 00:33:21 +00:00
|
|
|
subtask_end "$?";
|
|
|
|
|
|
|
|
# From /etc/os-release - see run.sh
|
|
|
|
if [[ "${ID}" == "raspbian" ]]; then
|
2022-08-06 19:54:45 +00:00
|
|
|
subtask_begin "Patching for Raspbian";
|
2021-11-26 00:33:21 +00:00
|
|
|
if [[ -e "/etc/apt/sources.list.d/raspi" ]]; then
|
|
|
|
rm /etc/apt/sources.list.d/raspi;
|
|
|
|
fi
|
|
|
|
subtask_end "$?";
|
|
|
|
fi
|
|
|
|
|
2022-08-06 19:54:45 +00:00
|
|
|
# HTTPS doesn't allow for our proxy to cache it
|
2022-08-06 19:50:45 +00:00
|
|
|
subtask_begin "Reconfiguring existing apt sources https → http";
|
2022-08-06 19:54:45 +00:00
|
|
|
sed -i 's/https:/http:/g' /etc/apt/sources.list;
|
2022-08-06 19:50:45 +00:00
|
|
|
find /etc/apt/sources.list.d/ -type f -iname '*.list' -print0 | xargs -0 -n1 sed -i 's/https:\/\//http:\/\//g';
|
|
|
|
subtask_end "$?";
|
|
|
|
|
2021-11-26 00:33:21 +00:00
|
|
|
task_end "$?" "Failed to configure apt cache.";
|
|
|
|
}
|
|
|
|
|
|
|
|
enable_apt_cache;
|