Diese Zusatzpakete installieren wir im Basiscontainer:
joe
openssh-server
123456789101112
[email protected]# lxc exec debian-9 /bin/bash
[email protected]# apt-get install joe
Reading package lists... Done
Building dependency tree
Reading state information... Done
...
Unpacking joe (4.4-1) ...
Setting up joe (4.4-1) ...
update-alternatives: using /usr/bin/joe to provide /usr/bin/editor (editor) in auto mode
[email protected]# apt-get install openssh-server
...
[email protected]# apt-get clean
#!/bin/sh
# port of apt-cacher-ng on the lxd host
PORT=3142
APT_PROXY_FILE="/etc/apt/apt.conf.d/01proxy"
LXDHOST=
for h in $(ip addr|grep -o "inet [0-9.]*/"|grep -v 127.0.0.1|grep -o "[0-9.]*"|sed -e "s/[.][0-9]*$/.1/"); do
nc -z "${h}" "${PORT}" && { LXDHOST="${h}"; break; }
done
if [ -n "${LXDHOST}" ]; then
echo >"${APT_PROXY_FILE}" "Acquire::http::Proxy \"http://${LXDHOST}:${PORT}\";"
else
rm -f "${APT_PROXY_FILE}"
fi
/root/systemd/apt-proxy.service
123456789101112
[Unit]
Description=Apt proxy to apt-cacher-ng on lxd host
After=network.target
[Service]
ExecStart=/root/bin/apt-proxy.sh
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Aktivieren
123
[email protected]:~# systemctl enable /root/systemd/apt-proxy.service
Created symlink /etc/systemd/system/multi-user.target.wants/apt-proxy.service → /root/systemd/apt-proxy.service.
Created symlink /etc/systemd/system/apt-proxy.service → /root/systemd/apt-proxy.service.
Test
1234567891011121314
[email protected]:~# reboot
...
[email protected]:~# systemctl status apt-proxy
● apt-proxy.service - Apt proxy to apt-cacher-ng on lxd host
Loaded: loaded (/root/systemd/apt-proxy.service; enabled; vendor preset: enabled)
Active: active (exited) since Sat 2020-04-11 08:51:37 CEST; 36s ago
Process: 102 ExecStart=/root/bin/apt-proxy.sh (code=exited, status=0/SUCCESS)
Main PID: 102 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/apt-proxy.service
Apr 11 08:51:37 debian-9 systemd[1]: Started Apt proxy to apt-cacher-ng on lxd host.
Apr 11 08:51:37 debian-9 systemd[1]: apt-proxy.service: Failed to reset devices.list: Operation not permitted
Apr 11 08:51:37 debian-9 systemd[1]: apt-proxy.service: Failed to set invocation ID on control group /system.slice/apt-proxy.service, ignoring: Operation not permitted