a2cloud/setup/adtpro-start

42 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2015-10-30 12:34:48 +00:00
#! /bin/bash
2016-10-25 17:42:29 +00:00
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
# adtpro-start - script to start ADTPro "as a headless daemon", ish
#
# 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.
# don't do anything if ADTPro is already running
if [[ $(ps aux | grep [A]DTPro) ]]; then
2015-10-30 12:38:31 +00:00
2016-10-25 17:42:29 +00:00
1&>2 echo "ADTPro server is already running."
2015-10-30 12:38:31 +00:00
else
2016-10-25 17:42:29 +00:00
# look for eligible USB-to-serial adapter
ttyUSB=
# if lower USB port
if [[ -c /dev/ttyUSBlower ]]; then
ttyUSB=ttyUSBlower
# if hub in lower port, use lowest numbered port on hub
elif [[ $(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | wc -l) -gt 0 ]]; then
ttyUSB=$(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | head -1 | cut -c 6-)
# if hub in upper port with multiple adapters, use lowest numbered port on hub
elif [[ $(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | wc -l) -gt 1 ]]; then
ttyUSB=$(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | head -1 | cut -c 6-)
fi
2015-10-30 12:38:31 +00:00
2016-10-25 17:42:29 +00:00
if [[ $ttyUSB ]]; then
echo -n "Please wait..."
sudo nohup adtpro.sh headless serial &> /dev/null
echo "ok."
else
1>&2 echo "No USB-to-serial adapter found in the lower USB port, or"
1>&2 echo " a hub on the lower USB port, or the lowest-numbered port"
1>&2 echo " of a hub on the upper USB port. Not starting ADTPro server."
fi
2015-10-30 12:34:48 +00:00
fi