diff --git a/Makefile b/Makefile index fb49f1c..d102cf5 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,10 @@ DATADIR = /share/manjaro-architect BIN = \ bin/btrfs-subvol-functions \ - bin/check-translate.in \ + bin/check-translate \ bin/ma-launcher \ - bin/manjaro-architect + bin/manjaro-architect \ + bin/nw_check LIBS = \ lib/ini_val.sh \ diff --git a/bin/nw_check.in b/bin/nw_check.in new file mode 100644 index 0000000..69d12f5 --- /dev/null +++ b/bin/nw_check.in @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# +# Architect Installation Framework (2016-2017) +# +# Written by Carl Duff and @mandog for Archlinux +# Heavily modified and re-written by @Chrysostomus to install Manjaro instead +# Contributors: @papajoker, @oberon, and the Manjaro-Community. +# +# This program is free software, provided under the GNU General Public License +# as published by the Free Software Foundation. So feel free to copy, distribute, +# or modify it as you wish. + +"""connectivity check, kindly contributed by @fhdk""" + +import sys +from urllib.request import urlopen + +remote_host = "https://manjaro.org" +maxwait = 2 +data = None +try: + data = urlopen(remote_host, timeout=maxwait) +except: + pass + +if data: + sys.exit(0) +else: + sys.exit(1) diff --git a/bin/setup b/bin/setup index 78f16df..f372e80 100644 --- a/bin/setup +++ b/bin/setup @@ -12,7 +12,7 @@ [[ -e /run/miso/bootmnt ]] && setfont ter-116n -while [[ ! $(ping -c 2 manjaro.org) ]]; do +while ! nw_check; do if [[ $(cat /proc/1/comm) == "systemd" ]];then if [[ $(systemctl is-active NetworkManager) == "active" ]]; then dialog --backtitle ":: Manjaro Architect ::" --yesno "\nPlease connect to the internet:\n" 0 0 && \ diff --git a/lib/util.sh b/lib/util.sh index a2bae3f..3f1a916 100644 --- a/lib/util.sh +++ b/lib/util.sh @@ -341,7 +341,7 @@ set_keymap() { } mk_connection() { - if [[ ! $(ping -c 2 google.com) ]]; then + if ! nw_check; then DIALOG " $_NoCon " --yesno "\n$_EstCon\n " 0 0 && $NW_CMD && return 0 || clear && exit 0 fi } @@ -358,7 +358,7 @@ check_requirements() { exit 1 fi - if [[ ! $(ping -c 1 google.com) ]]; then + if ! nw_check; then DIALOG " $_ErrTitle " --infobox "\n$_ConFailBody\n " 0 0 sleep 2 exit 1