mirror of
https://github.com/RasppleII/a2cloud.git
synced 2024-12-25 02:29:28 +00:00
31 lines
1.1 KiB
Bash
31 lines
1.1 KiB
Bash
#! /bin/bash
|
|
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
|
|
|
if [[ $1 == "-d" ]]; then
|
|
shift
|
|
setgetty=1
|
|
else
|
|
setgetty=
|
|
fi
|
|
|
|
if [[ $1 -ne 300 && $1 -ne 1200 && $1 -ne 2400 && $1 -ne 4800 && $1 -ne 9600 && $1 -ne 19200 && $1 -ne 38400 && $1 -ne 57600 && $1 -ne 115200 ]]; then
|
|
echo 'Usage: baud [-d] 300|1200|2400|4800|9600|19200|38400|57600|115200';
|
|
echo ' -d sets default speed for all serial port shells (takes effect on logout)'
|
|
echo ' omitting -d makes change temporary and immediate'
|
|
else
|
|
if [[ $setgetty ]]; then
|
|
sudo sed -i "s/ttyAMA0 .* /ttyAMA0 $1 /" /etc/inittab;
|
|
sudo sed -i "s/ttyAMA0,[0-9]*/ttyAMA0,$1/g" /boot/cmdline.txt;
|
|
sudo sed -i "s/\(ttyUSB.*\) .* /\1 $1 /g" /etc/inittab;
|
|
sudo init q;
|
|
sudo pkill -f "/sbin/getty"
|
|
else
|
|
if [[ $(tty | grep tty) ]]; then
|
|
stty -F $(tty) $1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
echo -e "$(tput bold)$(tty) current $(stty -a -F $(tty) | grep -o 'speed .* baud')$(tput sgr0)"
|
|
echo -e "$(tput bold)default speed at login: $(grep ttyUSB /etc/inittab | sed 's/^.*ttyUSB[^ ]* \(.*\) .*$/\1/') baud$(tput sgr0)"
|