Skip to content

Commit

Permalink
Merge pull request #669 from m2Giles/patch-1
Browse files Browse the repository at this point in the history
Change incus-agent install location to writeable location
  • Loading branch information
stgraber authored May 22, 2024
2 parents 37627be + cb07cb6 commit 2c5a38b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 23 additions & 4 deletions internal/server/instance/drivers/agent-loader/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,34 @@ if [ ! -e "systemd" ] || [ ! -e "incus-agent" ]; then
exit 1
fi

if [ ! -e "/lib/systemd/system" ]; then
# 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 /lib/udev/rules.d/
cp systemd/incus-agent.service /lib/systemd/system/
cp systemd/incus-agent-setup /lib/systemd/
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DefaultDependencies=no
[Service]
Type=notify
WorkingDirectory=-/run/incus_agent
ExecStartPre=/lib/systemd/incus-agent-setup
ExecStartPre=TARGET/systemd/incus-agent-setup
ExecStart=/run/incus_agent/incus-agent
Restart=on-failure
RestartSec=5s
Expand Down

0 comments on commit 2c5a38b

Please sign in to comment.