Restart sysrepod, netopeer2-server and the cla-sysrepod upon failures
In addition, a restart of sysrepod is bad enough so that it restarts
everything else, and a failed netopeer2-server results in a restart of
sysrepod (and therefore everything else) because there's quite some
potential for confusion otherwise.
I saw that confusion; it wasn't pretty.
Change-Id: Iba18f594014c70e94727b69cd81ac9c57a0eafdb
diff --git a/board/czechlight/common/overlay/etc/systemd/system/czechlight-roadm-v2.service b/board/czechlight/common/overlay/etc/systemd/system/czechlight-roadm-v2.service
new file mode 100644
index 0000000..3afd902
--- /dev/null
+++ b/board/czechlight/common/overlay/etc/systemd/system/czechlight-roadm-v2.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=CzechLight CL-ROADMv2 driver
+After=syslog.target network.target sysrepod.service
+Reuires=sysrepod.service
+PartOf=sysrepod.service
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/cla-sysrepod --properties-log-level=5 --sr-bridge-log-level=5 --sysrepo-log-level=3 --driver=CL-ROADMv2 --port=/dev/ttyUSB0
+PrivateTmp=yes
+PrivateDevices=no
+ProtectSystem=yes
+ProtectHome=yes
+SystemCallArchitectures=native
+Restart=always
+StartLimitIntervalSec=0
+
+[Install]
+WantedBy=multi-user.target
diff --git a/board/czechlight/common/overlay/etc/systemd/system/netopeer2-server.service b/board/czechlight/common/overlay/etc/systemd/system/netopeer2-server.service
new file mode 100644
index 0000000..850c5b5
--- /dev/null
+++ b/board/czechlight/common/overlay/etc/systemd/system/netopeer2-server.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=A NETCONF server on top of sysrepo
+After=syslog.target network.target sysrepod.service
+Requires=sysrepod.service
+PartOf=sysrepod.service
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/netopeer2-server
+PIDFile=/var/run/netopeer2-server.pid
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectSystem=yes
+ProtectHome=yes
+SystemCallArchitectures=native
+Restart=always
+StartLimitIntervalSec=0
+
+[Install]
+WantedBy=multi-user.target
diff --git a/board/czechlight/common/overlay/etc/systemd/system/sysrepod.service b/board/czechlight/common/overlay/etc/systemd/system/sysrepod.service
new file mode 100644
index 0000000..d94a993
--- /dev/null
+++ b/board/czechlight/common/overlay/etc/systemd/system/sysrepod.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Sysrepo YANG configuration storage and management
+After=syslog.target network.target
+PartOf=netopeer2-server.service
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/sysrepod
+PIDFile=/var/run/sysrepod.pid
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectSystem=yes
+ProtectHome=yes
+SystemCallArchitectures=native
+Restart=always
+StartLimitIntervalSec=0
+
+[Install]
+WantedBy=multi-user.target
diff --git a/board/czechlight/common/overlay/root/doit-CL-ROADM-v2.sh b/board/czechlight/common/overlay/root/doit-CL-ROADM-v2.sh
index 5f9525d..1c48f2d 100755
--- a/board/czechlight/common/overlay/root/doit-CL-ROADM-v2.sh
+++ b/board/czechlight/common/overlay/root/doit-CL-ROADM-v2.sh
@@ -10,4 +10,10 @@
sysrepoctl --install --search-dir /usr/share/cla-sysrepo/yang --yang /usr/share/cla-sysrepo/yang/czechlight-roadm-v2.yang
sysrepocfg --datastore=startup --import=/usr/share/cla-sysrepo/yang/czechlight-roadm-v2.startup.xml czechlight-roadm-v2
+systemctl enable czechlight-roadm-v2
+systemctl start czechlight-roadm-v2
+
+systemctl enable netopeer2-server
+systemctl start netopeer2-server
+
echo 'cla-sysrepod --properties-log-level=5 --sr-bridge-log-level=5 --sysrepo-log-level=3 --driver=CL-ROADMv2 --port=/dev/ttyUSB0' >> ~/.ash_history