File: linuxcnc_info.in

package info (click to toggle)
linuxcnc 1%3A2.9.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 285,604 kB
  • sloc: python: 202,568; ansic: 109,036; cpp: 99,239; tcl: 16,054; xml: 10,631; sh: 10,303; makefile: 1,255; javascript: 138; sql: 72; asm: 15
file content (174 lines) | stat: -rwxr-xr-x 4,437 bytes parent folder | download | duplicates (3)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash

# This script creates a file in /tmp and
# opens it with first visual editor found in a search list for editors

# Copyright: 2014
# Author:    Dewey Garrett <dgarrett@panix.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

ofile=/tmp/linuxcnc_info.txt
PROG=$(basename $0)

usage () {
  cat <<EOF
$PROG creates file $ofile
USAGE:
  $PROG [options]
  options:
    -s  silent (suppress automatic opening of file)
    -h  help
EOF
exit 1
}

git_commit () {
  dir=$(dirname $0)
  if [ "${dir}" = "/usr/bin" ] ; then
    echo NA
  else
    echo $(cd $dir; git rev-parse --short HEAD 2>/dev/null)
  fi
}

# try to find a visual editor to show created file
# use list with existing preference first, then other common editors
editors="$VISUAL gedit mousepad geany nedit nano gvim abiword"
VIEWER=""
for e in $editors ; do
  if [  -x "$(command -v $e)" ] ; then
    VIEWER=$e
    break #use first editor found
  fi
done

while getopts hs OPT; do
  case $OPT in
    s) VIEWER="";;
    h) usage;;
    *) usage;;
  esac
done

[ -z "$VIEWER" ] && echo "No VIEWER: output to $ofile"

# all subsequent output:
exec 1>$ofile
exec 2>&1

function show () {
  if [ -z "$1" ] ; then
    echo
    return
  fi
  name=$1
  shift
  value=$*
  printf "%20s: %s\n" "$name" "$value"
}

function parse_cpuinfo () {
  cat /proc/cpuinfo|grep "$1"|head -1|cut -d: -f2-
}

function parse_after_colon () {
  echo "$*"|cut -d: -f2-
}

function tryversion () {
  prog="$1"
  if [ $(command -v "$prog") ] ; then
     ans=$($prog --version 2>/dev/null)
     if [ -z "$ans" ] ; then
       echo "?"
     else
       echo "$ans"
     fi
  else
     echo "not_in_PATH"
  fi
}

cat <<EOF
The file:    $ofile
can be posted to a forum or a web site like:
     http://pastebin.com
in order to provide information about the linuxcnc
system and configuration.

EOF

[ -n "$VIEWER" ] && echo VIEWER=$VIEWER

show "            Date" $(date)
show "        UTC Date" $(date -u)
show "    this program" $0
show "          uptime" $(uptime)
show " lsb_release -sa" $(lsb_release -sa 2>/dev/null)
show "        linuxcnc" $(command -v linuxcnc)
show "             pwd" $(pwd -P)
show "            USER" $USER
show "         LOGNAME" $LOGNAME
show "            HOME" $HOME
show "          EDITOR" $EDITOR
show "          VISUAL" $VISUAL
show "        LANGUAGE" $LANGUAGE
show "            TERM" $TERM
show "       COLORTERM" $COLORTERM
show "         DISPLAY" $DISPLAY
show "         DESKTOP" $DESKTOP_SESSION
show "    display size" $(parse_after_colon $(xdpyinfo|grep dimensions))
show "            PATH" $PATH
echo
echo "uname items:"
show "     nodename -n" $(uname -n)
show "  kernel-name -s" $(uname -s)
show "  kernel-vers -v" $(uname -v)
show "      machine -m" $(uname -m)
show "    processor -p" $(uname -p)
show "     platform -i" $(uname -i)
show "  oper system -o" $(uname -o)
show ""
echo "/proc items:"
show "         cmdline" $(< /proc/cmdline)
show "      model name" $(parse_cpuinfo "model name")
show "           cores" $(parse_cpuinfo "cpu cores")
show "         cpu MHz" $(parse_cpuinfo "cpu MHz")
show "         parport" $(cat /proc/ioports|grep parport)
show "          serial" $(cat /proc/ioports|grep serial)
echo
echo "Versions:"
show "             gcc" $(gcc --version|head -1)
show "          python" $(@PYTHON@ --version 2>&1)
show "             git" $(tryversion git)
show "      git commit" $(git_commit)
show "             tcl" $(echo "puts $::tcl_version"|tclsh)
show "              tk" $(echo "puts $::tk_version;destroy ."|wish)
show "           glade" $(tryversion glade)
echo
echo "linuxcnc_var all:"
echo
for n in $(linuxcnc_var all) ; do
   show "${n%%=*}" ${n##*=}
done

echo
echo "dpkg -l '*linuxcnc*':"
dpkg -l '*linuxcnc*'
echo

[ -n "$VIEWER" ] && $VIEWER "$ofile"
exit 0