-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_functions.Linux.system
44 lines (42 loc) · 1.54 KB
/
.bash_functions.Linux.system
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# vim: ft=bash noet:
! declare 2>&1 | grep -wq ^colors= && [ $BASH_VERSINFO -ge 4 ] && source $initDir/.colors
test "$debug" -gt 0 && echo "=> Running $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal ..."
if groups 2>/dev/null | egrep -wq "sudo|adm|admin|root|wheel";then
# You must call these functions wia the "Sudo" function
function nmRestart {
local -r systemType=$( ( strings $(\ps -p 1 -o command= | cut -d" " -f1) | \egrep -o "upstart|sysvinit|systemd|launchd" || echo unknown ) | head -1)
local -r timer=12s
local output=""
local outputDataType=""
if ! env | \grep ^SSH_CONNECTION= -q; then
if [ $systemType = systemd ]; then
systemctl --no-block restart network-manager
sleep 0.75s
systemctl --no-pager status network-manager
else
if [ $systemType = upstart ] || [ $systemType = sysvinit ]; then
service network-manager restart
fi
fi
echo "=> Waiting $timer for Wi-Fi to connect back again ..."
sleep $timer
printf "=> WANIP: "
output="$(\curl -sA "" ipinfo.io/ip 2>/dev/null || \wget -qU "" -O- ipinfo.io/ip)"
outputDataType=$(echo "$output" | file -bi -)
case $outputDataType in
text/html*) echo "$output" | html2text;;
application/json*) echo "$output" | jq .;;
text/plain*) echo "$output";;
*) echo "Unknown data type." >&2; return 1 ;;
esac
echo
fi
}
function partedListALLDisks {
for disk in $(\ls /dev/sd{a..z} /dev/mmcblk{0..9} 2>/dev/null);do
parted $disk print "$@"
done
}
fi
set +x
test "$debug" -gt 0 && echo "=> END of $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal"