sh: Add internet-check base script
Added script to sh base package to allow checking for internet connectivity. Checks both through system virtual filesystem and, as a fallback, through pinging google dns. Added a simple readme to sh module.
This commit is contained in:
parent
658e07e1b8
commit
3bf5becbe2
3 changed files with 48 additions and 4 deletions
24
sh/.local/bin/check-internet
Executable file
24
sh/.local/bin/check-internet
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
# Check for internet connectivity.
|
||||
# Returns 0 if connectivity exists, 1 if it does not.
|
||||
|
||||
hasconnec=0
|
||||
for intf in /sys/class/net/*; do
|
||||
case $intf in
|
||||
"/sys/class/net/lo") break ;;
|
||||
*)
|
||||
[ "$(cat "$intf/carrier")" = 1 ] && hasconnec=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $hasconnec -ne 1 ]; then
|
||||
ping -q -w 1 -c 1 8.8.8.8 >/dev/null 2>&1 && hasconnec=1
|
||||
fi
|
||||
|
||||
if [ $hasconnec -eq 1 ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
20
sh/README.md
Normal file
20
sh/README.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# sh
|
||||
|
||||
The bare minimum terminal configuration for a working system.
|
||||
Contains:
|
||||
|
||||
* an XDG compliant home directory setup
|
||||
* several basic environment variables
|
||||
* simple aliases
|
||||
* an optional fzf default setup
|
||||
* X autostart
|
||||
|
||||
While other modules are largely optional,
|
||||
this module is the only one strictly necessary for the system to really work at all.
|
||||
|
||||
Additionally contains two scripts on which some other modules build:
|
||||
|
||||
* a simple script to detect if applications exist
|
||||
(and optionally warn the user if they don't)
|
||||
* and a script to check if internet connectivity exists
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue