File: install.sh

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 (44 lines) | stat: -rw-r--r-- 1,302 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
if [ ! -e "systemd" ] || [ ! -e "incus-agent" ]; then
    echo "This script must be run from within the 9p mount"
    exit 1
fi

# Find target path.
TARGET=""
for alternative in /usr/lib /lib /etc; do
    [ -w "${alternative}/systemd" ] || continue
    [ -w "${alternative}/udev" ] || continue

    TARGET="${alternative}"
    break
done

if [ "${TARGET}" = "" ]; then
    echo "This script only works on systemd systems"
    exit 1
fi

echo "Installing agent into ${TARGET}"

# Install the units.
cp udev/99-incus-agent.rules "${TARGET}/udev/rules.d/"
cp systemd/incus-agent.service "${TARGET}/systemd/system/"
cp systemd/incus-agent-setup "${TARGET}/systemd/"

# Replacing the variables.
sed -i "s#TARGET#${TARGET}#g" "${TARGET}/udev/rules.d/99-incus-agent.rules"
sed -i "s#TARGET#${TARGET}#g" "${TARGET}/systemd/system/incus-agent.service"
sed -i "s#TARGET#${TARGET}#g" "${TARGET}/systemd/incus-agent-setup"

# Make sure systemd is aware of them.
systemctl daemon-reload

# SELinux handling.
if getenforce >/dev/null 2>&1 && type semanage >/dev/null 2>&1; then
    semanage fcontext -a -t bin_t /var/run/incus_agent/incus-agent
fi

echo ""
echo "Incus agent has been installed, reboot to confirm setup."
echo "To start it now, unmount this filesystem and run: systemctl start incus-agent"