Commit ad647d0d authored by Jakub,Kolodziejski's avatar Jakub,Kolodziejski
Browse files

Initial version

parents
Pipeline #260 failed with stages
#!/bin/bash
# Shell script to automatically find USRP N310 & 2974 serial redirect ports and generate the ser2net.conf file necessary.
# Jakub Kolodziejski - 2/12/2020
SER2NETCONF='/etc/ser2net.conf'
# Make sure script is run with root or sudo privileges because it will be modifying /etc/ser2net.conf and restart the service
if [ $EUID -ne 0 ]; then
echo "This script must be run as root!"
exit 1
fi
# Make sure ser2net is installed
if [ -z $(which ser2net) ]; then
echo "Package ser2net not found. Please install ser2net!"
echo " apt-get install ser2net"
exit 1
fi
# Clear the ser2net.conf file
echo "Setting up ser2net.conf"
echo "# Auto generated ser2net.conf configuration" > $SER2NETCONF
echo "" >> $SER2NETCONF
# Find the USRP N310 serial redirect port and add the necessary lines to ser2net.conf if found
echo "Looking for USRP N310"
USRP_N310_SERIAL=$(find /dev/serial/by-id/ -type l -name "usb-Silicon_Labs_CP2105_Dual_USB_to_UART_Bridge_Controller_*-if00-port0" | head -n 1)
if [ -z "$USRP_N310_SERIAL" ]; then
echo "None found"
else
echo "Found N310 at: $USRP_N310_SERIAL"
echo "# USRP N310 serial console to onboard ARM board" >> $SER2NETCONF
echo "BANNER:banner_usrpn310:Connected to USRP N310 Serial Console\r\n\r\n" >> $SER2NETCONF
echo "10001:telnet:600:$USRP_N310_SERIAL:115200 8DATABITS NONE 1STOPBIT banner_usrpn310" >> $SER2NETCONF
echo "" >> $SER2NETCONF
fi
# Find the USRP 2974 serial redirect port and add the necessary lines to ser2net.conf if found
echo "Looking for USRP 2974"
USRP_2974_SERIAL=$(find /dev/serial/by-id/ -type l -name "usb-FTDI_FT230X_Basic_UART_*-if00-port0" | head -n 1)
if [ -z "$USRP_2974_SERIAL" ]
then
echo "None found"
else
echo "Found 2974 at: $USRP_2974_SERIAL"
echo "# USRP 2974 serial console to onboard PC" >> $SER2NETCONF
echo "BANNER:banner_usrp2974:Connected to USRP 2974 Serial Console\r\n\r\n" >> $SER2NETCONF
echo "10002:telnet:600:$USRP_2974_SERIAL:115200 8DATABITS NONE 1STOPBIT banner_usrp2974" >> $SER2NETCONF
echo "" >> $SER2NETCONF
fi
# Restart ser2net
echo "Restarting ser2net..."
systemctl restart ser2net
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment