git: 5529844e1456 - main - net/remarkable-devd: new port -- Devd hotplug rules for Remarkable Tablet
Tobias C. Berner
tcberner at FreeBSD.org
Wed Jul 14 10:37:27 UTC 2021
The branch main has been updated by tcberner:
URL: https://cgit.FreeBSD.org/ports/commit/?id=5529844e1456e2692b756ca5368e215cea0e0a17
commit 5529844e1456e2692b756ca5368e215cea0e0a17
Author: Trenton Schulz <trueos at norwegianrockcat.com>
AuthorDate: 2021-07-14 10:32:37 +0000
Commit: Tobias C. Berner <tcberner at FreeBSD.org>
CommitDate: 2021-07-14 10:36:53 +0000
net/remarkable-devd: new port -- Devd hotplug rules for Remarkable Tablet
Automatic IP address when connecting a Remarkable Tablet to USB. This
makes it possible to access your Remarkable tablet via ssh or its USB
web interface when it's enabled.
PR: 256754
---
net/Makefile | 1 +
net/remarkable-devd/Makefile | 27 +++++++++++++++++
net/remarkable-devd/files/pkg-message.in | 14 +++++++++
net/remarkable-devd/files/remarkable.conf.in | 7 +++++
net/remarkable-devd/files/remarkable.in | 45 ++++++++++++++++++++++++++++
net/remarkable-devd/pkg-descr | 3 ++
6 files changed, 97 insertions(+)
diff --git a/net/Makefile b/net/Makefile
index c4dcdcab2497..8c6f797407df 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -1179,6 +1179,7 @@
SUBDIR += recvnet
SUBDIR += redir
SUBDIR += relayd
+ SUBDIR += remarkable-devd
SUBDIR += remmina
SUBDIR += remotebox
SUBDIR += remotedesk
diff --git a/net/remarkable-devd/Makefile b/net/remarkable-devd/Makefile
new file mode 100644
index 000000000000..bf533ed082be
--- /dev/null
+++ b/net/remarkable-devd/Makefile
@@ -0,0 +1,27 @@
+# Created by: Trenton Schulz <trueos at norwegianrockcat.com>
+
+PORTNAME= remarkable-devd
+PORTVERSION= 1.0
+CATEGORIES= net
+MASTER_SITES= #
+DISTFILES= #
+
+MAINTAINER= trueos at norwegianrockcat.com
+COMMENT= Devd hotplug rules for Remarkable Tablet
+
+LICENSE= BSD2CLAUSE
+
+USE_RC_SUBR= remarkable
+
+NO_BUILD= yes
+
+SUB_FILES= pkg-message \
+ remarkable.conf
+
+PLIST_FILES= etc/devd/remarkable.conf
+
+do-install:
+ ${INSTALL_DATA} ${WRKDIR}/remarkable.conf ${STAGEDIR}${PREFIX}/etc/devd/remarkable.conf
+ ${INSTALL_SCRIPT} ${WRKDIR}/remarkable ${STAGEDIR}${PREFIX}/etc/rc.d/remarkable
+
+.include <bsd.port.mk>
diff --git a/net/remarkable-devd/files/pkg-message.in b/net/remarkable-devd/files/pkg-message.in
new file mode 100644
index 000000000000..fd0cd91764e5
--- /dev/null
+++ b/net/remarkable-devd/files/pkg-message.in
@@ -0,0 +1,14 @@
+[
+{ type: install
+ message: <<EOM
+A devd rule and rc script has been added to get an address from the
+remarkable tablet when it is connected. This is disabled by default.
+Set remarkable_enable=YES if you want this to happen automatically. Devd must also be restarted.
+
+# sysrc remarkable_enable=YES
+# service devd restart
+
+For details, see %%PREFIX%%/etc/devd/remarkable.conf and %%PREFIX%%/etc/rc.d/remarkable
+EOM
+}
+]
diff --git a/net/remarkable-devd/files/remarkable.conf.in b/net/remarkable-devd/files/remarkable.conf.in
new file mode 100644
index 000000000000..66efd43b8dc2
--- /dev/null
+++ b/net/remarkable-devd/files/remarkable.conf.in
@@ -0,0 +1,7 @@
+# Connect the Remarkable 1 device and get the IP address
+attach 100 {
+ device-name "urndis.+";
+ match "vendor" "0x04b3";
+ match "product" "0x4010";
+ action "%%PREFIX%%/etc/rc.d/remarkable start $device-name";
+};
diff --git a/net/remarkable-devd/files/remarkable.in b/net/remarkable-devd/files/remarkable.in
new file mode 100644
index 000000000000..5033009ea16a
--- /dev/null
+++ b/net/remarkable-devd/files/remarkable.in
@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# PROVIDE: webcamd
+# REQUIRE: FILESYSTEMS netif dbus
+# BEFORE: devd
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name=remarkable
+rcvar=remarkable_enable
+load_rc_config $name
+
+devd_device=${2}
+start_cmd="${name}_start"
+
+remarkable_start_devd()
+{
+ # Find the USB Ethernet for the device
+ # We first grab the total number of interfaces in
+ # the case when all the interfaces are USB Ethernet
+ local total_ifs=`sysctl -n net.link.generic.system.ifcount`
+ local i=0
+ for i in $(seq 0 $total_ifs)
+ do
+ ueparent=`sysctl -n net.ue.$i.%parent`
+ if [ $? -eq 0 ] && [ $ueparent = $devd_device ]; then
+ /sbin/dhclient ue$i
+ return
+ fi
+ done
+ echo "Couldn't find a remarkable tablet."
+}
+
+remarkable_start()
+{
+ if [ "$devd_device" ]; then
+ remarkable_start_devd
+ else
+ echo "Plug in your Remarkable to connect to it"
+ fi
+}
+
+run_rc_command "$1"
+
diff --git a/net/remarkable-devd/pkg-descr b/net/remarkable-devd/pkg-descr
new file mode 100644
index 000000000000..1196e4e754b6
--- /dev/null
+++ b/net/remarkable-devd/pkg-descr
@@ -0,0 +1,3 @@
+Automatic IP address when connecting a Remarkable Tablet to USB. This
+makes it possible to access your Remarkable tablet via ssh or its USB
+web interface when it's enabled.
More information about the dev-commits-ports-main
mailing list