1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Usage:
|
4 | # soil/diagnose.sh <function name>
|
5 |
|
6 | : ${LIB_OSH=stdlib/osh}
|
7 | source $LIB_OSH/bash-strict.sh
|
8 | source $LIB_OSH/task-five.sh
|
9 |
|
10 | source soil/common.sh # dump-env
|
11 |
|
12 | dump-timezone() {
|
13 |
|
14 | # On Travis:
|
15 | # /usr/share/zoneinfo/UTC
|
16 | # On my machine
|
17 | # /usr/share/zoneinfo/America/Los_Angeles
|
18 |
|
19 | if command -v file; then
|
20 | file '/etc/localtime'
|
21 | fi
|
22 | echo
|
23 | read md5 _ <<< $(md5sum /etc/localtime)
|
24 | log "md5 = $md5"
|
25 | find /usr/share/zoneinfo -type f | xargs md5sum | grep $md5
|
26 | echo
|
27 | }
|
28 |
|
29 | dump-versions() {
|
30 | set +o errexit
|
31 |
|
32 | source build/dev-shell.sh # python3 may be here
|
33 |
|
34 | set -x
|
35 | which python2
|
36 | python2 -V
|
37 |
|
38 | which python3
|
39 | python3 -V
|
40 | set +x
|
41 | }
|
42 |
|
43 | dump-locale() {
|
44 | set -x
|
45 | # show our locale
|
46 | locale
|
47 |
|
48 | # show all locales
|
49 | locale -a
|
50 | set +x
|
51 | }
|
52 |
|
53 | dump-hardware() {
|
54 | egrep '^(processor|model name)' /proc/cpuinfo
|
55 | echo
|
56 |
|
57 | egrep '^Mem' /proc/meminfo
|
58 | echo
|
59 |
|
60 | df -h
|
61 | echo
|
62 | }
|
63 |
|
64 | dump-distro() {
|
65 | local path=/etc/os-release
|
66 | if test -f $path; then
|
67 | cat $path
|
68 | else
|
69 | echo "$path doesn't exist"
|
70 | fi
|
71 | echo
|
72 |
|
73 | if command -v apt-cache > /dev/null; then
|
74 | apt-cache policy r-base-core
|
75 | fi
|
76 | }
|
77 |
|
78 | dump-user-host() {
|
79 | echo -n 'whoami = '
|
80 | whoami
|
81 | echo
|
82 |
|
83 | echo "PWD = $PWD"
|
84 | echo
|
85 |
|
86 | if command -v hostname > /dev/null; then
|
87 | echo -n 'hostname = '
|
88 | hostname
|
89 | else
|
90 | # Fedora
|
91 | echo 'hostname command missing'
|
92 | fi
|
93 | echo
|
94 |
|
95 | uname -a
|
96 | echo
|
97 |
|
98 | who
|
99 | echo
|
100 | }
|
101 |
|
102 | dump-tty() {
|
103 | echo TTY
|
104 | tty || true
|
105 | }
|
106 |
|
107 | os-info() {
|
108 | dump-user-host
|
109 | echo
|
110 |
|
111 | dump-tty
|
112 | echo
|
113 |
|
114 | dump-distro
|
115 | echo
|
116 |
|
117 | dump-versions
|
118 | echo
|
119 |
|
120 | dump-locale
|
121 | echo
|
122 |
|
123 | dump-timezone
|
124 | echo
|
125 |
|
126 | dump-hardware
|
127 | echo
|
128 |
|
129 | # Process limits
|
130 | echo 'Soft limits:'
|
131 | ulimit -S -a
|
132 | echo
|
133 | echo 'Hard limits:'
|
134 | ulimit -H -a
|
135 | echo
|
136 | }
|
137 |
|
138 | task-five "$@"
|
139 |
|