krata: rewrite all repo infrastructure

This commit is contained in:
Alex Zenla
2024-03-07 09:04:05 +00:00
parent baefe0dceb
commit 670e140682
39 changed files with 419 additions and 181 deletions

39
resources/bundle/install.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/sh
set -e
remove_service_if_exists() {
if systemctl show -P FragmentPath "${1}" > /dev/null
then
UNIT_PATH="$(systemctl show -P FragmentPath "${1}")"
if [ -f "${UNIT_PATH}" ]
then
echo "[WARN] disabling removing systemd unit ${UNIT_PATH}" > /dev/stderr
systemctl disable --now "${1}" || true
rm "${UNIT_PATH}"
fi
fi
}
REAL_SCRIPT="$(realpath "${0}")"
cd "$(dirname "${REAL_SCRIPT}")"
remove_service_if_exists kratad.service
remove_service_if_exists kratanet.service
cp kratad.service /usr/lib/systemd/system/kratad.service
cp kratanet.service /usr/lib/systemd/system/kratanet.service
cp kratad kratanet /usr/libexec
cp kratactl /usr/bin
chmod +x /usr/libexec/kratad
chmod +x /usr/libexec/kratanet
chmod +x /usr/bin/kratactl
mkdir -p /var/lib/krata /usr/share/krata/guest
cp kernel /usr/share/krata/guest/kernel
cp initrd /usr/share/krata/guest/initrd
systemctl daemon-reload
systemctl enable kratad.service kratanet.service
systemctl restart kratad.service kratanet.service

12
resources/bundle/uninstall.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
systemctl disable --now kratad.service || true
systemctl disable --now kratanet.service || true
rm -f /usr/lib/systemd/system/kratad.service
rm -f /usr/lib/systemd/system/kratanet.service
rm -f /usr/bin/kratactl
rm -f /usr/libexec/kratad /usr/libexec/kratanet
rm -rf /usr/share/krata

View File

@ -1,32 +0,0 @@
#!/bin/sh
set -e
REAL_SCRIPT="$(realpath "${0}")"
cd "$(dirname "${REAL_SCRIPT}")"
if [ -f "/etc/systemd/system/kratad.service" ]
then
systemctl disable --now kratad.service
fi
if [ -f "/etc/systemd/system/kratanet.service" ]
then
systemctl disable --now kratanet.service
fi
cp kratad.service /etc/systemd/system/kratad.service
cp kratanet.service /etc/systemd/system/kratanet.service
cp kratad kratanet kratactl /usr/local/bin
chmod +x /usr/local/bin/kratad
chmod +x /usr/local/bin/kratanet
chmod +x /usr/local/bin/kratactl
mkdir -p /var/lib/krata/default
cp kernel /var/lib/krata/default/kernel
cp initrd /var/lib/krata/default/initrd
systemctl daemon-reload
systemctl enable kratad.service kratanet.service
systemctl restart kratad.service kratanet.service

View File

@ -1,11 +1,11 @@
[Unit]
Description=Krata Controller Daemon
Description=Krata Control Daemon
[Service]
Restart=on-failure
Type=simple
WorkingDirectory=/var/lib/krata
ExecStart=/usr/local/bin/kratad -l unix:///var/lib/krata/daemon.socket
ExecStartPre=/bin/mkdir -p /var/lib/krata
ExecStart=/usr/libexec/kratad -l unix:///var/lib/krata/daemon.socket
Environment=RUST_LOG=info
User=root

View File

@ -4,8 +4,7 @@ Description=Krata Networking Daemon
[Service]
Restart=on-failure
Type=simple
WorkingDirectory=/var/lib/krata
ExecStart=/usr/local/bin/kratanet
ExecStart=/usr/libexec/kratanet
Environment=RUST_LOG=info
User=root