mirror of
https://github.com/RasppleII/a2cloud.git
synced 2024-12-22 13:30:27 +00:00
55c53b9c10
As noted, Ivan has agreed to allow these scripts to be relicensed under CC0. We have one file under LGPL (a unit file we lifted wholesake from systemd) and the ADTPro wrapper which I'm pretty sure Ivan wrote, but if he didn't we need to fix its license to be the same as ADTPro. Either way, to the best of my knowledge, this resolves the question of how things are licensed explicitly. (Closes #21)
47 lines
1.7 KiB
Bash
Executable File
47 lines
1.7 KiB
Bash
Executable File
#! /bin/bash
|
|
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
|
|
|
# baud - user command to change baudrate of current terminal
|
|
#
|
|
# To the extent possible under law, T. Joseph Carter and Ivan Drucker have
|
|
# waived all copyright and related or neighboring rights to the a2cloud
|
|
# scripts themselves. Software used or installed by these scripts is subject
|
|
# to other licenses. This work is published from the United States.
|
|
|
|
isSystemd=
|
|
isSysVInit=
|
|
# If you really want something else, *you* maintain it!
|
|
if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then
|
|
gettyFile="/etc/systemd/system/getty.target.wants/usbgetty@.service"
|
|
elif [[ -f /etc/inittab ]]; then
|
|
gettyFile="/etc/inittab"
|
|
fi
|
|
|
|
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 /" $gettyFile;
|
|
sudo sed -i "s/ttyAMA0,[0-9]*/ttyAMA0,$1/g" /boot/cmdline.txt;
|
|
sudo sed -i "s/\(ttyUSB.*\) .* /\1 $1 /g" $gettyFile;
|
|
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 scanttyUSB $gettyFile | sed 's/^.*scanttyUSB[^ ]* \(.*\) .*$/\1/') baud$(tput sgr0)"
|