File: hwinfo2_fetch_sysdata

package info (click to toggle)
hardinfo 2.2.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,040 kB
  • sloc: ansic: 40,169; cpp: 1,216; sh: 340; xml: 81; python: 50; makefile: 3
file content (54 lines) | stat: -rwxr-xr-x 2,236 bytes parent folder | download | duplicates (2)
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/sh

#create group hardinfo2 if not exists
if ! awk -F: '$1 == "hardinfo2" { found = 1 } END { exit !found }' /etc/group; then
    groupadd hardinfo2 2>/dev/null
    addgroup hardinfo2 2>/dev/null
fi

#Create runtime data directory
mkdir /run/hardinfo2 2>/dev/null
chmod 750 /run/hardinfo2

#----Allow users in hardinfo2 group to get these hardware info----
#iomem and ioport address - no need to show system/kernel addresses.
cat /proc/iomem |grep -v Kernel|grep -v System >/run/hardinfo2/iomem 2>/dev/null
cat /proc/ioports >/run/hardinfo2/ioports 2>/dev/null

#DMI memory array and DIMM memory information
dmidecode -t 16 >/run/hardinfo2/dmi_memarray 2>/dev/null
dmidecode -t 17 >/run/hardinfo2/dmi_memory 2>/dev/null

#Allow for single user systems to use user group (To avoid reboot)
UID_MIN=1000
if [ -e /etc/login.defs ] ; then
    UID_MIN=$(awk 'match($1,"^UID_MIN") {print $2}' /etc/login.defs)
fi
#SYSTYPE 0:Root, 1:SingleUser 2:MultiUser
SYSTYPE=$(awk -F: -v UID_MIN=$UID_MIN '$3 >= UID_MIN && !match($7,"false") && !match($7,"nologin") && !match($1,"nobody") { C++; } END { if(C+0 == 0) print 0; else if(C+0 == 1) print 1; else print 2 }' /etc/passwd)
#Find User ID, User Name, Group Name
UIDNO=$(awk -F: -v UID_MIN=$UID_MIN '$3 >= UID_MIN && !match($7,"false") && !match($7,"nologin") && !match($1,"nobody") { print $3;exit; }' /etc/passwd)
GIDNO=$(awk -F: -v UID_MIN=$UID_MIN '$3 >= UID_MIN && !match($7,"false") && !match($7,"nologin") && !match($1,"nobody") { print $4;exit; }' /etc/passwd)
UIDNAME=$(awk -F: -v UIDNO=$UIDNO '$3 == UIDNO { print $1 }' /etc/passwd)
GIDNAME=$(awk -F: -v GIDNO=$GIDNO '$3 == GIDNO { print $1 }' /etc/group)
if [ $SYSTYPE = "1" ] && [ ! -z "${UIDNAME}" ] && [ $GIDNAME = $UIDNAME ]; then
    echo "Single User System" >/run/hardinfo2/systype
    #set owner to single user group
    chown -R root:$GIDNAME /run/hardinfo2
else
    if [ $SYSTYPE = "0" ]; then
	echo "Root Only System" >/run/hardinfo2/systype
    else
	echo "Multi User System" >/run/hardinfo2/systype
    fi
    #set owner to hardinfo2 (multiuser)
    chown -R root:hardinfo2 /run/hardinfo2
fi
#set rights
chmod 640 /run/hardinfo2/*


#loading SPD modules
modprobe -q spd5118
modprobe -q ee1004
modprobe -q at24 || true