Improve internet detection

Registered by YannUbuntu

Boot-Repair needs internet for various operations (install packages, purge and reinstall packages, pastebin).
This requires a reliable method to test if internet is available or not. It should work whatever the user configuration (wifi / routeur / IPv4 /v6 ...), and if possible with quick answer (to avoid latency in the UI).

Currently B-R determines if the user is connected to internet or not via the following way:
if [[ $(ping -c 1 www.ubuntu.com | grep "1 received") ]];then INTERNET="connected";else INTERNET="no connection";fi

This is slow and may not work if the user is behind a company/university router.

This should be improved.

Blueprint information

Status:
Complete
Approver:
None
Priority:
Medium
Drafter:
YannUbuntu
Direction:
Approved
Assignee:
fefux
Definition:
Approved
Series goal:
None
Implementation:
Implemented
Milestone target:
None
Started by
YannUbuntu
Completed by
YannUbuntu

Whiteboard

Short-term: solution that works fast, and with routers
( http://forum.ubuntu-fr.org/viewtopic.php?pid=7405701#p7405701 )

Medium-term: 2nd solution that downloads required packages (increases reliability of the "Purge" function):
NEEDEDPACKAGES="grub-pc grub-common grub-gfxpayload-lists";TMPFOLDER=$(mktemp -t --directory boot-repair.XXXX); cd $TMPFOLDER; a=$(sudo apt-get download $NEEDEDPACKAGES); b="$?"; echo "b=$b" ; c=$(sudo mv -f $TMPFOLDER/*.deb /var/cache/apt/archives/); d="$?"; echo "d=$d"; if [[ "$b" = "0" ]] && [[ "$d" = "0" ]];then sudo apt-get --yes --reinstall --download-only install $NEEDEDPACKAGES;echo "DEB install possible"; else echo "DEB download not possible (maybe no internet)";fi
( https://bugs.launchpad.net/boot-repair/+bug/902751 )
This 2nd idea will be developped in this other blueprint: https://blueprints.launchpad.net/boot-repair/+spec/more-securities-before-purge

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.