-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysinfo.sh
executable file
·54 lines (48 loc) · 1.71 KB
/
sysinfo.sh
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
#! /bin/bash
# #################################################################################
#
# Indoor system script
# get basic system info: date, RPi S/N, network settings
#
# #################################################################################
SERIAL=`cat /proc/cpuinfo | grep -i '^serial' | grep -Eo '[a-fA-F0-9]{16}$'`
DAT=$(date "+%Y-%m-%d")
IP_ADDR=`hostname -I`
#INET=`cat /etc/network/interfaces | grep "eth0 inet" | awk '{print $4}'`
IFC_TEMP=`ifconfig eth0 | grep "inet addr"`
NETMASK=`echo $IFC_TEMP | awk '{print $4}' | sed 's/Mask://'`
BROADCAST=`echo $IFC_TEMP | awk '{print $3}' | sed 's/Bcast://'`
#NETMASK=`ifconfig eth0 | grep "inet addr" | awk '{print $4}' | sed 's/Mask://'`
#BROADCAST=`ifconfig eth0 | grep "inet addr" | awk '{print $3}' | sed 's/Bcast://'`
NETWORK=`netstat -rn | grep eth0 | awk '{if($1!="0.0.0.0") print $1}'`
GATEWAY=`netstat -rn | grep eth0 | awk '{if($1=="0.0.0.0") print $2}'`
#NS_TEMP=`netstat -rn | grep eth0`
#GATEWAY=`echo $NS_TEMP | awk '{if($1=="0.0.0.0") print $2}'`
#NETWORK=`echo $NS_TEMP | awk '{if($1!="0.0.0.0") print $1}'`
DNS=`cat /etc/resolv.conf | grep nameserver | awk 'NR==1 {print $2}'`
MACADDR=`ifconfig eth0 | grep "HWaddr" | awk '{print $5}' | sed -e 's/:/-/g'`
INET_TMP=`cat /etc/dhcpcd.conf | grep "interface eth0"`
if [ -z "$INET_TMP" ]; then
INET='dhcp'
else
INET='static'
fi
if [ -z $IP_ADDR ]; then
IP_ADDR=127.0.0.1
fi
if [ -z $NETMASK ]; then
NETMASK=0.0.0.0
fi
if [ -z $BROADCAST ]; then
BROADCAST=0.0.0.0
fi
if [ -z $GATEWAY ]; then
GATEWAY=0.0.0.0
fi
if [ -z $NETWORK ]; then
NETWORK=0.0.0.0
fi
if [ -z $DNS ]; then
DNS=0.0.0.0
fi
echo $DAT $SERIAL $INET $IP_ADDR $NETMASK $BROADCAST $GATEWAY $NETWORK $DNS $MACADDR