mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-02 22:03:01 +02:00
board/common: add '-p' (plain output) to help command
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -1,41 +1,72 @@
|
||||
#!/bin/sh
|
||||
H1=$(printf '\033[7m')
|
||||
H2=$(printf '\033[1m')
|
||||
DM=$(printf '\033[2m')
|
||||
UL=$(printf '\033[4m')
|
||||
IT=$(printf '\033[3m')
|
||||
BL=$(printf '\033[5m')
|
||||
H0=$(printf '\033[0m')
|
||||
# COLUMS and ROWS should be set on the console, if not, use fallback
|
||||
if [ -z "$COLUMNS" ]; then
|
||||
if command -v tput; then
|
||||
COLUMNS=$(tput cols)
|
||||
else
|
||||
COLUMNS=80
|
||||
fi
|
||||
fi
|
||||
|
||||
noansi()
|
||||
h1()
|
||||
{
|
||||
H1=""
|
||||
H2=""
|
||||
DM=""
|
||||
UL=""
|
||||
IT=""
|
||||
BL=""
|
||||
H0=""
|
||||
STR="$*"
|
||||
if [ -n "$plain" ]; then
|
||||
echo "$STR" | tr '[:lower:]' '[:upper:]'
|
||||
echo "$STR" | sed 's/./=/g'
|
||||
else
|
||||
printf "\033[7m%-${COLUMNS}s\033[0m" "$STR"
|
||||
fi
|
||||
}
|
||||
|
||||
h2()
|
||||
{
|
||||
STR="$*"
|
||||
if [ -n "$plain" ]; then
|
||||
echo "$STR"
|
||||
echo "$STR" | sed 's/./-/g'
|
||||
else
|
||||
printf "\033[1m%-${COLUMNS}s\033[0m" "$STR"
|
||||
fi
|
||||
}
|
||||
|
||||
ul()
|
||||
{
|
||||
if [ -n "$plain" ]; then
|
||||
echo "__${*}__"
|
||||
else
|
||||
printf "\033[54%s\033[0m" "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
em()
|
||||
{
|
||||
if [ -n "$plain" ]; then
|
||||
echo "**${*}**"
|
||||
else
|
||||
printf "\033[5m%s\033[0m" "$*"
|
||||
fi
|
||||
}
|
||||
|
||||
overview()
|
||||
{
|
||||
cat <<EOF
|
||||
${H1}Help System Press 'Q' to quit | Arrow keys and PgUp/PgDn to scroll ${H0}
|
||||
$(h1 "Help System Press 'Q' to quit | Arrow keys and PgUp/PgDn to scroll")
|
||||
|
||||
${H2}See Also${H0}
|
||||
$(h2 "See Also")
|
||||
help edit Tutorial on VI and Mg editors
|
||||
help net Network set up introduction
|
||||
setup User friendly setup and diagnostic tool
|
||||
|
||||
${H2}General Syntax${H0}
|
||||
$(h2 "General Syntax")
|
||||
cmd [optional arg] E.g., use 'date -h' to get help for date command
|
||||
|
||||
${H2}File system${H0}
|
||||
$(h2 "File system")
|
||||
pwd | ls | cd Show directory, contents, or change directory
|
||||
cat file Show file contents
|
||||
vi | mg [file] Edit file with the VI or Micro Emacs editor
|
||||
|
||||
${H2}Services${H0}
|
||||
$(h2 "Services")
|
||||
initctl list Lists all configurable services (svc's)
|
||||
initctl enable svc Enable a service 'svc'
|
||||
initctl reload Reload init process' state, start/stop svc's
|
||||
@@ -44,7 +75,8 @@ ${H2}Services${H0}
|
||||
initctl restart svc Restart a running 'svc'
|
||||
initctl status [svc] Display running status of all services, or one 'svc'
|
||||
|
||||
${H2}Tools${H0}
|
||||
$(h2 "Tools")
|
||||
setup User friendly setup and diagnostic tool
|
||||
date [-h] Display current time, or sets the system date
|
||||
factory Factory reset the device (on the next boot)
|
||||
hwclock [-h] Query or set the hardware clock (RTC)
|
||||
@@ -60,7 +92,7 @@ ${H2}Tools${H0}
|
||||
reboot Restart the device
|
||||
reset Reset the shell prompt if it gets garbled
|
||||
|
||||
${H2}Network Tools${H0}
|
||||
$(h2 "Network Tools")
|
||||
ethtool [-h] Ethernet stats, and low-level MAC/PHY settings
|
||||
traceroute [-h] Trace the route ip packets follow going to a host
|
||||
tcpdump [-h] Display network packet headers in real-time
|
||||
@@ -88,46 +120,45 @@ ${H2}Network Tools${H0}
|
||||
ftpget Retrieve a remote file via FTP
|
||||
wget Get a file using HTTP or FTP from a remote host
|
||||
|
||||
${H2}Overview Commands${H0}
|
||||
$(h2 "Overview Commands")
|
||||
df -h List disk usage (in human readable format)
|
||||
free List memory usage
|
||||
ps List running processes
|
||||
show [arg] Show system status, see 'show help' for more info
|
||||
top Displays CPU usage and top list of running tasks
|
||||
|
||||
${H2}Interesting Files${H0}
|
||||
$(h2 "Interesting Files")
|
||||
/etc/default/svc Command line args for service 'svc' (see above)
|
||||
/etc/rc.local Local setup, runs after all services have started
|
||||
/etc/network/ Directory of networking setup, see 'help net'
|
||||
|
||||
${H2}Example Commands${H0}
|
||||
$(h2 "Example Commands")
|
||||
cd /tmp; wget ftp://192.168.55.43/file && cat file
|
||||
cd /var/log; tftp -p -l messages 192.168.55.43
|
||||
cat /proc/net/arp
|
||||
edit /etc/network/interfaces
|
||||
|
||||
${H2}See Also${H0}
|
||||
$(h2 "See Also")
|
||||
help edit Tutorial on VI and Mg editors
|
||||
help net Network set up introduction
|
||||
|
||||
setup User friendly setup and diagnostic tool
|
||||
EOF
|
||||
}
|
||||
|
||||
vi()
|
||||
{
|
||||
cat <<EOF
|
||||
${H1}Visual Editor (vi) ${H0}
|
||||
|
||||
$(h1 "Visual Editor (vi)")
|
||||
Vi is the de facto standard editor in UNIX systems. It comes with two modes:
|
||||
|
||||
- ${H2}Command mode (default):${H0} administrative tasks such as saving files,
|
||||
- $(em "Command mode (default):") administrative tasks such as saving files,
|
||||
executing commands, moving the cursor, cutting and pasting lines or words,
|
||||
as well as finding and replacing. ${UL}Return to command mode with Esc${H0}
|
||||
as well as finding and replacing. $(em "Return to command mode with Esc")
|
||||
|
||||
- ${H2}Insert mode:${H0} Everything that's typed in this mode is interpreted as
|
||||
- $(em "Insert mode:") Everything that's typed in this mode is interpreted as
|
||||
input and placed in the file.
|
||||
|
||||
${H2}Navigation commands${H0}
|
||||
$(h2 "Navigation commands")
|
||||
|
||||
h - move the cursor one character to the left
|
||||
j - move the cursor down one character
|
||||
@@ -140,7 +171,7 @@ ${H2}Navigation commands${H0}
|
||||
:0 - move to beginning of file
|
||||
G - move to end of file
|
||||
|
||||
${H2}Editing commands${H0}
|
||||
$(h2 "Editing commands")
|
||||
|
||||
u - undo last operation
|
||||
x - delete the character the cursor is on
|
||||
@@ -150,7 +181,7 @@ ${H2}Editing commands${H0}
|
||||
p - paste (line, word, or char) after cursor
|
||||
P - paste (line, word, or char) before cursor
|
||||
|
||||
${H2}Saving and quit commands${H0}
|
||||
$(h2 "Saving and quit commands")
|
||||
|
||||
:w - save the current file
|
||||
:w filename - save a copy of the file named filename
|
||||
@@ -164,7 +195,7 @@ ${H2}Saving and quit commands${H0}
|
||||
:q - quit vi
|
||||
:q! - quit vi even if the file has unsaved changes
|
||||
|
||||
${H2}Enter insert mode${H0}
|
||||
$(h2 "Enter insert mode")
|
||||
|
||||
a - append new text after the cursor
|
||||
i - insert text before the cursor
|
||||
@@ -179,12 +210,11 @@ EOF
|
||||
emacs()
|
||||
{
|
||||
cat <<EOF
|
||||
${H1}Micro Emacs (mg) ${H0}
|
||||
|
||||
$(h1 "Micro Emacs (mg)")
|
||||
Mg is a bit more user-friendly than vi. It has the same familiar interface
|
||||
as Notepad, but with slightly different keybindings.
|
||||
|
||||
${H2}Introduction${H0}
|
||||
$(h2 "Introduction")
|
||||
|
||||
Most commands involve using the Control ("Ctrl") or the Meta ("Alt") key.
|
||||
The following conventions are used in the online help:
|
||||
@@ -195,7 +225,7 @@ The following conventions are used in the online help:
|
||||
If you don't have a Meta/Alt key, you can use Esc instead. Press and release
|
||||
the Esc key and then type <chr>. This is equivalent to M-<chr>.
|
||||
|
||||
${H2}Navigation${H0}
|
||||
$(h2 "Navigation")
|
||||
|
||||
Though arrow keys, Home/End, and PgUp/PgDn usually work, using Mg over serial
|
||||
console can sometimes cause these keys to be mismapped by terminal program.
|
||||
@@ -214,7 +244,7 @@ console can sometimes cause these keys to be mismapped by terminal program.
|
||||
M-> Move to end of file
|
||||
C-x g Move to line number
|
||||
|
||||
${H2}Editing${H0}
|
||||
$(h2 "Editing")
|
||||
|
||||
All edit commands that kill (cut) text is placed in a kill ring (clipboard).
|
||||
Note: when marking text, there is no visual mark.
|
||||
@@ -236,7 +266,7 @@ Note: when marking text, there is no visual mark.
|
||||
C-d Delete character to the right
|
||||
C-o Open new line at cursor
|
||||
|
||||
${H2}General Commands${H0}
|
||||
$(h2 "General Commands")
|
||||
|
||||
C-g Abort current command
|
||||
C-l Recenter buffer on current line
|
||||
@@ -252,7 +282,7 @@ ${H2}General Commands${H0}
|
||||
C-x b Switch to another buffer
|
||||
C-x C-c Exit
|
||||
|
||||
${H2}Window Commands${H0}
|
||||
$(h2 "Window Commands")
|
||||
|
||||
C-x 0 Unsplit, keep other window
|
||||
C-x 1 Unsplit, keep this window
|
||||
@@ -278,12 +308,11 @@ editor()
|
||||
vi
|
||||
emacs
|
||||
cat <<EOF
|
||||
${H1}Summary ${H0}
|
||||
|
||||
$(h1 "Summary")
|
||||
Use Mg or GNU Nano if you are a beginner. The system is set up to so you can
|
||||
use the 'edit' command, which will start GNU Nano:
|
||||
|
||||
edit /etc/rc.local # Starts GNU Nano
|
||||
edit /etc/rc.local # Starts GNU Nano
|
||||
|
||||
EOF
|
||||
;;
|
||||
@@ -293,8 +322,7 @@ EOF
|
||||
networking()
|
||||
{
|
||||
cat <<EOF
|
||||
${H1}Networking ${H0}
|
||||
|
||||
$(h1 "Networking")
|
||||
This section details how to set up everything from basic to advanced networking.
|
||||
Topics covered include:
|
||||
|
||||
@@ -310,7 +338,7 @@ reserved for Ethernet links attached to a switch or bridge, while the term
|
||||
'interface' more generically refers to the physical interface in a system.
|
||||
|
||||
|
||||
${H2}Static vs Dynamic Addresses${H0}
|
||||
$(h2 "Static vs Dynamic Addresses")
|
||||
|
||||
An IPv4 address consists of four "octets" separated by periods. A static IPv4
|
||||
address can look like this:
|
||||
@@ -352,7 +380,7 @@ mDNS to discover and access a device you do not know, or do not want to know,
|
||||
the IP address to. See more in the next section.
|
||||
|
||||
|
||||
${H2}DNS and mDNS${H0}
|
||||
$(h2 "DNS and mDNS")
|
||||
|
||||
Managing a central DNS is both painful and time consuming, most networks, and
|
||||
in particular industrial, therefore only set up a DNS for static servers and
|
||||
@@ -400,7 +428,7 @@ Note: there are other mechanisms for device discovery. Microsoft have been
|
||||
their web browsers to https://hostname-01-02-03.local
|
||||
|
||||
|
||||
${H2}VLAN Interfaces${H0}
|
||||
$(h2 "VLAN Interfaces")
|
||||
|
||||
A VLAN interface in Linux is an "upper" interface, e.g., 'eth0.1'. It is
|
||||
where you set an IP address and interact with th rest of the world. The
|
||||
@@ -425,7 +453,7 @@ VLAN interfaces can be used for many things, here we will focus on their
|
||||
use as upper interface on a bridge.
|
||||
|
||||
|
||||
${H2}Bridging Interfaces${H0}
|
||||
$(h2 "Bridging Interfaces")
|
||||
|
||||
A bridge is the correct name for a switch. In the context of this text,
|
||||
however, we will use the term to refer to the Linux bridge module in the
|
||||
@@ -455,7 +483,7 @@ Note: these ports should not (cannot) have any IP address. Instead, any IP
|
||||
/proc/sys/net/ipv6/conf/eth0/disable_ipv6 sysctl file to '1'.
|
||||
|
||||
|
||||
${H2}Bridging and VLANs${H0}
|
||||
$(h2 "Bridging and VLANs")
|
||||
|
||||
A VLAN-aware bridge works the same way, only with VLAN separation taken into
|
||||
account. All communication, as well as MAC address learning, is limited to
|
||||
@@ -501,7 +529,7 @@ The resulting stack of interfaces look like this:
|
||||
:
|
||||
|
||||
|
||||
${H2}Persistent Configuration${H0}
|
||||
$(h2 "Persistent Configuration")
|
||||
|
||||
A simple end device can get by with the following in /etc/network/interfaces:
|
||||
|
||||
@@ -554,7 +582,7 @@ possible to combine the two if needed. Use 'inet dhcp' and add an 'address'
|
||||
statement to the iface stanza.
|
||||
|
||||
|
||||
${H2}Port Classification${H0}
|
||||
$(h2 "Port Classification")
|
||||
|
||||
The bundled 'show' script is a very handy tool. It use several tricks to make
|
||||
information about the system more accessible. On switching capable hardware
|
||||
@@ -562,7 +590,7 @@ products, switch ports are identified early at system bootstrap and placed in
|
||||
the 'port' group. See 'ip link' output:
|
||||
|
||||
...
|
||||
4: e0: <BROADCAST,MULTICAST> master br0 state UP ${UL}group port${H0}
|
||||
4: e0: <BROADCAST,MULTICAST> master br0 state UP $(em "group port")
|
||||
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
|
||||
...
|
||||
|
||||
@@ -583,7 +611,7 @@ Another way is to add something like this to /etc/rc.local:
|
||||
done
|
||||
|
||||
|
||||
${H2}Interesting Files${H0}
|
||||
$(h2 "Interesting Files")
|
||||
|
||||
- /etc/dhcpcd.conf General DHCP and ZeroConf (LL) settings
|
||||
- /etc/network/interfaces The original, useful for small setups
|
||||
@@ -593,8 +621,7 @@ ${H2}Interesting Files${H0}
|
||||
- /etc/sysctl.d/* Snippets, useful for per-subsystem settings
|
||||
|
||||
|
||||
${H1}Summary ${H0}
|
||||
|
||||
$(h1 "Summary")
|
||||
All persistent networking is set up in /etc/network/interfaces using the
|
||||
program ifupdown-ng. The tools to reconfigure networking at runtime are:
|
||||
|
||||
@@ -612,7 +639,7 @@ adding VLANs, the vlan1 and vlan2 interfaces on top so it of it all. Then
|
||||
finally it can start the DHCP client on vlan1 and set the static IP address
|
||||
on vlan2.
|
||||
|
||||
${BL}>>> Be careful with these tools when logged in remotely! <<<${H0}
|
||||
$(em ">>> Be careful with these tools when logged in remotely! <<<")
|
||||
|
||||
EOF
|
||||
}
|
||||
@@ -639,7 +666,7 @@ topic()
|
||||
if [ "$1" = "-p" ]; then
|
||||
shift
|
||||
pager="cat"
|
||||
noansi
|
||||
plain="yes"
|
||||
else
|
||||
if command -v most; then
|
||||
pager=most
|
||||
|
||||
Reference in New Issue
Block a user