File: incus-agent

package info (click to toggle)
incus 6.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 24,428 kB
  • sloc: sh: 16,313; ansic: 3,121; python: 457; makefile: 337; ruby: 51; sql: 50; lisp: 6
file content (30 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (5)
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" "$@"