forked from armbian/build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
83 lines (66 loc) · 2.11 KB
/
bashrc
File metadata and controls
83 lines (66 loc) · 2.11 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
if [ ${TERM} == "dumb" ]; then
return
fi
export TERM=linux
OUT=""
LOAD=$(w | sed -n 1p | awk '{print $(NF-2), $(NF-1),$(NF-0)}')
OUT="${OUT}Load: ${LOAD} "
## getting temperature from USB termometer
## http://www.dx.com/p/81105
##
if which temper >/dev/null; then
TEMPER=$(temper -c)
if echo $TEMPER | egrep -qv "Couldn't find the USB device"; then
TEMPER=$(echo "scale=1;${TEMPER}/1" | bc)
TEMPER="- Ambient: ${TEMPER}"
else
TEMPER=""
fi
fi
CEL=$(awk 'BEGIN { print "\302\260C"; }')
if [ -d "/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/" ]; then
TEMP=$(cat /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input)
TEMP=$(echo "scale=1;${TEMP}/1000" | bc)
fi
# if we are reading A20 temp with daemon
if [ -f "/run/soc-temp" ]; then
TEMP=$(cat /run/soc-temp)
fi
# if we are reading from A20
if [ -d "/sys/devices/platform/a20-tp-hwmon/" ]; then
TEMP=$(cat /sys/devices/platform/a20-tp-hwmon/temp1_input)
TEMP=$(echo "scale=1;${TEMP}/1000" | bc)
fi
# if we are reading from A20 on newer kernel
if [ -d "/sys/devices/virtual/thermal/thermal_zone0/" ]; then
TEMP=$(cat /sys/devices/virtual/thermal/thermal_zone0/temp)
TEMP=$(echo "scale=1;${TEMP}/1000" | bc)
fi
OUT="${OUT}- Board: ${TEMP}${CEL} "
if [[ -n $TEMPER ]]; then
OUT=$OUT"${TEMPER}${CEL} "
fi
if [ "$(cat /proc/partitions |grep sd)" != "" ];then
SDA_TYPE=$(/sbin/udevadm info --query=all --name=sda | grep ID_BUS=)
SDA_TYPE=${SDA_TYPE#*=}
fi
# if we have a hard drive
if [[ -e '/dev/sda' && $SDA_TYPE == "ata" ]] ; then
HDDTEMP=$(/usr/sbin/hddtemp /dev/sda 2>&1)
if [ $? -eq 0 ]; then
HDDTEMP=$(echo ${HDDTEMP} | awk '{print $NF}')
HDDFREE=$(df -h /dev/sda1 | grep sda | awk '{ print " / " $(NF-2)}')
if [ "${HDDFREE}" != "" ]; then
HDDFREE="${HDDFREE}"b
fi
OUT="${OUT}- Drive: ${HDDTEMP}${HDDFREE} "
fi
fi
MEMFREE=$(free | sed -n 2p | awk '{print $(NF-3)}')
MEMBUFFERS=$(free | sed -n 2p | awk '{print $(NF-1)}')
MEMCACHED=$(free | sed -n 2p | awk '{print $(NF)}')
MEM=$(echo "(${MEMFREE}+${MEMBUFFERS}+${MEMCACHED})/1024" | bc)
OUT="${OUT}- Memory: ${MEM}Mb"
echo ""
echo ${OUT}
echo ""