Update velia

Due to recent changes in velia, where we split the daemon into several
smaller ones, this commit adds service files for those new daemons
(veliad-{health,hardware,system}) and also installs a new YANG model
that is needed for the veliad-system functionality.

Also sync all dependencies, that's required due to the way the build
system picks versions of sysrepo, etc. And that in turn required a
sanity sweep over unit dependencies.

NOTE: anything that uses sysrepo must be listed in the reset-sysrepo
package, otherwise Bad Things(TM) happen.

Change-Id: I5aae8da2d7af95ead80070ad4cd18d7143e0f736
Co-authored-by: Jan Kundrát <jan.kundrat@cesnet.cz>
diff --git a/package/velia/velia-hardware.service b/package/velia/velia-hardware.service
new file mode 100644
index 0000000..d84140f
--- /dev/null
+++ b/package/velia/velia-hardware.service
@@ -0,0 +1,23 @@
+[Unit]
+Description=Tracking hardware metrics
+After=syslog.target network.target czechlight-install-yang.service cfg-restore-sysrepo.service
+Before=rauc-mark-good.service
+PartOf=netopeer2.service
+Requires=czechlight-install-yang.service cfg-restore-sysrepo.service
+ConditionKernelCommandLine=czechlight
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/veliad-hardware --log-level=4 --appliance=czechlight-clearfog
+PrivateTmp=yes
+PrivateDevices=no
+ProtectSystem=yes
+ProtectHome=yes
+Restart=always
+RestartSec=10s
+LogRateLimitIntervalSec=10
+LogRateLimitBurst=30000
+SyslogLevel=alert
+
+[Install]
+WantedBy=multi-user.target
diff --git a/package/velia/velia.service b/package/velia/velia-health.service
similarity index 77%
rename from package/velia/velia.service
rename to package/velia/velia-health.service
index 5eb6fc5..2506f85 100644
--- a/package/velia/velia.service
+++ b/package/velia/velia-health.service
@@ -1,5 +1,5 @@
 [Unit]
-Description=Velia is a health tracking for embedded devices running Linux
+Description=Health tracking of the whole system
 Requires=multi-user.target
 After=multi-user.target
 ConditionKernelCommandLine=czechlight
@@ -7,10 +7,10 @@
 [Service]
 Type=simple
 ExecStartPre=/bin/sh -c 'for COLOUR in red green blue; do echo none > /sys/class/leds/status:$${COLOUR}/trigger; echo 0 > /sys/class/leds/status:green/brightness; done'
-ExecStart=/usr/bin/veliad --log-level=4 --systemd-ignore-unit=systemd-journal-upload.service --appliance=czechlight-clearfog
+ExecStart=/usr/bin/veliad-health --log-level=4 --appliance=czechlight-clearfog --systemd-ignore-unit=systemd-journal-upload.service
 ExecStopPost=/bin/sh -c 'for COLOUR in red green blue; do echo 0 > /sys/class/leds/status:$$COLOUR/brightness; done; [[ "$EXIT_CODE" == "exited" ]] && COLOUR="green" || COLOUR="red"; echo timer > /sys/class/leds/status:$$COLOUR/trigger; echo 256 > /sys/class/leds/status:$$COLOUR/brightness'
 PrivateTmp=yes
-PrivateDevices=no
+PrivateDevices=yes
 ProtectSystem=yes
 ProtectHome=yes
 Restart=always
diff --git a/package/velia/velia-system.service b/package/velia/velia-system.service
new file mode 100644
index 0000000..af00c14
--- /dev/null
+++ b/package/velia/velia-system.service
@@ -0,0 +1,23 @@
+[Unit]
+Description=System management via sysrepo
+After=syslog.target network.target czechlight-install-yang.service cfg-restore-sysrepo.service
+Before=rauc-mark-good.service
+PartOf=netopeer2.service
+Requires=czechlight-install-yang.service cfg-restore-sysrepo.service
+ConditionKernelCommandLine=czechlight
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/veliad-system --log-level=4
+PrivateTmp=yes
+PrivateDevices=no
+ProtectSystem=yes
+ProtectHome=yes
+Restart=always
+RestartSec=10s
+LogRateLimitIntervalSec=10
+LogRateLimitBurst=30000
+SyslogLevel=alert
+
+[Install]
+WantedBy=multi-user.target
diff --git a/package/velia/velia.mk b/package/velia/velia.mk
index b09a0e9..a32c38e 100644
--- a/package/velia/velia.mk
+++ b/package/velia/velia.mk
@@ -7,16 +7,22 @@
 VELIA_LICENSE = Apache-2.0
 VELIA_LICENSE_FILES = LICENSE.md
 
+define VELIA_PREPARE_SERVICE
+    $(INSTALL) -D -m 0644 \
+            $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/velia/$1.service \
+            $(TARGET_DIR)/usr/lib/systemd/system/
+    ln -sf ../$1.service $(TARGET_DIR)/usr/lib/systemd/system/multi-user.target.wants/
+endef
+
 define VELIA_INSTALL_INIT_SYSTEMD
         mkdir -p $(TARGET_DIR)/usr/lib/systemd/system/multi-user.target.wants/
         $(INSTALL) -D -m 0644 \
-                $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/velia/velia.service \
-                $(TARGET_DIR)/usr/lib/systemd/system/
-        ln -sf ../velia.service $(TARGET_DIR)/usr/lib/systemd/system/multi-user.target.wants/
-
-		$(INSTALL) -D -m 0644 \
                 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/velia/max_match_rules.conf \
                 $(TARGET_DIR)/usr/share/dbus-1/system.d/
+
+        $(call VELIA_PREPARE_SERVICE,velia-health)
+        $(call VELIA_PREPARE_SERVICE,velia-hardware)
+        $(call VELIA_PREPARE_SERVICE,velia-system)
 endef
 
 $(eval $(cmake-package))