diff --git a/docs/ivanx/setup/adtpro-start.txt b/docs/ivanx/setup/adtpro-start.txt new file mode 100644 index 0000000..2996a1c --- /dev/null +++ b/docs/ivanx/setup/adtpro-start.txt @@ -0,0 +1,33 @@ +#!/bin/bash + +# don't do anything if ADTPro is already running +if [[ $(ps aux | grep [A]DTPro) ]]; then + + 1&>2 echo "ADTPro server is already running." + +else + + # 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 + + 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 + +fi \ No newline at end of file diff --git a/docs/ivanx/setup/adtpro.sh.txt b/docs/ivanx/setup/adtpro.sh.txt new file mode 100644 index 0000000..aa9b2a5 --- /dev/null +++ b/docs/ivanx/setup/adtpro.sh.txt @@ -0,0 +1,141 @@ +#!/bin/bash + +# ADTPro - *nix startup shell script +# +# Note: +# Invoke with the name of the communications button to push +# in order to start with that mode active (i.e. './adtpro.sh ethernet') +# +# You can set two variables here: +# 1. $MY_JAVA_HOME - to pick a particular java to run under +# 2. $ADTPRO_HOME - to say where you installed ADTPro +# +# Set default ADTPRO_HOME to be the fully qualified +# current working directory. +#export ADTPRO_HOME="`dirname \"$0\"`" +#cd "$ADTPRO_HOME" +#export ADTPRO_HOME=`pwd` + +# Uncomment and modify one or both of the lines below if you +# want to specify a particular location for Java or ADTPro. +# NOTE: be sure to include a trailing slash on MY_JAVA_HOME, +# but not on ADTPRO_HOME. +# +# export MY_JAVA_HOME=/usr/local/java/bin/ +# export ADTPRO_HOME=~/myuser/adtpro + +usageExit () { + echo "usage:" 1>&2 + echo "adtpro.sh [headless] [serial|ethernet|audio|localhost] [serialPortName]" 1>&2 + exit 1 +} + +export ADTPRO_HOME=/usr/local/adtpro +cd "$ADTPRO_HOME" + +OS=`uname` +OS_ARCH=`uname -m` + +[[ $1 == "headless" ]] && { headless=1; shift; } || headless= + +if [[ $1 && ( $1 != "serial" && $1 != "ethernet" && $1 != "audio" && $1 != "localhost" ) ]]; then + usageExit +fi + +# For Linux, use this: +if [ "$OS" = "Linux" ]; then + + serialPortName= + if [[ $1 == "serial" ]]; then + if [[ $2 ]]; then + serialPortName="$2" + [[ ${serialPortName:0:5} == "/dev/" ]] && serialPortName=${serialPortName:5} + if [[ ! -c /dev/$serialPortName ]]; then + echo "Serial port $serialPortName not found." 1>&2 + usageExit + fi + elif [[ -c /dev/ttyUSBlower ]]; then + serialPortName=ttyUSBlower + elif [[ $(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | wc -l) -gt 0 ]]; then + serialPortName=$(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | head -1 | cut -c 6-) + elif [[ $(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | wc -l) -gt 1 ]]; then + serialPortName=$(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | head -1 | cut -c 6-) + else + echo "No eligible USB-to-serial adapter found." 1>&2 + echo "Possible ports:" 1>&2 + echo " lower USB port" + echo " any port on lower USB hub with no other adapters" + echo " lowest port on USB hub on upper or lower USB port with multiple adapters" + usageExit + fi + fi + + if [[ $(grep CommPort= /usr/local/adtpro/disks/ADTPro.properties) ]]; then + if [[ $serialPortName ]]; then + sed -i "s/^CommPort=.*$/CommPort=\/dev\/$serialPortName/" /usr/local/adtpro/disks/ADTPro.properties &> /dev/null + else + serialPortName=$(grep 'CommPort=/dev/' ADTPro.properties 2> /dev/null | cut -f 3 -d '/') + fi + else + echo -e "#ADTPro.properties\n#$(date)\nCommPortSpeed=115200\nCommPortBootstrapSpeed=2400\nCommPort=/dev/$serialPortName\nCommPortBootstrapPacing=250\nHardwareHandshaking=false\nSerialIPHost=localhost\nSerialIPPort=1977" > /usr/local/adtpro/disks/ADTPro.properties + chmod ugo+w /usr/local/adtpro/disks/ADTPro.properties + fi + + ADTPRO_EXTRA_JAVA_PARMS="-Dgnu.io.rxtx.SerialPorts=/dev/$serialPortName" + + if [ -f /usr/bin/raspi-config ]; then + export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/arm + elif [ "$OS_ARCH" = "i686" ]; then + export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/i686-pc-linux-gnu + else + if [ "$OS_ARCH" = "i386" ]; then + export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/i686-pc-linux-gnu + else + export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/x86_64-unknown-linux-gnu + fi + fi +fi + +# For OSX, use this: +if [ "$OS" = "Darwin" ]; then + if [ "$OS_ARCH" = "powerpc" ]; then + export RXTXLIB=lib/rxtx/rxtx-2.1-7-bins-r2/Mac_OS_X + else + export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/mac-10.5 + fi +fi + +# For Solaris, use this: +if [ "$OS" = "SunOS" ]; then + export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/sparc-sun-solaris2.10-32 +fi + +# Set up the library location. +export TWEAK1="-Djava.library.path=" +export TWEAK=$TWEAK1$ADTPRO_HOME/$RXTXLIB + +if [[ $headless ]]; then + if [[ ! $1 || ! -f /usr/bin/xvfb-run ]]; then + if [[ ! -f /usr/bin/xvfb-run ]]; then + echo "Headless operation requires xvfb." + usageExit + else + echo "Headless operation requires a communication mode (e.g. serial)." + usageExit + fi + exit 1 + else + HEADLESS="xvfb-run --auto-servernum " + fi +fi + +if [[ $serialPortName && $(ps aux | grep "/sbin/getty.*$serialPortName") ]]; then + sudo pkill -f "/sbin/getty.*$serialPortName" +fi +sudo pkill -f [A]DTPro +cd "$ADTPRO_HOME"/disks +$HEADLESS"$MY_JAVA_HOME"java -Xms256m -Xmx512m "$TWEAK" $ADTPRO_EXTRA_JAVA_PARMS -cp ../lib/ADTPro.jar:../"$RXTXLIB"/../RXTXcomm.jar:../lib/AppleCommander/AppleCommander-ac.jar org.adtpro.ADTPro $* & +if [[ $1 == "serial" ]]; then + echo "Starting up on interface $serialPortName. Please wait..." +fi +sleep 30 diff --git a/docs/ivanx/setup/vsd.txt b/docs/ivanx/setup/vsd.txt new file mode 100644 index 0000000..1fff799 --- /dev/null +++ b/docs/ivanx/setup/vsd.txt @@ -0,0 +1,42 @@ +#!/bin/bash + +skipWarning= +drive= +if [[ $1 == "-1" || $1 == "-d1" ]]; then + shift +elif [[ $1 = "-2" || $1 == "-d2" ]]; then + drive=2 + shift +fi +if [[ ! $1 ]]; then + echo "virtual drive $(( drive ? 2 : 1 )): $(readlink /usr/local/adtpro/disks/Virtual${drive}.po)" +else + if [[ $1 == "-f" ]]; then + shift + skipWarning=1 + fi + if [[ ! -f $1 ]]; then + echo "Image file '$1' was not found." + elif [[ -f /usr/local/adtpro/disks/Virtual${drive}.po && ! -L /usr/local/adtpro/disks/Virtual${drive}.po ]]; then + echo "/usr/local/adtpro/disks/Virtual${drive}.po is an actual disk image" + echo "file, not a symbolic link. Please move or rename it, and try again." + else + rm /usr/local/adtpro/disks/Virtual${drive}.po &>/dev/null; + [[ ${1:0:1} != "/" ]] && pwd="$PWD/"; + ln -s "$pwd$1" /usr/local/adtpro/disks/Virtual${drive}.po + [[ $drive ]] && VSD2="$pwd$1" || VSD1="$pwd$1" + if [[ $(ps aux | grep [A]DTPro) ]]; then + if [[ ! $skipWarning ]]; then + echo "Please make sure you're not writing to either virtual drive on your Apple II." + echo -n " Press return when ready, or control-C to cancel..." + read + fi + sudo pkill -f [A]DTPro + while [[ $(ps aux | grep [A]DTPro) ]]; do sleep 1; done + /usr/local/bin/adtpro-start + fi + fi +fi + +unset drive +unset pwd