diff mbox series

ugps: start also in case device is absent

Message ID YK92dc3bxkQFPMbr@makrotopia.org
State Under Review
Delegated to: Daniel Golle
Headers show
Series ugps: start also in case device is absent | expand

Commit Message

Daniel Golle May 27, 2021, 10:37 a.m. UTC
Don't bail out from init script in case the GPS device is missing.
Some modems take time to come up, and some people may use things like
'kplex' to feed ugpsd. Hence it is better to always start ugpsd
unconditionally and let procd's respawn take care of retrying.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 package/utils/ugps/Makefile        |  2 +-
 package/utils/ugps/files/ugps.init | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

Comments

Piotr Dymacz May 28, 2021, 7:58 a.m. UTC | #1
Hi Daniel,

On 27.05.2021 12:37, Daniel Golle wrote:
> Don't bail out from init script in case the GPS device is missing.
> Some modems take time to come up, and some people may use things like
> 'kplex' to feed ugpsd. Hence it is better to always start ugpsd
> unconditionally and let procd's respawn take care of retrying.

Wouldn't hotplug be a better solution than respawning process forever 
(not sure about kplex usage)?
Daniel Golle May 28, 2021, 8:06 a.m. UTC | #2
On Fri, May 28, 2021 at 09:58:48AM +0200, Piotr Dymacz wrote:
> Hi Daniel,
> 
> On 27.05.2021 12:37, Daniel Golle wrote:
> > Don't bail out from init script in case the GPS device is missing.
> > Some modems take time to come up, and some people may use things like
> > 'kplex' to feed ugpsd. Hence it is better to always start ugpsd
> > unconditionally and let procd's respawn take care of retrying.
> 
> Wouldn't hotplug be a better solution than respawning process forever (not
> sure about kplex usage)?

If it was an actual serial device being used, then yes, hotplug would
be the better solution. If what we are waiting for is a PTY created by
another process (think: kplex) hotplug would not be of much use there
(maybe inotifywait on a directory in tmpfs only used for the gps PTY
would be an option, but then require inotifywait...).
I agree that it would be nice to find a generic catch-them-all solution
though which doesn't require endless respawning.


> 
> -- 
> Cheers,
> Piotr
> 
> > 
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> > ---
> >   package/utils/ugps/Makefile        |  2 +-
> >   package/utils/ugps/files/ugps.init | 12 ++++++++----
> >   2 files changed, 9 insertions(+), 5 deletions(-)
> > 
> > diff --git a/package/utils/ugps/Makefile b/package/utils/ugps/Makefile
> > index 4ce64d9631..16cdbc41b9 100644
> > --- a/package/utils/ugps/Makefile
> > +++ b/package/utils/ugps/Makefile
> > @@ -8,7 +8,7 @@
> >   include $(TOPDIR)/rules.mk
> >   PKG_NAME:=ugps
> > -PKG_RELEASE:=1
> > +PKG_RELEASE:=2
> >   PKG_SOURCE_URL=$(PROJECT_GIT)/project/ugps.git
> >   PKG_SOURCE_PROTO:=git
> > diff --git a/package/utils/ugps/files/ugps.init b/package/utils/ugps/files/ugps.init
> > index 3cd1ca1b8d..f52b19cc27 100644
> > --- a/package/utils/ugps/files/ugps.init
> > +++ b/package/utils/ugps/files/ugps.init
> > @@ -17,10 +17,14 @@ start_service() {
> >   	[ "$disabled" == "0" ] || return
> > -	[ -c "$tty" ] || {
> > -		tty="/dev/$tty"
> > -		[ -c "$tty" ] || return
> > -	}
> > +	case "$tty" in
> > +		"/"*)
> > +			true
> > +			;;
> > +		*)
> > +			tty="/dev/$tty"
> > +			;;
> > +	esac
> >   	procd_open_instance
> >   	procd_set_param command "$PROG"
> > 
>
diff mbox series

Patch

diff --git a/package/utils/ugps/Makefile b/package/utils/ugps/Makefile
index 4ce64d9631..16cdbc41b9 100644
--- a/package/utils/ugps/Makefile
+++ b/package/utils/ugps/Makefile
@@ -8,7 +8,7 @@ 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ugps
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/ugps.git
 PKG_SOURCE_PROTO:=git
diff --git a/package/utils/ugps/files/ugps.init b/package/utils/ugps/files/ugps.init
index 3cd1ca1b8d..f52b19cc27 100644
--- a/package/utils/ugps/files/ugps.init
+++ b/package/utils/ugps/files/ugps.init
@@ -17,10 +17,14 @@  start_service() {
 
 	[ "$disabled" == "0" ] || return
 
-	[ -c "$tty" ] || {
-		tty="/dev/$tty"
-		[ -c "$tty" ] || return
-	}
+	case "$tty" in
+		"/"*)
+			true
+			;;
+		*)
+			tty="/dev/$tty"
+			;;
+	esac
 
 	procd_open_instance
 	procd_set_param command "$PROG"