Re: backticks in rc.conf
On Tue, 21 Jul 2009 13:21:04 +0100, RW rwmailli...@googlemail.com wrote: On Tue, 21 Jul 2009 14:18:37 +0300 Giorgos Keramidas keram...@ceid.upatras.gr wrote: There's a catch here that may go unnoticed for a while... rc.conf may be sourced by /etc/rc *long* before filesystems are mounted. As a result grep or awk may be not be available and stop rc.conf from loading. rc.conf is sourced for each rcng script Yes, I should have avoided 'may' as it sounds hypothetical. Every rcng script sources rc.conf :) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
backticks in rc.conf
can i use backticks in rc.conf? Basically i want a standard rc.conf and want to bind rsync to a specific ip hence i want this in my rc.conf rsyncd_flags=--config=/etc/rsyncd.conf --address=` ifconfig bce1 | grep inet | awk '{print $2}'` it works fine from the shell, however on reboot the address section doesnt expand, or rather it goes blank eg Jul 20 16:56:37 X root: /etc/rc: DEBUG: run_rc_command: doit: /usr/local/bin/rsync --config=/etc/rsyncd.conf --address= --daemon ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: backticks in rc.conf
On Tue, 21 Jul 2009 09:46:47 +0100, chris scott kra...@googlemail.com wrote: can i use backticks in rc.conf? Basically, yes. The /etc/rc.conf file is run through sh, it is a shell script that assigns values to variables, but can (ab)use it to execute programs. rsyncd_flags=--config=/etc/rsyncd.conf --address=` ifconfig bce1 | grep inet | awk '{print $2}'` it works fine from the shell, however on reboot the address section doesnt expand, or rather it goes blank You should use the full pathnames leading to ifconfig, grep, and awk. Make sure they are accessible when rc.conf is executed. -- Polytropon From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: backticks in rc.conf
On Tue, 21 Jul 2009 11:29:20 +0200, Polytropon free...@edvax.de wrote: On Tue, 21 Jul 2009 09:46:47 +0100, chris scott kra...@googlemail.com wrote: can i use backticks in rc.conf? Basically, yes. The /etc/rc.conf file is run through sh, it is a shell script that assigns values to variables, but can (ab)use it to execute programs. rsyncd_flags=--config=/etc/rsyncd.conf --address=` ifconfig bce1 | grep inet | awk '{print $2}'` it works fine from the shell, however on reboot the address section doesnt expand, or rather it goes blank You should use the full pathnames leading to ifconfig, grep, and awk. Make sure they are accessible when rc.conf is executed. There's a catch here that may go unnoticed for a while... rc.conf may be sourced by /etc/rc *long* before filesystems are mounted. As a result grep or awk may be not be available and stop rc.conf from loading. It's probably a good idea to: * Add a special rsyncd_bind_address variable that is handled in `/usr/local/etc/rc.d/rsyncd' itself * Permit AUTO as the value of ${rsyncd_bind_address} and do the smart thing there. * Edit `/usr/local/etc/rc.d/rsyncd' to add a dependency for the NETWORKING and FILESYSTEMS special names, so that `rc.d/rsyncd' runs only after networking is up and /usr or other late-mounted filesystems have finished loading. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: backticks in rc.conf
2009/7/21 Giorgos Keramidas keram...@ceid.upatras.gr On Tue, 21 Jul 2009 11:29:20 +0200, Polytropon free...@edvax.de wrote: On Tue, 21 Jul 2009 09:46:47 +0100, chris scott kra...@googlemail.com wrote: can i use backticks in rc.conf? Basically, yes. The /etc/rc.conf file is run through sh, it is a shell script that assigns values to variables, but can (ab)use it to execute programs. rsyncd_flags=--config=/etc/rsyncd.conf --address=` ifconfig bce1 | grep inet | awk '{print $2}'` it works fine from the shell, however on reboot the address section doesnt expand, or rather it goes blank You should use the full pathnames leading to ifconfig, grep, and awk. Make sure they are accessible when rc.conf is executed. There's a catch here that may go unnoticed for a while... rc.conf may be sourced by /etc/rc *long* before filesystems are mounted. As a result grep or awk may be not be available and stop rc.conf from loading. It's probably a good idea to: * Add a special rsyncd_bind_address variable that is handled in `/usr/local/etc/rc.d/rsyncd' itself * Permit AUTO as the value of ${rsyncd_bind_address} and do the smart thing there. * Edit `/usr/local/etc/rc.d/rsyncd' to add a dependency for the NETWORKING and FILESYSTEMS special names, so that `rc.d/rsyncd' runs only after networking is up and /usr or other late-mounted filesystems have finished loading. thanks for the advice but I've found a solution (see below). My systems dont generally have a /usr slice as i like to keep all the os in one place, having a slice for /usr/local. /var, /home, and /tmp so the late fs isnt an issue for me. My latest test builds are pure zfs so wont be an issue there either 8) a=`echo $ifconfig_bge0 | /usr/bin/awk '{ for ( i=1 ; i = NF; i++) { if ( $i ~ /[iI][nN][eE][tT]/ ) { sub(/\/.*/,, $(i+1)); print $(i+1) } } }'` rsyncd_flags=--config=/etc/rsyncd.conf --address=$a ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: backticks in rc.conf
On Tue, 21 Jul 2009 12:24:09 +0100, chris scott kra...@googlemail.com wrote: a=`echo $ifconfig_bge0 | /usr/bin/awk '{ for ( i=1 ; i = NF; i++) { if ( $i ~ /[iI][nN][eE][tT]/ ) { sub(/\/.*/,, $(i+1)); print $(i+1) } } }'` rsyncd_flags=--config=/etc/rsyncd.conf --address=$a This is far too complex for my taste. If you are certain that you will have all the tools around (/usr /usr/local and so on), then it may be simpler to use something like: addr=$( ifconfig lagg0 | perl -ne 'print $1\n if (m/^.*inet\s+(\S+)\s.*$/);' ) This seems to work without all the looping/sub in awk: $ ifconfig lagg0 | perl -ne 'print $1\n if (m/^.*inet\s+(\S+)\s.*$/);' 192.168.1.3 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: backticks in rc.conf
On Tue, 21 Jul 2009 14:18:37 +0300 Giorgos Keramidas keram...@ceid.upatras.gr wrote: There's a catch here that may go unnoticed for a while... rc.conf may be sourced by /etc/rc *long* before filesystems are mounted. As a result grep or awk may be not be available and stop rc.conf from loading. rc.conf is sourced for each rcng script ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org
Re: backticks in rc.conf
On Tue, Jul 21, 2009 at 12:24:09PM +0100, chris scott wrote: 2009/7/21 Giorgos Keramidas keram...@ceid.upatras.gr On Tue, 21 Jul 2009 11:29:20 +0200, Polytropon free...@edvax.de wrote: On Tue, 21 Jul 2009 09:46:47 +0100, chris scott kra...@googlemail.com wrote: can i use backticks in rc.conf? Basically, yes. The /etc/rc.conf file is run through sh, it is a shell script that assigns values to variables, but can (ab)use it to execute programs. rsyncd_flags=--config=/etc/rsyncd.conf --address=` ifconfig bce1 | grep inet | awk '{print $2}'` it works fine from the shell, however on reboot the address section doesnt expand, or rather it goes blank You should use the full pathnames leading to ifconfig, grep, and awk. Make sure they are accessible when rc.conf is executed. There's a catch here that may go unnoticed for a while... rc.conf may be sourced by /etc/rc *long* before filesystems are mounted. As a result grep or awk may be not be available and stop rc.conf from loading. It's probably a good idea to: * Add a special rsyncd_bind_address variable that is handled in `/usr/local/etc/rc.d/rsyncd' itself * Permit AUTO as the value of ${rsyncd_bind_address} and do the smart thing there. * Edit `/usr/local/etc/rc.d/rsyncd' to add a dependency for the NETWORKING and FILESYSTEMS special names, so that `rc.d/rsyncd' runs only after networking is up and /usr or other late-mounted filesystems have finished loading. thanks for the advice but I've found a solution (see below). My systems dont generally have a /usr slice as i like to keep all the os in one place, having a slice for /usr/local. /var, /home, and /tmp so the late fs isnt an issue for me. Probably you mean a /usr partition - which is a division of a slice. Generally, since there are only 4 slices available, they are not used to divide the disk for mountable file systems, but rather are used for major divisions such as if you have more than one OS sharing the disk. The the FreeBSD slice can be further divided into partitions. Note, that confusion occurs here often as MS uses the terminology differently. The primary divisions that FreeBSD calls slices, they call primary partitions. jerry My latest test builds are pure zfs so wont be an issue there either 8) a=`echo $ifconfig_bge0 | /usr/bin/awk '{ for ( i=1 ; i = NF; i++) { if ( $i ~ /[iI][nN][eE][tT]/ ) { sub(/\/.*/,, $(i+1)); print $(i+1) } } }'` rsyncd_flags=--config=/etc/rsyncd.conf --address=$a ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org