{"id":3348,"date":"2018-08-16T11:45:54","date_gmt":"2018-08-16T16:45:54","guid":{"rendered":"http:\/\/lisa.rushworth.us\/?p=3348"},"modified":"2018-08-16T11:45:54","modified_gmt":"2018-08-16T16:45:54","slug":"openhab-with-custom-built-serial-binding-fix-to-locking-permission-issue","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=3348","title":{"rendered":"openHAB With Custom Built Serial Binding &#8211; fix to locking permission issue"},"content":{"rendered":"<p>When we updated our openHAB server to Fedora 28 and changed to a non-root user, the openhab user was unable to create lock files in \/run\/lock. As an interim fix, we just changed the permission on the lock folder to allow the openhab account to create files. As a more elegant solution, I&#8217;ve built the nrjavaserial JAR file from the <a href=\"https:\/\/github.com\/NeuronRobotics\/nrjavaserial\/\" target=\"_blank\" rel=\"noopener\">source in NeuronRobotics&#8217; repository<\/a>.<\/p>\n<p>The process to build and use a JAR built from this source follows. Before attempting to build the nrjavaserial jar from source, ensure you have gradle (which will install a LOT of additional packages), lockdev, lockdev-devel, some jdk, and some jdk-devel (I used java-1.8.0-openjdk-1.8.0.181-7.b13.fc28.x86_64 and java-1.8.0-openjdk-devel-1.8.0.181-7.b13.fc28.x86_64 because they were already installed for other projects).<\/p>\n<p># Set ossrhUsername and ossrhPassword values for the account used to build the project &#8211; username and password can be null<br \/>\n[lisa@server ~]# cat ~\/.gradle\/gradle.properties<br \/>\nossrhUsername=<br \/>\nossrhPassword=<\/p>\n<p># Grab the source<br \/>\n[lisa@server ~]# git clone https:\/\/github.com\/NeuronRobotics\/nrjavaserial.git<\/p>\n<p># Build the project<br \/>\n[lisa@server ~]# cd nrjavaserial<br \/>\n[lisa@server nrjavaserial]# make linux64 # assuming you&#8217;ve got 64-bit linux<\/p>\n<p># Voila, a jar file<br \/>\n[lisa@server nrjavaserial]# cd build\/libs<br \/>\n[lisa@server libs]# ll<br \/>\ntotal 852<br \/>\n-rw-r&#8211;r&#8211; 1 root root 611694 Aug 16 10:08 nrjavaserial-3.14.0.jar<br \/>\n-rw-r&#8211;r&#8211; 1 root root 170546 Aug 16 10:08 nrjavaserial-3.14.0-javadoc.jar<br \/>\n-rw-r&#8211;r&#8211; 1 root root 85833 Aug 16 10:08 nrjavaserial-3.14.0-sources.jar<\/p>\n<p>Before installing the newly built nrjavaserial-3.14.0.jar into openHAB, ensure you have lockdev installed on your Fedora machine and add your openhab user account to the lock group.<\/p>\n<p># Verify the lockdev folder was created<br \/>\n[lisa@server ~]# ll \/run\/lock\/<br \/>\ntotal 4<br \/>\n-rw-r&#8211;r&#8211; 1 root root 22 Aug 10 15:35 asound.state.lock<br \/>\ndrwx&#8212;&#8212; 2 root root 60 Aug 10 15:30 iscsi<br \/>\ndrwxrwxr-x 2 root lock 140 Aug 16 12:19 lockdev<br \/>\ndrwx&#8212;&#8212; 2 root root 40 Aug 10 15:30 lvm<br \/>\ndrwxr-xr-x 2 root root 40 Aug 10 15:30 ppp<br \/>\ndrwxr-xr-x 2 root root 40 Aug 10 15:30 subsys<br \/>\n# Add the openhab user to the lock group<br \/>\n[lisa@server ~]# usermod -a -G lock openhab<\/p>\n<p>The openhab user account can now write to the \/run\/lock\/lockdev folder. Install the new jar file into openHAB. When you restart openHAB, verify lock files are created as expected.<br \/>\n[lisa@server ~]# ll \/run\/lock\/lockdev\/<br \/>\ntotal 20<br \/>\n-rw-rw-r&#8211; 5 openhab openhab 11 Aug 16 12:19 LCK&#8230;31525<br \/>\n-rw-rw-r&#8211; 5 openhab openhab 11 Aug 16 12:19 LCK..ttyUSB-5<br \/>\n-rw-rw-r&#8211; 5 openhab openhab 11 Aug 16 12:19 LCK..ttyUSB-55<br \/>\n-rw-rw-r&#8211; 5 openhab openhab 11 Aug 16 12:19 LK.000.188.000<br \/>\n-rw-rw-r&#8211; 5 openhab openhab 11 Aug 16 12:19 LK.000.188.001<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When we updated our openHAB server to Fedora 28 and changed to a non-root user, the openhab user was unable to create lock files in \/run\/lock. As an interim fix, we just changed the permission on the lock folder to allow the openhab account to create files. As a more elegant solution, I&#8217;ve built the &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[63,30],"tags":[642,638,643,44,394],"class_list":["post-3348","post","type-post","status-publish","format-standard","hentry","category-home-automation","category-system-administration","tag-liblockdev","tag-lockdev","tag-nrjavaserial","tag-openhab","tag-openhab2"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/3348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3348"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/3348\/revisions"}],"predecessor-version":[{"id":3349,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/3348\/revisions\/3349"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}