Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jan 2021 18:01:34 +0100
From:      Polytropon <freebsd@edvax.de>
To:        Scott <freebsd-lists-5@thismonkey.com>
Cc:        "James B. Byrne" <byrnejb@harte-lyne.ca>, Polytropon <freebsd@edvax.de>, freebsd-questions@freebsd.org
Subject:   Re: Need help specifying args in rc.conf for a service
Message-ID:  <20210113180134.a481ad1e.freebsd@edvax.de>
In-Reply-To: <X/4yYW1cZcaWEEC5@thismonkey.com>
References:  <mailman.68.1610452801.64653.freebsd-questions@freebsd.org> <74ebbde2ed354c37fc2a84cbf3e36840.squirrel@webmail.harte-lyne.ca> <X/4yYW1cZcaWEEC5@thismonkey.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Wed, 13 Jan 2021 10:36:01 +1100, Scott wrote:
> On Tue, Jan 12, 2021 at 09:35:58AM -0500, James B. Byrne wrote:
> > 
> > 
> > On Mon, January 11, 2021 07:55, Scott wrote:
> > >
> > > here's what I get using:
> > >         node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)($|/)"'
> > >
> > > + _doit=$' limits -C daemon su -m nobody -c \'sh -c "/usr/sbin/daemon  -f -p
> > > /var/run/node_exporter.pid -T node_exporter     /usr/bin/env
> > > /usr/local/bin/node_exporter     --web.listen-address=:9100
> > > --collector.textfile.directory=/var/tmp/node_exporter
> > > --collector.filesystem.ignored-mount-points="^/(dev)($|/)""\''
> > > + _run_rc_doit $' limits -C daemon su -m nobody -c \'sh -c "/usr/sbin/daemon
> > > -f -p /var/run/node_exporter.pid -T node_exporter     /usr/bin/env
> > > /usr/local/bin/node_exporter     --web.listen-address=:9100
> > > --collector.textfile.directory=/var/tmp/node_exporter
> > > --collector.filesystem.ignored-mount-points="^/(dev)($|/)""\''
> > > + debug $'run_rc_command: doit:  limits -C daemon su -m nobody -c \'sh -c
> > > "/usr/sbin/daemon  -f -p /var/run/node_exporter.pid -T node_exporter
> > > /usr/bin/env /usr/local/bin/node_exporter     --web.listen-address=:9100
> > > --collector.textfile.directory=/var/tmp/node_exporter
> > > --collector.filesystem.ignored-mount-points="^/(dev)($|/)""\''
> > > + eval $' limits -C daemon su -m nobody -c \'sh -c "/usr/sbin/daemon  -f -p
> > > /var/run/node_exporter.pid -T node_exporter     /usr/bin/env
> > > /usr/local/bin/node_exporter     --web.listen-address=:9100
> > > --collector.textfile.directory=/var/tmp/node_exporter
> > > --collector.filesystem.ignored-mount-points="^/(dev)($|/)""\''
> > > + limits -C daemon su -m nobody -c 'sh -c "/usr/sbin/daemon  -f -p
> > > /var/run/node_exporter.pid -T node_exporter     /usr/bin/env
> > > /usr/local/bin/node_exporter     --web.listen-address=:9100
> > > --collector.textfile.directory=/var/tmp/node_exporter
> > > --collector.filesystem.ignored-mount-points="^/(dev)($|/)""'
> > > Illegal variable name.
> > >
> > > Thanks
> > >
> > >
> > 
> > Try escaping the '$' character (\$).
> > 
> > 
> > node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)(\$|/)"'
> > [...]
> 
> No joy:
> 
> + _doit=$' limits -C daemon su -m nobody -c \'sh -c "/usr/sbin/daemon  -f -p /var/run/node_exporter.pid -T node_exporter     /usr/bin/env /usr/local/bin/node_exporter     --web.listen-address=:9100     --collector.textfile.directory=/var/tmp/node_exporter     --collector.filesystem.ignored-mount-points="^/(dev)(\\$|/)""\''
> + _run_rc_doit $' limits -C daemon su -m nobody -c \'sh -c "/usr/sbin/daemon  -f -p /var/run/node_exporter.pid -T node_exporter     /usr/bin/env /usr/local/bin/node_exporter     --web.listen-address=:9100     --collector.textfile.directory=/var/tmp/node_exporter     --collector.filesystem.ignored-mount-points="^/(dev)(\\$|/)""\''
> + debug $'run_rc_command: doit:  limits -C daemon su -m nobody -c \'sh -c "/usr/sbin/daemon  -f -p /var/run/node_exporter.pid -T node_exporter     /usr/bin/env /usr/local/bin/node_exporter     --web.listen-address=:9100     --collector.textfile.directory=/var/tmp/node_exporter     --collector.filesystem.ignored-mount-points="^/(dev)(\\$|/)""\''
> + eval $' limits -C daemon su -m nobody -c \'sh -c "/usr/sbin/daemon  -f -p /var/run/node_exporter.pid -T node_exporter     /usr/bin/env /usr/local/bin/node_exporter     --web.listen-address=:9100     --collector.textfile.directory=/var/tmp/node_exporter     --collector.filesystem.ignored-mount-points="^/(dev)(\\$|/)""\''
> + limits -C daemon su -m nobody -c 'sh -c "/usr/sbin/daemon  -f -p /var/run/node_exporter.pid -T node_exporter     /usr/bin/env /usr/local/bin/node_exporter     --web.listen-address=:9100     --collector.textfile.directory=/var/tmp/node_exporter     --collector.filesystem.ignored-mount-points="^/(dev)(\$|/)""'
> Badly placed (.

The last error indicates that there still is a problem with
escaping and quoting. You'd have to find a combination of ",
' and \ to make it work.

Another idea: Create a file /etc/ignore.txt with the following
content:

	"^/(dev)(\$|/)"

Make sure no \n follows - the 2nd " should be the last symbol
in the file, its size therefore be 15 bytes.

In /etc/rc.conf, try:

	node_exporter_args="--collector.filesystem.ignored-mount-points=`/in/cat /etc/ignore.txt`"

It's not fully clear to me where the expansion attempt happens,
but it seems that it happens in at least two places: first in
/etc/rc.conf, which turns \$ into literal $, and further down
in the "starter script" which reads $ and tries to expand it,
instead of using it "as is". The idea is to keep at least one
of those possible interpreters from interpreting, which almost
every time leads to a predictable mis-interpretation.

To avoid this, try /etc/ignore.txt with:

	'^/(dev)($|/)'

or maybe even:

	'^/(dev)(\$|/)'

Finally, you have the ability to hard-code the $ at the last
place it will be processed, checking the "surrounding" for any
possible variable evalation. That is of course not an ideal
solution, but it might be a working solution. Create a diff for
it so you can apply it after each program upgrade.


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20210113180134.a481ad1e.freebsd>