Date: Wed, 8 Nov 2017 04:49:14 +1100 (EST) From: Ian Smith <smithi@nimnet.asn.au> To: Ernie Luzar <luzar722@gmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: Need help with rc.d script Message-ID: <20171108043726.N72828@sola.nimnet.asn.au> In-Reply-To: <20171108021900.W9710@sola.nimnet.asn.au> References: <mailman.444.1510052978.1530.freebsd-questions@freebsd.org> <20171108021900.W9710@sola.nimnet.asn.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 8 Nov 2017 02:38:54 +1100, Ian Smith wrote: > > # This is the continuous loop checking the current ip address to > > # to determin if it changed. > > while [ 1 ]; do > > More portable (for any shell) is 'while true; do' .. > > > # Get the IP address assigned to that NIC device name. > > nic_ip="$(ifconfig $nic_devicename inet | \ > > grep -o "inet.*" | cut -d ' ' -f 2)" More problematic and unnecessary double quotes I missed before .. > > #echo "nic_ip2 = ${nic_ip}" > > > > if [ "${prev_ip}" != "${nic_ip}" ]; then > > # Update dynamic DNS hosting site with new ip address. > > website="https://dynamicdns.park-your-domain.com/update?" > > dyn_host="host=home-fbsd&domain=host.xxxxxxx.com" > > password="&password=a3e0ffc2274746b29ceaf126d59e51c1" > > url="$website$dyn_host$password" > > #echo "$url" > > /usr/local/bin/wget -O /var/log/namecheap.dynip.update.log -q "$url" > > #echo "rtn-code = $?" > > if [ $? -ne 0 ]; then > > echo "Error: /usr/local/bin/wget command failed." > > exit 3 > > fi > > #echo "${nic_ip}" > ${prev_ip_file} > > prev_ip="${nic_ip}" > > fi > > sleep ${elapse_time} > > done > > You do NOT need to use daemon, all you need to do is replace done with > > done & > > and perhaps test to be clear that's working, > > echo "dynip script done" > exit 0 > > So that the script and so run_rc_command will complete, leaving the > "while .. done &" subshell running in background. On second thoughts, 'while .. done' in this particular context might not run in a subshell. If the above method doesn't work, force that section to run in a specific subshell in background, like so: ( while true; do [..] done ) & echo that worked exit 0 cheers, Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20171108043726.N72828>