Tiny Core Base > TCB Tips & Tricks
How to find which extension provides a file
Rich:
Hi polikuo
--- Quote from: polikuo on November 19, 2024, 01:30:16 AM ---Here's a loophole that I missed ...
--- End quote ---
Looks like you plugged it, well done.
Rich:
Hi GNUser
--- Quote from: GNUser on November 19, 2024, 09:38:48 AM ---Hi Rich. I love your improvements to provides.sh. Thank you. I always thought that script could be easier to use. ...
--- End quote ---
That was the plan:
Use a / to mark the beginning of the search term if desired.
Type in your search term.
Use a $ sign to mark the end of the search term if desired.
Hit enter.
--- Quote --- ... I'd say if provides.db is older than 24 hours and there is a network connection, to go ahead and automatically update provides.db. ...
--- End quote ---
I guess we could add something like this to the beginning of UpdateProvidesDB():
--- Code: ---ping -W 1 -c 1 8.8.8.8 2>&1 > /dev/null || return 1
--- End code ---
It doesn't check DNS, but it's fast and will stop you from trying to access
the Internet if there is no connectivity.
--- Quote --- ... Maybe provide a switch if user wants to update provides.db regardless of its age? ...
--- End quote ---
Instead of a command line switch, an environmental variable to override the
value used for -mmin in the find command would work, for example:
Never update:
--- Code: ---PROVIDESUPDATE=-0
--- End code ---
Update ASAP, file is older than 1 minute:
--- Code: ---PROVIDESUPDATE=+0
--- End code ---
Update if older than 24 hours:
--- Code: ---PROVIDESUPDATE=+1440
--- End code ---
--- Quote --- ... It would be nice for no arguments to cause help to be printed, but I understand your reason for not doing that. The -h and --help are working as expected.
--- End quote ---
I also include -help as an option. :P
GNUser:
--- Quote from: Rich on November 19, 2024, 01:51:25 PM ---I guess we could add something like this to the beginning of UpdateProvidesDB():
--- Code: ---ping -W 1 -c 1 8.8.8.8 2>&1 > /dev/null || return 1
--- End code ---
--- End quote ---
Why not go with Robert's approach (which shows up in tc-config and settime.sh ):
--- Code: ---ifconfig | grep -q Bcast || return 1
--- End code ---
This way there are no hardcoded ip addresses, no calls to Google, no danger of breakage if firewall blocks icmp traffic. Plus, if Busybox's ifconfig someday changes Bcast to some other string, tc-config, settime.sh, and provides.sh would all need an identical repair.
I really like the PROVIDESUPDATE environmental variable approach. Great idea!
Rich:
Hi GNUser
--- Quote from: GNUser on November 19, 2024, 07:19:20 PM --- ... Why not go with Robert's approach (which shows up in tc-config and settime.sh ):
--- Code: ---ifconfig | grep -q Bcast || return 1
--- End code ---
...
--- End quote ---
Funny you should mention it. That will detect the NIC was brought up.
It will not detect an unplugged network cable or problems upstream.
Oh, and watch this:
--- Code: ---tc@box:~$ ifconfig eth0 | grep Bcast
inet addr:192.168.1.45 Bcast:192.168.1.255 Mask:255.255.255.0
tc@box:~$ sudo ifconfig eth0 down
tc@box:~$ ifconfig eth0 | grep Bcast
inet addr:192.168.1.45 Bcast:192.168.1.255 Mask:255.255.255.0
tc@box:~$
--- End code ---
I also considered using this:
--- Code: ---ifconfig eth0 | grep RUNNING
--- End code ---
That will detect taking down the NIC and unplugging the network cable.
While it detects a disconnect between computer and network switch, it
won't detect a disconnect between network switch and router.
GNUser:
Hi Rich. Scratch the Bcast idea, then.
I also thought of this:
--- Code: ---getMirror
DOMAIN="$(echo "$MIRROR" | busybox awk -F[/:] '{print $4}')"
nslookup "$DOMAIN" >/dev/null 2>&1 || return 1
--- End code ---
However, maybe it's best not to test connectivity. If provides.db meets age criteria for updating, I think provides.sh should just go ahead and try to update it (with a reasonable timeout so that user isn't waiting forever if there is no network connectivity). If a failed connectivity check takes as long as a failed update attempt, the connectivity check does not seem to add any value.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version