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 29 30
|
#!/bin/sh
PREFIX="/run/incus_agent"
# Legacy handling
if [ ! -e "${PREFIX}" ] && [ -d "/run/lxd_agent" ]; then
ln -s "/run/lxd_agent" "${PREFIX}"
fi
mkdir -p "${PREFIX}/.mnt"
# Functions.
mount_9p() {
modprobe 9pnet_virtio >/dev/null 2>&1 || true
mount -t 9p agent "${PREFIX}/.mnt" -o ro,access=0,trans=virtio,size=1048576 >/dev/null 2>&1
}
# Mount the agent share.
mount_9p || fail "Couldn't mount 9p, failing."
# Transfer the agent binary.
rm -f "${PREFIX}/incus-agent"
cp -a "${PREFIX}/.mnt/incus-agent.linux.$(uname -m)" "${PREFIX}/incus-agent"
chown root:root "${PREFIX}/incus-agent"
# Unmount the temporary mount.
umount "${PREFIX}/.mnt"
rmdir "${PREFIX}/.mnt"
# Re-exec the agent.
exec "${PREFIX}/incus-agent" "$@"
|