mirror of
https://github.com/RasppleII/a2cloud.git
synced 2024-12-21 06:29:57 +00:00
Re-indent scripts (tabs)
This commit is contained in:
parent
78d247a0ef
commit
1824c4aa43
64
setup/a2chat.txt
Normal file → Executable file
64
setup/a2chat.txt
Normal file → Executable file
@ -1,65 +1,65 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
if [[ ! $(dpkg -l irssi 2> /dev/null | grep '^ii') ]]; then
|
||||
echo "Installing irssi..."
|
||||
supo apt-get -y update
|
||||
sudo apt-get -y install irssi &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
echo "Installing irssi..."
|
||||
supo apt-get -y update
|
||||
sudo apt-get -y install irssi &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
fi
|
||||
|
||||
if [[ $1 == "-n" && $2 ]]; then
|
||||
nickname=$2
|
||||
nickname=$2
|
||||
elif [[ $1 == "-n" ]]; then
|
||||
nickname="0"
|
||||
nickname="0"
|
||||
elif [[ -f ~/.irssi/a2c.nickname ]]; then
|
||||
nickname=$(cat ~/.irssi/a2c.nickname)
|
||||
nickname=$(cat ~/.irssi/a2c.nickname)
|
||||
else
|
||||
nickname=
|
||||
nickname=
|
||||
fi
|
||||
|
||||
while [[ ! $nickname || ! $(grep -i '^[a-z_\-\\^{}|`][a-z0-9_\-\\^{}|`]*$' <<< $nickname) ]]; do
|
||||
echo "Choosing a nickname"
|
||||
echo
|
||||
echo "A nickname on irc is how you are known to other people. It can"
|
||||
echo "consist of letters, numbers, and punctuation symbols such as -, _, and ^."
|
||||
echo "Some older IRC servers will cut your nickname to eight characters, but"
|
||||
echo "more modern ones like A2Central do not."
|
||||
echo
|
||||
echo "Aliases are fine on irc, but really common names like James or Mark or"
|
||||
echo "AppleIIGuy are likely to be used by someone else already. A guy named"
|
||||
echo "Joseph might use some variation of their name (such as JosephC or"
|
||||
echo "tjcarter) or come up with something else entirely."
|
||||
echo
|
||||
echo "You can change your nickname once you're online by typing a command"
|
||||
echo "like \"/nick <newnick>\", and you can rerun this script with the -n"
|
||||
echo "parameter to have this script save your choice for future use."
|
||||
echo
|
||||
echo -n "Enter a nickname (use 'a2chat -n' to change it later): "
|
||||
read
|
||||
nickname=$REPLY
|
||||
echo "Choosing a nickname"
|
||||
echo
|
||||
echo "A nickname on irc is how you are known to other people. It can"
|
||||
echo "consist of letters, numbers, and punctuation symbols such as -, _, and ^."
|
||||
echo "Some older IRC servers will cut your nickname to eight characters, but"
|
||||
echo "more modern ones like A2Central do not."
|
||||
echo
|
||||
echo "Aliases are fine on irc, but really common names like James or Mark or"
|
||||
echo "AppleIIGuy are likely to be used by someone else already. A guy named"
|
||||
echo "Joseph might use some variation of their name (such as JosephC or"
|
||||
echo "tjcarter) or come up with something else entirely."
|
||||
echo
|
||||
echo "You can change your nickname once you're online by typing a command"
|
||||
echo "like \"/nick <newnick>\", and you can rerun this script with the -n"
|
||||
echo "parameter to have this script save your choice for future use."
|
||||
echo
|
||||
echo -n "Enter a nickname (use 'a2chat -n' to change it later): "
|
||||
read
|
||||
nickname=$REPLY
|
||||
done
|
||||
|
||||
mkdir -p ~/.irssi
|
||||
echo $nickname > ~/.irssi/a2c.nickname
|
||||
|
||||
if [[ -f ~/.irssi/startup ]]; then
|
||||
mv ~/.irssi/startup ~/.irssi/startup.orig
|
||||
mv ~/.irssi/startup ~/.irssi/startup.orig
|
||||
fi
|
||||
echo -e "/network add -autosendcmd '/join #a2c.chat' Palomino.A2\n/server add -auto -network Palomino.A2 irc.a2central.com\n" > ~/.irssi/startup
|
||||
|
||||
if [[ -f ~/.irssi/config ]]; then
|
||||
cp ~/.irssi/config ~/.irssi/config.orig
|
||||
cp ~/.irssi/config ~/.irssi/config.orig
|
||||
fi
|
||||
|
||||
irssi -n $nickname
|
||||
|
||||
rm ~/.irssi/startup &> /dev/null
|
||||
if [[ -f ~/.irssi/startup.orig ]]; then
|
||||
mv ~/.irssi/startup.orig ~/.irssi/startup
|
||||
mv ~/.irssi/startup.orig ~/.irssi/startup
|
||||
fi
|
||||
|
||||
rm ~/.irssi/config &> /dev/null
|
||||
if [[ -f ~/.irssi/config.orig ]]; then
|
||||
mv ~/.irssi/config.orig ~/.irssi/config
|
||||
mv ~/.irssi/config.orig ~/.irssi/config
|
||||
fi
|
||||
|
28
setup/a2cloudrc.txt
Normal file → Executable file
28
setup/a2cloudrc.txt
Normal file → Executable file
@ -1,37 +1,37 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
source /usr/local/etc/a2cloud-aliases
|
||||
|
||||
if [[ -f /usr/local/java/bin/java ]]; then
|
||||
export JAVA_HOME=/usr/local/java
|
||||
export JAVA_HOME=/usr/local/java
|
||||
elif [[ -f /usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/bin/java ]]; then # RPi
|
||||
export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt
|
||||
export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt
|
||||
elif [[ -f /usr/lib/jvm/java-8-oracle/bin/java ]]; then # webupd8
|
||||
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
|
||||
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
|
||||
elif [[ -f /usr/lib/jvm/java-8-oracle/jre/bin/java ]]; then # Ubuntu 14.04 RPi2
|
||||
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre
|
||||
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/jre
|
||||
elif [[ -f /usr/lib/jvm/jdk-7-oracle-armhf/bin/java ]]; then # RPi
|
||||
export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf
|
||||
export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf
|
||||
elif [[ -f /usr/lib/jvm/jdk-7-oracle/bin/java ]]; then # webupd8
|
||||
export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle
|
||||
export JAVA_HOME=/usr/lib/jvm/jdk-7-oracle
|
||||
fi
|
||||
[[ ! $(grep java <<< $PATH) ]] && PATH=$PATH:$JAVA_HOME/bin
|
||||
|
||||
if [[ -f /usr/local/etc/a2cloud-lang ]]; then
|
||||
lang8bit=$(cat /usr/local/etc/a2cloud-lang)
|
||||
lang8bit=$(cat /usr/local/etc/a2cloud-lang)
|
||||
else
|
||||
lang8bit=C
|
||||
lang8bit=C
|
||||
fi
|
||||
if [[ ${TERM:0:6} == "screen" ]]; then
|
||||
myTTY=$(ps hp $(ps hp $(ps hp $$ -o ppid) -o ppid) -o tty)
|
||||
myTTY=$(ps hp $(ps hp $(ps hp $$ -o ppid) -o ppid) -o tty)
|
||||
else
|
||||
myTTY=$(tty)
|
||||
export ttyTERM="$TERM"
|
||||
myTTY=$(tty)
|
||||
export ttyTERM="$TERM"
|
||||
fi
|
||||
if [[ $(grep ttyUSB <<< $myTTY) || $(grep ttyAMA <<< $myTTY) ]]; then
|
||||
LANG=$lang8bit
|
||||
LANG=$lang8bit
|
||||
fi
|
||||
if [[ ${TERM:0:6} == "screen" ]]; then
|
||||
TERM=$ttyTERM
|
||||
TERM=$ttyTERM
|
||||
fi
|
||||
|
64
setup/a2news.txt
Normal file → Executable file
64
setup/a2news.txt
Normal file → Executable file
@ -1,60 +1,60 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
defaultNNTP="news.aioe.org"
|
||||
defaultGroups="comp.emulators.apple2:\ncomp.sys.apple2:\ncomp.sys.apple2.comm:\ncomp.sys.apple2.marketplace:\ncomp.sys.apple2.programmer:\ncomp.sys.apple2.usergroups:"
|
||||
|
||||
if [[ ! $(dpkg -l tin 2> /dev/null | grep '^ii') ]]; then
|
||||
echo "Installing Tin newsreader..."
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install tin &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
echo "Installing Tin newsreader..."
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install tin &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
fi
|
||||
|
||||
if [[ $1 == "-h" || $1 == "--help" ]]; then
|
||||
echo "Usage: a2news [-s nntpServerAddress] [-m postingEmailAddress] [otherTinOptions]"
|
||||
echo " note: for full options, instead use 'tin'"
|
||||
exit 1
|
||||
echo "Usage: a2news [-s nntpServerAddress] [-m postingEmailAddress] [otherTinOptions]"
|
||||
echo " note: for full options, instead use 'tin'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while [[ $1 == "-s" || $1 == "-m" ]]; do
|
||||
if [[ $1 == "-s" && $2 ]]; then
|
||||
nntpServer=$2
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
if [[ $1 == "-s" && $2 ]]; then
|
||||
nntpServer=$2
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ $1 == "-m" && $2 ]]; then
|
||||
emailAddress=$2
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
if [[ $1 == "-m" && $2 ]]; then
|
||||
emailAddress=$2
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p ~/.tin
|
||||
|
||||
if [[ ! -f ~/.newsrc ]]; then
|
||||
IFS=''; echo -e "$defaultGroups" > ~/.newsrc
|
||||
IFS=''; echo -e "$defaultGroups" > ~/.newsrc
|
||||
fi
|
||||
|
||||
if [[ $nntpServer || ! -f ~/.tin/nntp.server ]]; then
|
||||
[[ ! $nntpServer ]] && nntpServer="$defaultNNTP"
|
||||
echo "$nntpServer" > ~/.tin/nntp.server
|
||||
[[ ! $nntpServer ]] && nntpServer="$defaultNNTP"
|
||||
echo "$nntpServer" > ~/.tin/nntp.server
|
||||
else
|
||||
nntpServer=$(cat ~/.tin/nntp.server)
|
||||
nntpServer=$(cat ~/.tin/nntp.server)
|
||||
fi
|
||||
|
||||
if [[ $emailAddress || ! -f ~/.tin/tinrc ]]; then
|
||||
while [[ ! $emailAddress || ! $(grep "@" <<< $emailAddress) || ! $(grep "\." <<< $emailAddress) ]]; do
|
||||
echo -n "Enter the email address you want to post as: "
|
||||
read
|
||||
emailAddress=$REPLY
|
||||
done
|
||||
if [[ -f ~/.tin/tinrc ]]; then
|
||||
sed -i "s/^mail_address=.*$/mail_address=$emailAddress/" ~/.tin/tinrc
|
||||
else
|
||||
echo "mail_address=$emailAddress" > ~/.tin/tinrc
|
||||
fi
|
||||
while [[ ! $emailAddress || ! $(grep "@" <<< $emailAddress) || ! $(grep "\." <<< $emailAddress) ]]; do
|
||||
echo -n "Enter the email address you want to post as: "
|
||||
read
|
||||
emailAddress=$REPLY
|
||||
done
|
||||
if [[ -f ~/.tin/tinrc ]]; then
|
||||
sed -i "s/^mail_address=.*$/mail_address=$emailAddress/" ~/.tin/tinrc
|
||||
else
|
||||
echo "mail_address=$emailAddress" > ~/.tin/tinrc
|
||||
fi
|
||||
fi
|
||||
|
||||
NNTPSERVER=$nntpServer tin -r "$@"
|
||||
|
690
setup/acmd.txt
Normal file → Executable file
690
setup/acmd.txt
Normal file → Executable file
@ -1,64 +1,64 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# set default AppleCommander location if ADTPro is not installed
|
||||
defaultAcPath=$(echo -n /usr/local/bin/AppleCommander-*-ac.jar)
|
||||
|
||||
echoerr() {
|
||||
echo "$@" 1>&2;
|
||||
echo "$@" 1>&2;
|
||||
}
|
||||
|
||||
helpExit () {
|
||||
if [[ -s $acmdStdErr ]]; then
|
||||
if [[ $(grep CommandLineHelp $acmdStdErr) ]]; then
|
||||
grep -v ^-[pge][[:space:]] $acmdStdErr | grep -v '^ or' | grep -v 0x2000 1>&2
|
||||
echoerr "-g <imagename> <filename> [<outputFilename>] copy filename out of any"
|
||||
echoerr " disk image. Using - for outputFilename will copy to stdout."
|
||||
echoerr "-e <imagename> <filename> [<outputFilename>] like -g, with conversion"
|
||||
echoerr " to modern file format if possible."
|
||||
echoerr "-p <imagename> <filename> [[$|0x]<type>] [[$|0x]<auxtype>] copy filename"
|
||||
echoerr " into ProDOS disk image. <type> is either three-letter or numeric"
|
||||
echoerr " ProDOS file type (BIN if omitted). Will read from stdin if supplied."
|
||||
echoerr " ProDOS subdirectories in <filename> will be created if needed."
|
||||
echoerr " If an AppleDouble file or Nulib2 extended filename is detected,"
|
||||
echoerr " <type> and <auxtype> are automatically set, and resource forks are kept."
|
||||
if hash cppo &> /dev/null; then
|
||||
echoerr " (To extract these from a ProDOS image file, use cppo -ad or cppo -e.)"
|
||||
fi
|
||||
echoerr "-c <filename> <imagename> [[$|0x]<type>] [[$|0x]<auxtype>] synonym for -p"
|
||||
echoerr " with filename and imagename reversed."
|
||||
#echoerr "-cd <imagename> <filename> <dateTimeString>|<dateTimeStamp>"
|
||||
#echoerr " set creation date and time of file in ProDOS disk image"
|
||||
#echoerr "-md <imagename> <filename> <dateTimeString>|<dateTimeStamp>"
|
||||
#echoerr " set modified date and time of file in ProDOS disk image"
|
||||
else
|
||||
cat $acmdStdErr
|
||||
fi
|
||||
if [[ $arg1 == "-h" ]]; then
|
||||
exitVal=0
|
||||
else
|
||||
exitVal=1
|
||||
fi
|
||||
else
|
||||
if [[ $vsd1_md5 && ( "$vsd1_md5" != "$(md5sum /usr/local/adtpro/disks/Virtual.po)" || "$vsd2_md5" != "$(md5sum /usr/local/adtpro/disks/Virtual2.po)" ) ]]; then
|
||||
if [[ "$vsd1_md5" != "$(md5sum /usr/local/adtpro/disks/Virtual.po)" || "$vsd2_md5" != "$(md5sum /usr/local/adtpro/disks/Virtual2.po)" ]]; then
|
||||
echoerr "One of the virtual drive image files has changed while ADTPro server is active."
|
||||
echoerr " If using VSDRIVE, type 'vsdsync' now to see changes and prevent corruption."
|
||||
fi
|
||||
fi
|
||||
exitval=0
|
||||
fi
|
||||
rm $acmdStdErr &> /dev/null
|
||||
exit $exitVal
|
||||
if [[ -s $acmdStdErr ]]; then
|
||||
if [[ $(grep CommandLineHelp $acmdStdErr) ]]; then
|
||||
grep -v ^-[pge][[:space:]] $acmdStdErr | grep -v '^ or' | grep -v 0x2000 1>&2
|
||||
echoerr "-g <imagename> <filename> [<outputFilename>] copy filename out of any"
|
||||
echoerr " disk image. Using - for outputFilename will copy to stdout."
|
||||
echoerr "-e <imagename> <filename> [<outputFilename>] like -g, with conversion"
|
||||
echoerr " to modern file format if possible."
|
||||
echoerr "-p <imagename> <filename> [[$|0x]<type>] [[$|0x]<auxtype>] copy filename"
|
||||
echoerr " into ProDOS disk image. <type> is either three-letter or numeric"
|
||||
echoerr " ProDOS file type (BIN if omitted). Will read from stdin if supplied."
|
||||
echoerr " ProDOS subdirectories in <filename> will be created if needed."
|
||||
echoerr " If an AppleDouble file or Nulib2 extended filename is detected,"
|
||||
echoerr " <type> and <auxtype> are automatically set, and resource forks are kept."
|
||||
if hash cppo &> /dev/null; then
|
||||
echoerr " (To extract these from a ProDOS image file, use cppo -ad or cppo -e.)"
|
||||
fi
|
||||
echoerr "-c <filename> <imagename> [[$|0x]<type>] [[$|0x]<auxtype>] synonym for -p"
|
||||
echoerr " with filename and imagename reversed."
|
||||
#echoerr "-cd <imagename> <filename> <dateTimeString>|<dateTimeStamp>"
|
||||
#echoerr " set creation date and time of file in ProDOS disk image"
|
||||
#echoerr "-md <imagename> <filename> <dateTimeString>|<dateTimeStamp>"
|
||||
#echoerr " set modified date and time of file in ProDOS disk image"
|
||||
else
|
||||
cat $acmdStdErr
|
||||
fi
|
||||
if [[ $arg1 == "-h" ]]; then
|
||||
exitVal=0
|
||||
else
|
||||
exitVal=1
|
||||
fi
|
||||
else
|
||||
if [[ $vsd1_md5 && ( "$vsd1_md5" != "$(md5sum /usr/local/adtpro/disks/Virtual.po)" || "$vsd2_md5" != "$(md5sum /usr/local/adtpro/disks/Virtual2.po)" ) ]]; then
|
||||
if [[ "$vsd1_md5" != "$(md5sum /usr/local/adtpro/disks/Virtual.po)" || "$vsd2_md5" != "$(md5sum /usr/local/adtpro/disks/Virtual2.po)" ]]; then
|
||||
echoerr "One of the virtual drive image files has changed while ADTPro server is active."
|
||||
echoerr " If using VSDRIVE, type 'vsdsync' now to see changes and prevent corruption."
|
||||
fi
|
||||
fi
|
||||
exitval=0
|
||||
fi
|
||||
rm $acmdStdErr &> /dev/null
|
||||
exit $exitVal
|
||||
}
|
||||
|
||||
decToBin () {
|
||||
dec="$(( 10#$1 ))"
|
||||
bits=""
|
||||
for i in 7 6 5 4 3 2 1 0; do
|
||||
bits+=$(( (dec & (2**i)) >> i ))
|
||||
done
|
||||
echo -n "$(( 10#$bits ))"
|
||||
dec="$(( 10#$1 ))"
|
||||
bits=""
|
||||
for i in 7 6 5 4 3 2 1 0; do
|
||||
bits+=$(( (dec & (2**i)) >> i ))
|
||||
done
|
||||
echo -n "$(( 10#$bits ))"
|
||||
}
|
||||
|
||||
arg1=$1
|
||||
@ -68,350 +68,350 @@ acmdStdErr="/tmp/acmd_$RANDOM$RANDOM"
|
||||
[[ -f /usr/libexec/java_home ]] && osx=1 || osx=
|
||||
|
||||
if [[ $osx ]]; then
|
||||
if ! /usr/libexec/java_home &> /dev/null; then
|
||||
echo -n "AppleCommander requires the Java JDK. Do you want to install it now? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
# install Oracle Java for OS X
|
||||
echo "Downloading Java JDK..."
|
||||
mkdir -p /tmp/jdk
|
||||
curl -L --cookie oraclelicense=accept-securebackup-cookie $(curl -L "http://www.oracle.com/"$(curl -L "http://www.oracle.com/technetwork/java/javase/downloads/" 2> /dev/null | grep -o -m 1 '/technetwork/java/javase/downloads/jdk.-downloads-[0-9]*\.html') 2> /dev/null | grep -o 'http://.*macosx-x64.dmg' | sort | tail -1) 2> /dev/null > /tmp/jdk/jdk.dmg
|
||||
echo "Installing Java JDK..."
|
||||
hdiutil attach /tmp/jdk/jdk.dmg &> /dev/null
|
||||
sudo installer -pkg /Volumes/JDK*/JDK*.pkg -target /
|
||||
diskutil unmountDisk /Volumes/JDK*
|
||||
rm -r /tmp/jdk 2> /dev/null
|
||||
if ! /usr/libexec/java_home &> /dev/null; then
|
||||
echo "The Java JDK could not be installed."
|
||||
echo "Type \"java\" and then click \"More Info...\" to download and install it manually."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if ! /usr/libexec/java_home &> /dev/null; then
|
||||
echo -n "AppleCommander requires the Java JDK. Do you want to install it now? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
# install Oracle Java for OS X
|
||||
echo "Downloading Java JDK..."
|
||||
mkdir -p /tmp/jdk
|
||||
curl -L --cookie oraclelicense=accept-securebackup-cookie $(curl -L "http://www.oracle.com/"$(curl -L "http://www.oracle.com/technetwork/java/javase/downloads/" 2> /dev/null | grep -o -m 1 '/technetwork/java/javase/downloads/jdk.-downloads-[0-9]*\.html') 2> /dev/null | grep -o 'http://.*macosx-x64.dmg' | sort | tail -1) 2> /dev/null > /tmp/jdk/jdk.dmg
|
||||
echo "Installing Java JDK..."
|
||||
hdiutil attach /tmp/jdk/jdk.dmg &> /dev/null
|
||||
sudo installer -pkg /Volumes/JDK*/JDK*.pkg -target /
|
||||
diskutil unmountDisk /Volumes/JDK*
|
||||
rm -r /tmp/jdk 2> /dev/null
|
||||
if ! /usr/libexec/java_home &> /dev/null; then
|
||||
echo "The Java JDK could not be installed."
|
||||
echo "Type \"java\" and then click \"More Info...\" to download and install it manually."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else # not OS X, so presumably Linux
|
||||
if ! hash java &> /dev/null; then
|
||||
echo -n "AppleCommander requires the Java JDK. "
|
||||
if hash apt-get; then
|
||||
echo -n "Do you want to install it now? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
# from http://www.webupd8.org/2012/06/how-to-install-oracle-java-7-in-debian.html
|
||||
if { ! grep -q webupd8team /etc/apt/sources.list; }; then
|
||||
{
|
||||
echo;
|
||||
echo "# Oracle Java JDK";
|
||||
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main";
|
||||
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main";
|
||||
} | sudo tee -a /etc/apt/sources.list > /dev/null
|
||||
fi
|
||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
|
||||
sudo apt-get -y update
|
||||
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
|
||||
sudo apt-get -y install oracle-java8-installer
|
||||
sudo apt-get -y clean
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if ! hash java &> /dev/null; then
|
||||
echo
|
||||
echo "Get it from http://www.oracle.com/technetwork/java/javase/downloads/"
|
||||
exit 1
|
||||
fi
|
||||
if ! hash java &> /dev/null; then
|
||||
echo -n "AppleCommander requires the Java JDK. "
|
||||
if hash apt-get; then
|
||||
echo -n "Do you want to install it now? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
# from http://www.webupd8.org/2012/06/how-to-install-oracle-java-7-in-debian.html
|
||||
if { ! grep -q webupd8team /etc/apt/sources.list; }; then
|
||||
{
|
||||
echo;
|
||||
echo "# Oracle Java JDK";
|
||||
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main";
|
||||
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main";
|
||||
} | sudo tee -a /etc/apt/sources.list > /dev/null
|
||||
fi
|
||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
|
||||
sudo apt-get -y update
|
||||
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
|
||||
sudo apt-get -y install oracle-java8-installer
|
||||
sudo apt-get -y clean
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if ! hash java &> /dev/null; then
|
||||
echo
|
||||
echo "Get it from http://www.oracle.com/technetwork/java/javase/downloads/"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
setAcPath () {
|
||||
acPath=$defaultAcPath
|
||||
adtPath=
|
||||
if [[ ! -f $acPath ]]; then
|
||||
if [[ -f /usr/local/adtpro/adtpro.sh ]]; then
|
||||
adtPath="/usr/local/adtpro"
|
||||
elif [[ $osx ]]; then
|
||||
adtPath=$(echo -n /Applications/ADTPro* | tr ' ' '\n' | sort | head -1);
|
||||
fi
|
||||
if [[ -d "$adtPath" ]]; then
|
||||
acPath="$adtPath"/lib/AppleCommander/AppleCommander-ac.jar
|
||||
[[ ! -f $acPath ]] && acPath=$(echo -n "$adtPath"/lib/AppleCommander/AppleCommander-*-ac.jar)
|
||||
fi
|
||||
fi
|
||||
acPath=$(echo -n $acPath)
|
||||
acPath=$defaultAcPath
|
||||
adtPath=
|
||||
if [[ ! -f $acPath ]]; then
|
||||
if [[ -f /usr/local/adtpro/adtpro.sh ]]; then
|
||||
adtPath="/usr/local/adtpro"
|
||||
elif [[ $osx ]]; then
|
||||
adtPath=$(echo -n /Applications/ADTPro* | tr ' ' '\n' | sort | head -1);
|
||||
fi
|
||||
if [[ -d "$adtPath" ]]; then
|
||||
acPath="$adtPath"/lib/AppleCommander/AppleCommander-ac.jar
|
||||
[[ ! -f $acPath ]] && acPath=$(echo -n "$adtPath"/lib/AppleCommander/AppleCommander-*-ac.jar)
|
||||
fi
|
||||
fi
|
||||
acPath=$(echo -n $acPath)
|
||||
}
|
||||
|
||||
setAcPath
|
||||
if [[ ! -f $acPath ]]; then
|
||||
echo "Installing AppleCommander..."
|
||||
sudo mkdir -p /usr/local/bin
|
||||
acUrl="http://sourceforge.net/projects/applecommander/files/AppleCommander%20-%20Interim/testcase/AppleCommander-1.3.5.13id-ac.jar/download"
|
||||
if [[ $osx ]]; then
|
||||
curl -L "$acUrl" 2> /dev/null | sudo tee /usr/local/bin/AppleCommander-1.3.5.13id-ac.jar > /dev/null
|
||||
else
|
||||
sudo wget -qO /usr/local/bin/AppleCommander-1.3.5.13id-ac.jar "$acUrl"
|
||||
fi
|
||||
setAcPath
|
||||
if [[ ! -f "$acPath" ]]; then
|
||||
echo "AppleCommander couldn't be installed. Download it from"
|
||||
echo "http://applecommander.sourceforge.net and put it in /usr/local/bin."
|
||||
exit 1
|
||||
fi
|
||||
echo "Installing AppleCommander..."
|
||||
sudo mkdir -p /usr/local/bin
|
||||
acUrl="http://sourceforge.net/projects/applecommander/files/AppleCommander%20-%20Interim/testcase/AppleCommander-1.3.5.13id-ac.jar/download"
|
||||
if [[ $osx ]]; then
|
||||
curl -L "$acUrl" 2> /dev/null | sudo tee /usr/local/bin/AppleCommander-1.3.5.13id-ac.jar > /dev/null
|
||||
else
|
||||
sudo wget -qO /usr/local/bin/AppleCommander-1.3.5.13id-ac.jar "$acUrl"
|
||||
fi
|
||||
setAcPath
|
||||
if [[ ! -f "$acPath" ]]; then
|
||||
echo "AppleCommander couldn't be installed. Download it from"
|
||||
echo "http://applecommander.sourceforge.net and put it in /usr/local/bin."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
ac="java -Xmx128m -jar $acPath"
|
||||
|
||||
if [[ ! $2 || $arg1 == "-h" ]]; then
|
||||
java -jar "$acPath" 2> $acmdStdErr
|
||||
[[ $? -eq 127 ]] && exit 127 || helpExit $arg1
|
||||
java -jar "$acPath" 2> $acmdStdErr
|
||||
[[ $? -eq 127 ]] && exit 127 || helpExit $arg1
|
||||
fi
|
||||
|
||||
if [[ $arg1 != "-i" && $arg1 != "-ls" && $arg1 != "-l" && $arg1 != "-ll" && $arg1 != "-x" && $arg1 != "-g" && $arg1 != "-e" && $(ps aux | grep [A]DTPro) ]]; then
|
||||
vsd1_md5="$(md5sum /usr/local/adtpro/disks/Virtual.po)"
|
||||
vsd2_md5="$(md5sum /usr/local/adtpro/disks/Virtual2.po)"
|
||||
vsd1_md5="$(md5sum /usr/local/adtpro/disks/Virtual.po)"
|
||||
vsd2_md5="$(md5sum /usr/local/adtpro/disks/Virtual2.po)"
|
||||
fi
|
||||
|
||||
if [[ ( $arg1 == "-p" || $arg1 == "-c" || $arg1 == "-g" || $arg1 == "-e" ) && $2 && $3 ]]; then
|
||||
|
||||
AD=
|
||||
EX=
|
||||
prodosArg=
|
||||
prodosArgParent=
|
||||
rFile=
|
||||
getArg=
|
||||
if [[ $arg1 == "-c" || $arg1 == "-p" ]]; then
|
||||
if [[ $arg1 == "-c" ]]; then
|
||||
prodosArg="$2"
|
||||
imageArg="$3"
|
||||
elif [[ $arg1 == "-p" ]]; then
|
||||
prodosArg="$3"
|
||||
imageArg="$2"
|
||||
fi
|
||||
[[ $prodosArg == *"/"* ]] && prodosArgParent="${prodosArg%/*}/"
|
||||
rFile="${prodosArgParent}.AppleDouble/${prodosArg##*/}"
|
||||
if [[ -f "$prodosArg" && -f "$rFile" ]]; then # AppleDouble
|
||||
AD=1
|
||||
elif [ -f "${prodosArg%#*}"#?????? ]; then # Nulib2 ext filename
|
||||
EX=1
|
||||
prodosArg=$(echo -n "${prodosArg%#*}"#??????)
|
||||
rFile="${prodosArg}"r
|
||||
fi
|
||||
if [[ $AD || $EX ]]; then
|
||||
# if target is not a ProDOS disk, ignore metadata
|
||||
if ! $ac -i "$imageArg" | grep -q '^Disk Format: ProDOS'; then
|
||||
AD=
|
||||
EX=
|
||||
fi
|
||||
fi
|
||||
elif [[ $arg1 == "-g" || $arg1 == "-e" ]]; then
|
||||
fileArg="$3"
|
||||
imageArg="$2"
|
||||
getArg="$arg1"
|
||||
else
|
||||
exit 2;
|
||||
fi
|
||||
AD=
|
||||
EX=
|
||||
prodosArg=
|
||||
prodosArgParent=
|
||||
rFile=
|
||||
getArg=
|
||||
if [[ $arg1 == "-c" || $arg1 == "-p" ]]; then
|
||||
if [[ $arg1 == "-c" ]]; then
|
||||
prodosArg="$2"
|
||||
imageArg="$3"
|
||||
elif [[ $arg1 == "-p" ]]; then
|
||||
prodosArg="$3"
|
||||
imageArg="$2"
|
||||
fi
|
||||
[[ $prodosArg == *"/"* ]] && prodosArgParent="${prodosArg%/*}/"
|
||||
rFile="${prodosArgParent}.AppleDouble/${prodosArg##*/}"
|
||||
if [[ -f "$prodosArg" && -f "$rFile" ]]; then # AppleDouble
|
||||
AD=1
|
||||
elif [ -f "${prodosArg%#*}"#?????? ]; then # Nulib2 ext filename
|
||||
EX=1
|
||||
prodosArg=$(echo -n "${prodosArg%#*}"#??????)
|
||||
rFile="${prodosArg}"r
|
||||
fi
|
||||
if [[ $AD || $EX ]]; then
|
||||
# if target is not a ProDOS disk, ignore metadata
|
||||
if ! $ac -i "$imageArg" | grep -q '^Disk Format: ProDOS'; then
|
||||
AD=
|
||||
EX=
|
||||
fi
|
||||
fi
|
||||
elif [[ $arg1 == "-g" || $arg1 == "-e" ]]; then
|
||||
fileArg="$3"
|
||||
imageArg="$2"
|
||||
getArg="$arg1"
|
||||
else
|
||||
exit 2;
|
||||
fi
|
||||
|
||||
shift
|
||||
shift
|
||||
|
||||
if [[ $getArg ]]; then # get file
|
||||
if [[ $getArg ]]; then # get file
|
||||
|
||||
outFile=
|
||||
[[ $3 && $3 != "-" ]] && outFile="$3"
|
||||
[[ ! $3 ]] && outFile="${2##*/}"
|
||||
$ac $getArg "$imageArg" "$fileArg" $outFile 2> $acmdStdErr
|
||||
outFile=
|
||||
[[ $3 && $3 != "-" ]] && outFile="$3"
|
||||
[[ ! $3 ]] && outFile="${2##*/}"
|
||||
$ac $getArg "$imageArg" "$fileArg" $outFile 2> $acmdStdErr
|
||||
|
||||
else # put file
|
||||
else # put file
|
||||
|
||||
# test ProDOS name validity
|
||||
prodosPath=$(tr [:lower:] [:upper:] <<< "${prodosArg%#*}" )
|
||||
IFS_orig="$IFS"; IFS="/";
|
||||
prodosPathParts="$prodosPath"
|
||||
for thisProdosPathPart in $prodosPathParts; do
|
||||
if [[ ${#thisProdosPathPart} -gt 15 || ! $(grep ^[A-Z][0-9A-Z\.]*$ <<< $thisProdosPathPart) ]]; then
|
||||
echoerr "Invalid ProDOS name: $prodosPath"; exit 1;
|
||||
fi
|
||||
done
|
||||
IFS="$IFS_orig"
|
||||
# test ProDOS name validity
|
||||
prodosPath=$(tr [:lower:] [:upper:] <<< "${prodosArg%#*}" )
|
||||
IFS_orig="$IFS"; IFS="/";
|
||||
prodosPathParts="$prodosPath"
|
||||
for thisProdosPathPart in $prodosPathParts; do
|
||||
if [[ ${#thisProdosPathPart} -gt 15 || ! $(grep ^[A-Z][0-9A-Z\.]*$ <<< $thisProdosPathPart) ]]; then
|
||||
echoerr "Invalid ProDOS name: $prodosPath"; exit 1;
|
||||
fi
|
||||
done
|
||||
IFS="$IFS_orig"
|
||||
|
||||
# filetype to name table
|
||||
P_00=UNK; P_01=BAD; P_02=PCD; P_03=PTX; P_04=TXT; P_05=PDA; P_06=BIN; P_07=FNT; P_08=FOT; P_09=BA3; P_0a=DA3; P_0b=WPF; P_0c=SOS; P_0f=DIR; P_10=RPD; P_11=RPI; P_12=AFD; P_13=AFM; P_14=AFR; P_15=SCL; P_16=PFS; P_19=ADB; P_1a=AWP; P_1b=ASP; P_20=TDM; P_21=IPS; P_22=UPV; P_29=3SD; P_2a=8SC; P_2b=8OB; P_2c=8IC; P_2d=8LD; P_2e=P8C; P_41=OCR; P_42=FTD; P_50=GWP; P_51=GSS; P_52=GDB; P_53=DRW; P_54=GDP; P_55=HMD; P_56=EDU; P_57=STN; P_58=HLP; P_59=COM; P_5a=CFG; P_5b=ANM; P_5c=MUM; P_5d=ENT; P_5e=DVU; P_60=PRE; P_6b=BIO; P_6d=DVR; P_6e=PRE; P_6f=HDV; P_80=GEZ; P_81=GE1; P_82=GEO; P_83=GE3; P_84=GE4; P_85=GE5; P_86=GE6; P_87=GE7; P_88=GE8; P_89=GE9; P_8a=GEA; P_8b=GEB; P_8c=GEC; P_8d=GED; P_8e=GEE; P_8f=GEF; P_a0=WP_; P_ab=GSB; P_ac=TDF; P_ad=BDF; P_b0=SRC; P_b1=OBJ; P_b2=LIB; P_b3=S16; P_b4=RTL; P_b5=EXE; P_b6=STR; P_b7=TSF; P_b8=NDA; P_b9=CDA; P_ba=TOL; P_bb=DRV; P_bc=LDF; P_bd=FST; P_bf=DOC; P_c0=PNT; P_c1=PIC; P_c2=ANI; P_c3=PAL; P_c5=OOG; P_c6=SCR; P_c7=CDV; P_c8=FON; P_c9=FND; P_ca=ICN; P_d5=MUS; P_d6=INS; P_d7=MDI; P_d8=SND; P_db=DBM; P_e0=SHK; P_e2=DTS; P_ee=R16; P_ef=PAS; P_f0=CMD; P_f9=P16; P_fa=INT; P_fb=IVR; P_fc=BAS; P_fd=VAR; P_fe=REL; P_ff=SYS;
|
||||
# filetype to name table
|
||||
P_00=UNK; P_01=BAD; P_02=PCD; P_03=PTX; P_04=TXT; P_05=PDA; P_06=BIN; P_07=FNT; P_08=FOT; P_09=BA3; P_0a=DA3; P_0b=WPF; P_0c=SOS; P_0f=DIR; P_10=RPD; P_11=RPI; P_12=AFD; P_13=AFM; P_14=AFR; P_15=SCL; P_16=PFS; P_19=ADB; P_1a=AWP; P_1b=ASP; P_20=TDM; P_21=IPS; P_22=UPV; P_29=3SD; P_2a=8SC; P_2b=8OB; P_2c=8IC; P_2d=8LD; P_2e=P8C; P_41=OCR; P_42=FTD; P_50=GWP; P_51=GSS; P_52=GDB; P_53=DRW; P_54=GDP; P_55=HMD; P_56=EDU; P_57=STN; P_58=HLP; P_59=COM; P_5a=CFG; P_5b=ANM; P_5c=MUM; P_5d=ENT; P_5e=DVU; P_60=PRE; P_6b=BIO; P_6d=DVR; P_6e=PRE; P_6f=HDV; P_80=GEZ; P_81=GE1; P_82=GEO; P_83=GE3; P_84=GE4; P_85=GE5; P_86=GE6; P_87=GE7; P_88=GE8; P_89=GE9; P_8a=GEA; P_8b=GEB; P_8c=GEC; P_8d=GED; P_8e=GEE; P_8f=GEF; P_a0=WP_; P_ab=GSB; P_ac=TDF; P_ad=BDF; P_b0=SRC; P_b1=OBJ; P_b2=LIB; P_b3=S16; P_b4=RTL; P_b5=EXE; P_b6=STR; P_b7=TSF; P_b8=NDA; P_b9=CDA; P_ba=TOL; P_bb=DRV; P_bc=LDF; P_bd=FST; P_bf=DOC; P_c0=PNT; P_c1=PIC; P_c2=ANI; P_c3=PAL; P_c5=OOG; P_c6=SCR; P_c7=CDV; P_c8=FON; P_c9=FND; P_ca=ICN; P_d5=MUS; P_d6=INS; P_d7=MDI; P_d8=SND; P_db=DBM; P_e0=SHK; P_e2=DTS; P_ee=R16; P_ef=PAS; P_f0=CMD; P_f9=P16; P_fa=INT; P_fb=IVR; P_fc=BAS; P_fd=VAR; P_fe=REL; P_ff=SYS;
|
||||
|
||||
# process filetype
|
||||
if [[ ! $AD && ! $EX ]]; then # no resource fork or metadata
|
||||
[[ ${3:0:2} == "0x" ]] && ftArg="\$${3:2}" || ftArg="$3"
|
||||
auxType="$4"
|
||||
# process filetype
|
||||
if [[ ! $AD && ! $EX ]]; then # no resource fork or metadata
|
||||
[[ ${3:0:2} == "0x" ]] && ftArg="\$${3:2}" || ftArg="$3"
|
||||
auxType="$4"
|
||||
|
||||
# assume BIN/$2000 if filetype omitted
|
||||
if [[ ! $ftArg ]]; then
|
||||
ft="BIN"
|
||||
auxType="\$2000"
|
||||
# accept hex or decimal number for file type
|
||||
elif [[ ( ${ftArg:0:1} == '$' && ${#ftArg} -eq 3 ) || $(grep [0-9] <<< ${ftArg:0:1}) ]]; then
|
||||
if [[ ${ftArg:0:1} == '$' ]]; then
|
||||
fc=$(tr [:upper:] [:lower:] <<< ${ftArg:1:2})
|
||||
else
|
||||
fc=$(printf %02X "$ftArg" | tr [:upper:] [:lower:])
|
||||
fi
|
||||
ftVar="P_$fc";
|
||||
[[ ${!ftVar} ]] && ft=${!ftVar} || ft="\$$fc";
|
||||
else
|
||||
ft="$ftArg"
|
||||
fi
|
||||
# assume BIN/$2000 if filetype omitted
|
||||
if [[ ! $ftArg ]]; then
|
||||
ft="BIN"
|
||||
auxType="\$2000"
|
||||
# accept hex or decimal number for file type
|
||||
elif [[ ( ${ftArg:0:1} == '$' && ${#ftArg} -eq 3 ) || $(grep [0-9] <<< ${ftArg:0:1}) ]]; then
|
||||
if [[ ${ftArg:0:1} == '$' ]]; then
|
||||
fc=$(tr [:upper:] [:lower:] <<< ${ftArg:1:2})
|
||||
else
|
||||
fc=$(printf %02X "$ftArg" | tr [:upper:] [:lower:])
|
||||
fi
|
||||
ftVar="P_$fc";
|
||||
[[ ${!ftVar} ]] && ft=${!ftVar} || ft="\$$fc";
|
||||
else
|
||||
ft="$ftArg"
|
||||
fi
|
||||
|
||||
# set auxtype to $0801 for Applesoft programs if not specified
|
||||
[[ $ft == "BAS" && ! $auxType ]] && auxType="\$0801"
|
||||
# set auxtype to $0801 for Applesoft programs if not specified
|
||||
[[ $ft == "BAS" && ! $auxType ]] && auxType="\$0801"
|
||||
|
||||
# test for absence of stdin [[ -t 0 ]] and if absent use ProDOS name
|
||||
if [[ -t 0 ]]; then
|
||||
[[ ! -f $prodosArg ]] && { echoerr "$prodosArg not found."; exit 1; }
|
||||
$ac -d "$imageArg" $prodosPath &> /dev/null
|
||||
$ac -p "$imageArg" $prodosPath $ft $auxType < $prodosArg 2> $acmdStdErr
|
||||
else
|
||||
$ac -d "$imageArg" $prodosPath &> /dev/null
|
||||
$ac -p "$imageArg" $prodosPath $ft $auxType 2> $acmdStdErr
|
||||
fi
|
||||
else # AppleDouble or nulib extended, get resource fork and file metadata from header file
|
||||
# test for absence of stdin [[ -t 0 ]] and if absent use ProDOS name
|
||||
if [[ -t 0 ]]; then
|
||||
[[ ! -f $prodosArg ]] && { echoerr "$prodosArg not found."; exit 1; }
|
||||
$ac -d "$imageArg" $prodosPath &> /dev/null
|
||||
$ac -p "$imageArg" $prodosPath $ft $auxType < $prodosArg 2> $acmdStdErr
|
||||
else
|
||||
$ac -d "$imageArg" $prodosPath &> /dev/null
|
||||
$ac -p "$imageArg" $prodosPath $ft $auxType 2> $acmdStdErr
|
||||
fi
|
||||
else # AppleDouble or nulib extended, get resource fork and file metadata from header file
|
||||
|
||||
[[ ! -f $prodosArg ]] && { echoerr "$prodosArg not found."; exit 1; }
|
||||
[[ $AD && ! -f $rFile ]] && { echoerr "Not an AppleDouble file: $rFile"; exit 1; }
|
||||
[[ ! -f $prodosArg ]] && { echoerr "$prodosArg not found."; exit 1; }
|
||||
[[ $AD && ! -f $rFile ]] && { echoerr "Not an AppleDouble file: $rFile"; exit 1; }
|
||||
|
||||
if [[ $AD ]]; then
|
||||
# get metadata from AppleDouble header
|
||||
[[ $(dd if="$rFile" bs=1 count=1 skip=741 2> /dev/null | wc -c) -gt 0 ]] && isExtFile=1 || isExtFile=
|
||||
fileData=$(dd if="$rFile" bs=1 count=24 skip=637 2> /dev/null | xxd -p | tr -d '\n')
|
||||
ftVar="P_${fileData:34:2}";
|
||||
auxType="\$"${fileData:36:4}
|
||||
cDateTime=$(printf %d 0x${fileData:0:8})
|
||||
mDateTime=$(printf %d 0x${fileData:8:8})
|
||||
[[ $(printf %d 0x"${fileData:0:2}") -gt 127 ]] && (( cDateTime-=4294967296 )) # handle negative hex number
|
||||
[[ $(printf %d 0x"${fileData:8:2}") -gt 127 ]] && (( mDateTime-=4294967296 )) # handle negative hex number
|
||||
(( cDateTime+=946684800 )) # convert AD timestamp to Unix timestamp
|
||||
(( mDateTime+=946684800 )) # convert AD timestamp to Unix timestamp
|
||||
else # EX
|
||||
# get metadata from file info
|
||||
[[ -f "$rFile" ]] && isExtFile=1 || isExtFile=
|
||||
ftVar="P_${prodosArg: -6:2}"
|
||||
auxType="\$"${prodosArg: -4}
|
||||
if [[ $osx ]]; then
|
||||
mDateTime=$(stat -f "%m" "$prodosArg")
|
||||
else
|
||||
mDateTime=$(stat -c %Y "$prodosArg")
|
||||
fi
|
||||
cDateTime=$mDateTime
|
||||
fi
|
||||
[[ ${!ftVar} ]] && ft=${!ftVar} || ft="\$$fc"; # set file type
|
||||
# convert unix timestamp to ProDOS bitfield yyyyyyymmmmddddd 000hhhhh00mmmmmm
|
||||
cDateFields=($(date -d @$cDateTime +"%y %m %d %H %M" 2> /dev/null))
|
||||
[[ ! $cDateFields ]] && cDateFields=($(date -r $cDateTime +"%y %m %d %H %M")) # OS X/BSD
|
||||
mDateFields=($(date -d @$mDateTime +"%y %m %d %H %M" 2> /dev/null))
|
||||
[[ ! $mDateFields ]] && mDateFields=($(date -r $mDateTime +"%y %m %d %H %M")) # OS X/BSD
|
||||
cDateTimeHex=$(printf %08X $(( 2#$(printf %07d $(decToBin ${cDateFields[0]}))$(printf %04d $(decToBin ${cDateFields[1]}))$(printf %05d $(decToBin ${cDateFields[2]}))$(printf %08d $(decToBin ${cDateFields[3]}))$(printf %08d $(decToBin ${cDateFields[4]})) )))
|
||||
cDateTimeHex=${cDateTimeHex:2:2}${cDateTimeHex:0:2}${cDateTimeHex:6:2}${cDateTimeHex:4:2}
|
||||
mDateTimeHex=$(printf %08X $(( 2#$(printf %07d $(decToBin ${mDateFields[0]}))$(printf %04d $(decToBin ${mDateFields[1]}))$(printf %05d $(decToBin ${mDateFields[2]}))$(printf %08d $(decToBin ${mDateFields[3]}))$(printf %08d $(decToBin ${mDateFields[4]})) )))
|
||||
mDateTimeHex=${mDateTimeHex:2:2}${mDateTimeHex:0:2}${mDateTimeHex:6:2}${mDateTimeHex:4:2}
|
||||
if [[ $AD ]]; then
|
||||
# get metadata from AppleDouble header
|
||||
[[ $(dd if="$rFile" bs=1 count=1 skip=741 2> /dev/null | wc -c) -gt 0 ]] && isExtFile=1 || isExtFile=
|
||||
fileData=$(dd if="$rFile" bs=1 count=24 skip=637 2> /dev/null | xxd -p | tr -d '\n')
|
||||
ftVar="P_${fileData:34:2}";
|
||||
auxType="\$"${fileData:36:4}
|
||||
cDateTime=$(printf %d 0x${fileData:0:8})
|
||||
mDateTime=$(printf %d 0x${fileData:8:8})
|
||||
[[ $(printf %d 0x"${fileData:0:2}") -gt 127 ]] && (( cDateTime-=4294967296 )) # handle negative hex number
|
||||
[[ $(printf %d 0x"${fileData:8:2}") -gt 127 ]] && (( mDateTime-=4294967296 )) # handle negative hex number
|
||||
(( cDateTime+=946684800 )) # convert AD timestamp to Unix timestamp
|
||||
(( mDateTime+=946684800 )) # convert AD timestamp to Unix timestamp
|
||||
else # EX
|
||||
# get metadata from file info
|
||||
[[ -f "$rFile" ]] && isExtFile=1 || isExtFile=
|
||||
ftVar="P_${prodosArg: -6:2}"
|
||||
auxType="\$"${prodosArg: -4}
|
||||
if [[ $osx ]]; then
|
||||
mDateTime=$(stat -f "%m" "$prodosArg")
|
||||
else
|
||||
mDateTime=$(stat -c %Y "$prodosArg")
|
||||
fi
|
||||
cDateTime=$mDateTime
|
||||
fi
|
||||
[[ ${!ftVar} ]] && ft=${!ftVar} || ft="\$$fc"; # set file type
|
||||
# convert unix timestamp to ProDOS bitfield yyyyyyymmmmddddd 000hhhhh00mmmmmm
|
||||
cDateFields=($(date -d @$cDateTime +"%y %m %d %H %M" 2> /dev/null))
|
||||
[[ ! $cDateFields ]] && cDateFields=($(date -r $cDateTime +"%y %m %d %H %M")) # OS X/BSD
|
||||
mDateFields=($(date -d @$mDateTime +"%y %m %d %H %M" 2> /dev/null))
|
||||
[[ ! $mDateFields ]] && mDateFields=($(date -r $mDateTime +"%y %m %d %H %M")) # OS X/BSD
|
||||
cDateTimeHex=$(printf %08X $(( 2#$(printf %07d $(decToBin ${cDateFields[0]}))$(printf %04d $(decToBin ${cDateFields[1]}))$(printf %05d $(decToBin ${cDateFields[2]}))$(printf %08d $(decToBin ${cDateFields[3]}))$(printf %08d $(decToBin ${cDateFields[4]})) )))
|
||||
cDateTimeHex=${cDateTimeHex:2:2}${cDateTimeHex:0:2}${cDateTimeHex:6:2}${cDateTimeHex:4:2}
|
||||
mDateTimeHex=$(printf %08X $(( 2#$(printf %07d $(decToBin ${mDateFields[0]}))$(printf %04d $(decToBin ${mDateFields[1]}))$(printf %05d $(decToBin ${mDateFields[2]}))$(printf %08d $(decToBin ${mDateFields[3]}))$(printf %08d $(decToBin ${mDateFields[4]})) )))
|
||||
mDateTimeHex=${mDateTimeHex:2:2}${mDateTimeHex:0:2}${mDateTimeHex:6:2}${mDateTimeHex:4:2}
|
||||
|
||||
# create forks and file entry
|
||||
### RIGHT HERE PROBLEMS IF #000000 specified and maybe if not
|
||||
fileName="${prodosPath##*/}"
|
||||
if [[ $isExtFile ]]; then
|
||||
dfName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
||||
while [[ ! $rfName || $rfName == $dfName ]]; do
|
||||
rfName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
||||
done
|
||||
while [[ $fileName == "${prodosPath##*/}" || $rfName == $fileName || $dfName == $fileName ]]; do
|
||||
fileName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
||||
done
|
||||
$ac -d "$imageArg" "${prodosArgParent}$dfName" 2> /dev/null
|
||||
dd if="$prodosArg" 2> /dev/null | $ac -p "$imageArg" "${prodosArgParent}$dfName" $00 2> $acmdStdErr
|
||||
$ac -d "$imageArg" "${prodosArgParent}$rfName" 2> /dev/null
|
||||
dd if="$rFile" bs=1 skip=$(( 0$AD ? 741 : 0 )) 2> /dev/null | $ac -p "$imageArg" "${prodosArgParent}$rfName" $00 2> $acmdStdErr
|
||||
fi
|
||||
# create forks and file entry
|
||||
### RIGHT HERE PROBLEMS IF #000000 specified and maybe if not
|
||||
fileName="${prodosPath##*/}"
|
||||
if [[ $isExtFile ]]; then
|
||||
dfName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
||||
while [[ ! $rfName || $rfName == $dfName ]]; do
|
||||
rfName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
||||
done
|
||||
while [[ $fileName == "${prodosPath##*/}" || $rfName == $fileName || $dfName == $fileName ]]; do
|
||||
fileName=X$(printf %04X $RANDOM $RANDOM $RANDOM)
|
||||
done
|
||||
$ac -d "$imageArg" "${prodosArgParent}$dfName" 2> /dev/null
|
||||
dd if="$prodosArg" 2> /dev/null | $ac -p "$imageArg" "${prodosArgParent}$dfName" $00 2> $acmdStdErr
|
||||
$ac -d "$imageArg" "${prodosArgParent}$rfName" 2> /dev/null
|
||||
dd if="$rFile" bs=1 skip=$(( 0$AD ? 741 : 0 )) 2> /dev/null | $ac -p "$imageArg" "${prodosArgParent}$rfName" $00 2> $acmdStdErr
|
||||
fi
|
||||
|
||||
# create file entry, then find it
|
||||
$ac -d "$imageArg" "${prodosArgParent}$fileName" 2> /dev/null
|
||||
[[ $isExtFile ]] && ddsrc="if=/dev/zero bs=512 count=1" || ddsrc="if=$prodosArg"
|
||||
dd $ddsrc 2> /dev/null | $ac -p "$imageArg" "${prodosArgParent}$fileName" "$ft" "$auxType" 2> $acmdStdErr
|
||||
# thx to http://unix.stackexchange.com/a/122945/99697 for perl alternative to broken --byte-offset in grep 2.5.1 (e.g. in OS X)
|
||||
fileEntryOffset=$(perl -n0777e "print pos()-length('.$fileName') while /.$fileName/g" < "$imageArg")
|
||||
fileEntry=$(dd if="$imageArg" bs=1 count=39 skip=$fileEntryOffset 2> /dev/null | xxd -p | tr -d '\n')
|
||||
# create file entry, then find it
|
||||
$ac -d "$imageArg" "${prodosArgParent}$fileName" 2> /dev/null
|
||||
[[ $isExtFile ]] && ddsrc="if=/dev/zero bs=512 count=1" || ddsrc="if=$prodosArg"
|
||||
dd $ddsrc 2> /dev/null | $ac -p "$imageArg" "${prodosArgParent}$fileName" "$ft" "$auxType" 2> $acmdStdErr
|
||||
# thx to http://unix.stackexchange.com/a/122945/99697 for perl alternative to broken --byte-offset in grep 2.5.1 (e.g. in OS X)
|
||||
fileEntryOffset=$(perl -n0777e "print pos()-length('.$fileName') while /.$fileName/g" < "$imageArg")
|
||||
fileEntry=$(dd if="$imageArg" bs=1 count=39 skip=$fileEntryOffset 2> /dev/null | xxd -p | tr -d '\n')
|
||||
|
||||
if [[ $isExtFile ]]; then
|
||||
extKeyBlockOffset=$(( ( ( $(printf %d 0x"${fileEntry:36:2}") * 256 ) + $(printf %d 0x"${fileEntry:34:2}") * 512 ) ))
|
||||
if [[ $isExtFile ]]; then
|
||||
extKeyBlockOffset=$(( ( ( $(printf %d 0x"${fileEntry:36:2}") * 256 ) + $(printf %d 0x"${fileEntry:34:2}") * 512 ) ))
|
||||
|
||||
# find data fork, copy storage type, key block, block size, length to extended key block mini-entry
|
||||
# then mark as available/deleted
|
||||
dfOffset=$(perl -n0777e "print pos()-length('.$dfName') while /.$dfName/g" < "$imageArg")
|
||||
dfEntry=$(dd if="$imageArg" bs=1 count=39 skip=$dfOffset 2> /dev/null | xxd -p | tr -d '\n')
|
||||
dfStorageType=$(printf %02X $(( $(printf %d 0x${dfEntry:0:2}) >> 4 )) )
|
||||
dfBlocksUsed=$(( ( $(printf %d 0x${dfEntry:40:2}) * 256 ) + $(printf %d 0x${dfEntry:38:2}) ))
|
||||
dfInfo=${dfEntry:34:14}
|
||||
echo -n -e \\x"$dfStorageType"$(sed 's/../\\x&/g' <<< $dfInfo) \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( extKeyBlockOffset+0 )) 2> /dev/null
|
||||
# mark as deleted
|
||||
echo -n -e \\x0${dfEntry:1:1} \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( dfOffset+0 )) 2> /dev/null
|
||||
# find data fork, copy storage type, key block, block size, length to extended key block mini-entry
|
||||
# then mark as available/deleted
|
||||
dfOffset=$(perl -n0777e "print pos()-length('.$dfName') while /.$dfName/g" < "$imageArg")
|
||||
dfEntry=$(dd if="$imageArg" bs=1 count=39 skip=$dfOffset 2> /dev/null | xxd -p | tr -d '\n')
|
||||
dfStorageType=$(printf %02X $(( $(printf %d 0x${dfEntry:0:2}) >> 4 )) )
|
||||
dfBlocksUsed=$(( ( $(printf %d 0x${dfEntry:40:2}) * 256 ) + $(printf %d 0x${dfEntry:38:2}) ))
|
||||
dfInfo=${dfEntry:34:14}
|
||||
echo -n -e \\x"$dfStorageType"$(sed 's/../\\x&/g' <<< $dfInfo) \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( extKeyBlockOffset+0 )) 2> /dev/null
|
||||
# mark as deleted
|
||||
echo -n -e \\x0${dfEntry:1:1} \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( dfOffset+0 )) 2> /dev/null
|
||||
|
||||
# find resource fork, copy storage type, key block, block size, length to extended key block mini-entry
|
||||
# then mark as available/deleted
|
||||
rfOffset=$(perl -n0777e "print pos()-length('.$rfName') while /.$rfName/g" < "$imageArg")
|
||||
rfEntry=$(dd if="$imageArg" bs=1 count=39 skip=$rfOffset 2> /dev/null | xxd -p | tr -d '\n')
|
||||
rfStorageType=$(printf %02X $(( $(printf %d 0x${rfEntry:0:2}) >> 4 )) )
|
||||
rfBlocksUsed=$(( ( $(printf %d 0x${rfEntry:40:2}) * 256 ) + $(printf %d 0x${rfEntry:38:2}) ))
|
||||
rfInfo=${rfEntry:34:14}
|
||||
echo -n -e \\x"$rfStorageType"$(sed 's/../\\x&/g' <<< $rfInfo) \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( extKeyBlockOffset+256 )) 2> /dev/null
|
||||
# mark as deleted
|
||||
echo -n -e \\x0${rfEntry:1:1} \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( rfOffset+0 )) 2> /dev/null
|
||||
# find resource fork, copy storage type, key block, block size, length to extended key block mini-entry
|
||||
# then mark as available/deleted
|
||||
rfOffset=$(perl -n0777e "print pos()-length('.$rfName') while /.$rfName/g" < "$imageArg")
|
||||
rfEntry=$(dd if="$imageArg" bs=1 count=39 skip=$rfOffset 2> /dev/null | xxd -p | tr -d '\n')
|
||||
rfStorageType=$(printf %02X $(( $(printf %d 0x${rfEntry:0:2}) >> 4 )) )
|
||||
rfBlocksUsed=$(( ( $(printf %d 0x${rfEntry:40:2}) * 256 ) + $(printf %d 0x${rfEntry:38:2}) ))
|
||||
rfInfo=${rfEntry:34:14}
|
||||
echo -n -e \\x"$rfStorageType"$(sed 's/../\\x&/g' <<< $rfInfo) \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( extKeyBlockOffset+256 )) 2> /dev/null
|
||||
# mark as deleted
|
||||
echo -n -e \\x0${rfEntry:1:1} \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$(( rfOffset+0 )) 2> /dev/null
|
||||
|
||||
# reduce active file count in directory by two
|
||||
parentDirKeyBlockOffset=$(( ( ( $(printf %d 0x"${fileEntry:76:2}") * 256 ) + $(printf %d 0x"${fileEntry:74:2}") * 512 ) ))
|
||||
fileCountHex=$(dd if="$imageArg" bs=1 count=2 skip=$((parentDirKeyBlockOffset+4+33)) 2> /dev/null | xxd -p)
|
||||
fileCount=$(( ( $(printf %d 0x${fileCountHex:2:2}) * 256 ) + $(printf %d 0x${fileCountHex:0:2}) ))
|
||||
fileCountHex=$(printf %04X $((fileCount - 2)))
|
||||
echo -n -e \\x${fileCountHex:2:2}\\x${fileCountHex:0:2} \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$((parentDirKeyBlockOffset+4+33)) 2> /dev/null
|
||||
# reduce active file count in directory by two
|
||||
parentDirKeyBlockOffset=$(( ( ( $(printf %d 0x"${fileEntry:76:2}") * 256 ) + $(printf %d 0x"${fileEntry:74:2}") * 512 ) ))
|
||||
fileCountHex=$(dd if="$imageArg" bs=1 count=2 skip=$((parentDirKeyBlockOffset+4+33)) 2> /dev/null | xxd -p)
|
||||
fileCount=$(( ( $(printf %d 0x${fileCountHex:2:2}) * 256 ) + $(printf %d 0x${fileCountHex:0:2}) ))
|
||||
fileCountHex=$(printf %04X $((fileCount - 2)))
|
||||
echo -n -e \\x${fileCountHex:2:2}\\x${fileCountHex:0:2} \
|
||||
| dd of="$imageArg" conv=notrunc bs=1 seek=$((parentDirKeyBlockOffset+4+33)) 2> /dev/null
|
||||
|
||||
# update extended file metadata
|
||||
# update extended file metadata
|
||||
|
||||
# storage type (5), name length, name
|
||||
name="${prodosPath##*/}"
|
||||
nameLen=${#name}
|
||||
nameHeader=$(printf %02X $((nameLen + 80)) )
|
||||
nameField=$(echo -n $name | xxd -p | tr -d '\n' | sed -e :a -e 's/^.\{1,29\}$/&00/;ta')
|
||||
# storage type (5), name length, name
|
||||
name="${prodosPath##*/}"
|
||||
nameLen=${#name}
|
||||
nameHeader=$(printf %02X $((nameLen + 80)) )
|
||||
nameField=$(echo -n $name | xxd -p | tr -d '\n' | sed -e :a -e 's/^.\{1,29\}$/&00/;ta')
|
||||
|
||||
# blocks used
|
||||
blocksUsed=$(( dfBlocksUsed + rfBlocksUsed + 1 ))
|
||||
# blocks used
|
||||
blocksUsed=$(( dfBlocksUsed + rfBlocksUsed + 1 ))
|
||||
|
||||
# store updated metadata
|
||||
fileEntry=${nameHeader}${nameField}${fileEntry:32}
|
||||
fi
|
||||
# store updated metadata
|
||||
fileEntry=${nameHeader}${nameField}${fileEntry:32}
|
||||
fi
|
||||
|
||||
# put creation and modified date in file entry
|
||||
fileEntry=${fileEntry:0:48}${cDateTimeHex}${fileEntry:56:10}${mDateTimeHex}${fileEntry:74:4}
|
||||
# put creation and modified date in file entry
|
||||
fileEntry=${fileEntry:0:48}${cDateTimeHex}${fileEntry:56:10}${mDateTimeHex}${fileEntry:74:4}
|
||||
|
||||
# put casemask for mixed case filename in file entry
|
||||
[[ $EX ]] && prodosArg="${prodosArg%#*}"
|
||||
if [[ "${prodosPath##*/}" != "${prodosArg##*/}" ]]; then # mixed case
|
||||
caseMaskDec=32768
|
||||
mixedName="${prodosArg##*/}"
|
||||
[[ $EX ]] && mixedName="${mixedName%#*}"
|
||||
for (( i=0; i<${#mixedName}; i++ )); do
|
||||
[[ "${mixedName:$i:1}" == $(tr [:lower:] [:upper:] <<< "${mixedName:$i:1}") ]] # $? == 0 means uppercase
|
||||
(( caseMaskDec+=$(( $? * (2**(14-i)) )) ))
|
||||
done
|
||||
caseMaskHex=$(printf %04X $caseMaskDec)
|
||||
fileEntry=${fileEntry:0:56}${caseMaskHex:2:2}${caseMaskHex:0:2}${fileEntry:60}
|
||||
fi
|
||||
# put casemask for mixed case filename in file entry
|
||||
[[ $EX ]] && prodosArg="${prodosArg%#*}"
|
||||
if [[ "${prodosPath##*/}" != "${prodosArg##*/}" ]]; then # mixed case
|
||||
caseMaskDec=32768
|
||||
mixedName="${prodosArg##*/}"
|
||||
[[ $EX ]] && mixedName="${mixedName%#*}"
|
||||
for (( i=0; i<${#mixedName}; i++ )); do
|
||||
[[ "${mixedName:$i:1}" == $(tr [:lower:] [:upper:] <<< "${mixedName:$i:1}") ]] # $? == 0 means uppercase
|
||||
(( caseMaskDec+=$(( $? * (2**(14-i)) )) ))
|
||||
done
|
||||
caseMaskHex=$(printf %04X $caseMaskDec)
|
||||
fileEntry=${fileEntry:0:56}${caseMaskHex:2:2}${caseMaskHex:0:2}${fileEntry:60}
|
||||
fi
|
||||
|
||||
# write updated metadata to file entry
|
||||
echo -n -e $(sed 's/../\\x&/g' <<< $fileEntry) | dd of="$imageArg" bs=1 conv=notrunc seek=$fileEntryOffset 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
# write updated metadata to file entry
|
||||
echo -n -e $(sed 's/../\\x&/g' <<< $fileEntry) | dd of="$imageArg" bs=1 conv=notrunc seek=$fileEntryOffset 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
imageArg="$2"
|
||||
$ac "$@" 2> $acmdStdErr
|
||||
imageArg="$2"
|
||||
$ac "$@" 2> $acmdStdErr
|
||||
|
||||
fi
|
||||
|
||||
|
46
setup/adtpro-start.txt
Normal file → Executable file
46
setup/adtpro-start.txt
Normal file → Executable file
@ -1,34 +1,34 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# don't do anything if ADTPro is already running
|
||||
if [[ $(ps aux | grep [A]DTPro) ]]; then
|
||||
|
||||
1&>2 echo "ADTPro server is already running."
|
||||
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
|
||||
# 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
|
||||
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
|
||||
|
152
setup/adtpro.sh.txt
Normal file → Executable file
152
setup/adtpro.sh.txt
Normal file → Executable file
@ -1,15 +1,15 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# 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')
|
||||
# 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
|
||||
# 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.
|
||||
@ -26,9 +26,9 @@
|
||||
# export ADTPRO_HOME=~/myuser/adtpro
|
||||
|
||||
usageExit () {
|
||||
echo "usage:" 1>&2
|
||||
echo "adtpro.sh [headless] [serial|ethernet|audio|localhost] [serialPortName]" 1>&2
|
||||
exit 1
|
||||
echo "usage:" 1>&2
|
||||
echo "adtpro.sh [headless] [serial|ethernet|audio|localhost] [serialPortName]" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
export ADTPRO_HOME=/usr/local/adtpro
|
||||
@ -40,75 +40,75 @@ OS_ARCH=`uname -m`
|
||||
[[ $1 == "headless" ]] && { headless=1; shift; } || headless=
|
||||
|
||||
if [[ $1 && ( $1 != "serial" && $1 != "ethernet" && $1 != "audio" && $1 != "localhost" ) ]]; then
|
||||
usageExit
|
||||
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
|
||||
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/' /usr/local/adtpro/disks/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
|
||||
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/' /usr/local/adtpro/disks/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"
|
||||
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
|
||||
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
|
||||
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
|
||||
export RXTXLIB=lib/rxtx/rxtx-2.2pre2-local/sparc-sun-solaris2.10-32
|
||||
fi
|
||||
|
||||
# Set up the library location.
|
||||
@ -116,29 +116,29 @@ 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
|
||||
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"
|
||||
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..."
|
||||
echo "Starting up on interface $serialPortName. Please wait..."
|
||||
fi
|
||||
if [ -t 0 ]; then
|
||||
sleep 30
|
||||
sleep 30
|
||||
fi
|
||||
|
40
setup/baud.txt
Normal file → Executable file
40
setup/baud.txt
Normal file → Executable file
@ -1,38 +1,38 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
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"
|
||||
gettyFile="/etc/systemd/system/getty.target.wants/usbgetty@.service"
|
||||
elif [[ -f /etc/inittab ]]; then
|
||||
gettyFile="/etc/inittab"
|
||||
gettyFile="/etc/inittab"
|
||||
fi
|
||||
|
||||
if [[ $1 == "-d" ]]; then
|
||||
shift
|
||||
setgetty=1
|
||||
shift
|
||||
setgetty=1
|
||||
else
|
||||
setgetty=
|
||||
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'
|
||||
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
|
||||
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)"
|
||||
|
2088
setup/cppo.txt
Normal file → Executable file
2088
setup/cppo.txt
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
74
setup/dopo.txt
Normal file → Executable file
74
setup/dopo.txt
Normal file → Executable file
@ -1,76 +1,76 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# follows gzip syntax -- acts in place if filename provided, outputs to
|
||||
# stdout with -c, accepts stdin and outputs to stdout if filename is - or absent
|
||||
|
||||
# output to stdout?
|
||||
if [[ "$1" == "-c" ]]; then
|
||||
shift;
|
||||
stdout=1;
|
||||
shift;
|
||||
stdout=1;
|
||||
else
|
||||
stdout=
|
||||
stdout=
|
||||
fi
|
||||
|
||||
# use stdin?
|
||||
if [[ ! $1 || "$1" == "-" ]]; then
|
||||
stdin=1
|
||||
stdout=1
|
||||
stdin=1
|
||||
stdout=1
|
||||
elif [[ $1 && ! -f "$1" ]]; then
|
||||
echo "usage: dopo [-c] [-|140KdiskImageFilename] 1>&2";
|
||||
exit 1;
|
||||
echo "usage: dopo [-c] [-|140KdiskImageFilename] 1>&2";
|
||||
exit 1;
|
||||
else
|
||||
stdin=
|
||||
stdin=
|
||||
fi
|
||||
|
||||
if [[ ! $stdout ]]; then
|
||||
#get filename extension, in lowercase
|
||||
f="$(tr [:upper:] [:lower:] <<< ${1##*.})";
|
||||
#get filename extension, in lowercase
|
||||
f="$(tr [:upper:] [:lower:] <<< ${1##*.})";
|
||||
|
||||
#if it's dsk/do/po, get name without extension
|
||||
[[ "$f" == "dsk" || "$f" == "do" || "$f" == "po" ]] && of="${1%.*}" || of="$1";
|
||||
#if it's dsk/do/po, get name without extension
|
||||
[[ "$f" == "dsk" || "$f" == "do" || "$f" == "po" ]] && of="${1%.*}" || of="$1";
|
||||
|
||||
#if name had .po extension, append .dsk to outfile name, otherwise append .po
|
||||
[[ "$f" == "po" ]] && of="$of.dsk" || of="$of.po"
|
||||
#if name had .po extension, append .dsk to outfile name, otherwise append .po
|
||||
[[ "$f" == "po" ]] && of="$of.dsk" || of="$of.po"
|
||||
|
||||
# set outfile param for dd
|
||||
ofile="$of"
|
||||
# set outfile param for dd
|
||||
ofile="$of"
|
||||
else
|
||||
ofile="/tmp/$$.dopo_out"
|
||||
ofile="/tmp/$$.dopo_out"
|
||||
fi
|
||||
|
||||
if [[ ! $stdin ]]; then
|
||||
# set infile param for dd
|
||||
ifile="$1"
|
||||
# set infile param for dd
|
||||
ifile="$1"
|
||||
elif [[ -t 0 ]]; then
|
||||
echo "usage: dopo [-c] [-|140KdiskImageFilename]" 1>&2; exit 1;
|
||||
echo "usage: dopo [-c] [-|140KdiskImageFilename]" 1>&2; exit 1;
|
||||
else
|
||||
ifile="/tmp/$$.dopo_in"
|
||||
cat > "$ifile"
|
||||
ifile="/tmp/$$.dopo_in"
|
||||
cat > "$ifile"
|
||||
fi
|
||||
|
||||
# verify file is 140K by successfully reading 140K'th byte, and failing to read the one past
|
||||
[[ $(dd if="$ifile" of=/dev/null bs=1 skip=143359 2>&1 | tail -1 | cut -d ' ' -f 1) -ne 1 || $(dd if="$ifile" of=/dev/null bs=1 skip=143360 2>&1 | tail -1 | cut -d ' ' -f 1) -ne 0 ]] && badInput=1 || badInput=
|
||||
|
||||
if [[ $badInput ]]; then
|
||||
if [[ ! $stdin ]]; then
|
||||
echo -n "$1 doesn't appear to be a 140K image. Continue? " 1>&2;
|
||||
read
|
||||
[[ ${REPLY:0:1} == "y" || ${REPLY:0:1} == "Y" ]] || exit 1;
|
||||
else
|
||||
echo "warning: Input file doesn't appear to be a 140K image." 1>&2
|
||||
echo " Output file is likely to be useless." 1>&2
|
||||
fi
|
||||
if [[ ! $stdin ]]; then
|
||||
echo -n "$1 doesn't appear to be a 140K image. Continue? " 1>&2;
|
||||
read
|
||||
[[ ${REPLY:0:1} == "y" || ${REPLY:0:1} == "Y" ]] || exit 1;
|
||||
else
|
||||
echo "warning: Input file doesn't appear to be a 140K image." 1>&2
|
||||
echo " Output file is likely to be useless." 1>&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# for each track
|
||||
for t in {0..34}; do
|
||||
# read each sector in the right sequence to make (or unmake)
|
||||
# valid ProDOS blocks (sector pairs)
|
||||
for s in 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 15; do
|
||||
# copy the sector from the old file to the new one
|
||||
dd if="$ifile" of="$ofile" bs=256 count=1 skip=$(( t*16 + s )) seek=$(( t*16 + (s==0 || s==15 ? s : 15-s) )) 2> /dev/null
|
||||
done
|
||||
# read each sector in the right sequence to make (or unmake)
|
||||
# valid ProDOS blocks (sector pairs)
|
||||
for s in 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 15; do
|
||||
# copy the sector from the old file to the new one
|
||||
dd if="$ifile" of="$ofile" bs=256 count=1 skip=$(( t*16 + s )) seek=$(( t*16 + (s==0 || s==15 ? s : 15-s) )) 2> /dev/null
|
||||
done
|
||||
done
|
||||
|
||||
# remove the old one
|
||||
|
148
setup/dos2pro.txt
Normal file → Executable file
148
setup/dos2pro.txt
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
readcharDec () {
|
||||
# read one character from file & convert to equivalent decimal value
|
||||
@ -8,17 +8,17 @@ readcharDec () {
|
||||
# out: decimal value from 0-255
|
||||
# exit: 8=extraneous arg, 11=missing arg1,
|
||||
# 21=invalid arg1, 22=invalid arg2
|
||||
[[ $1 ]] || return 11
|
||||
[[ $3 ]] && return 8
|
||||
[[ -f $1 ]] || return 21
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) \
|
||||
&& ( $2 -ge 0 ) ]] || return 22; }
|
||||
# args are valid
|
||||
charX="$(dd if="$1" bs=1 skip=$(($2)) \
|
||||
count=1 2> /dev/null; echo -n X)"
|
||||
[[ ${#charX} -gt 1 ]] || { echo -n 0; return 0; }
|
||||
echo -n "${charX:0:1}" | od -t u1 | \
|
||||
head -1 | sed 's/[0\ ]*//' | tr -d ' \n'
|
||||
[[ $1 ]] || return 11
|
||||
[[ $3 ]] && return 8
|
||||
[[ -f $1 ]] || return 21
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) \
|
||||
&& ( $2 -ge 0 ) ]] || return 22; }
|
||||
# args are valid
|
||||
charX="$(dd if="$1" bs=1 skip=$(($2)) \
|
||||
count=1 2> /dev/null; echo -n X)"
|
||||
[[ ${#charX} -gt 1 ]] || { echo -n 0; return 0; }
|
||||
echo -n "${charX:0:1}" | od -t u1 | \
|
||||
head -1 | sed 's/[0\ ]*//' | tr -d ' \n'
|
||||
}
|
||||
|
||||
readcharHex () {
|
||||
@ -28,31 +28,31 @@ readcharHex () {
|
||||
# out: two-digit hex value from 00-FF
|
||||
# exit: 8=extraneous arg, 11=missing arg1,
|
||||
# 21=invalid arg1, 22=invalid arg2
|
||||
[[ $1 ]] || return 11
|
||||
[[ $3 ]] && return 8
|
||||
[[ -f $1 ]] || return 21
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) \
|
||||
&& ( $2 -ge 0 ) ]] || return 22; }
|
||||
# args are valid
|
||||
charX="$(dd if="$1" bs=1 skip=$(($2)) \
|
||||
count=1 2> /dev/null; echo -n X)"
|
||||
[[ ${#charX} -gt 1 ]] || { echo -n "00"; return 0; }
|
||||
printf %02X $(echo -n "${charX:0:1}" | od -t u1 | \
|
||||
head -1 | sed 's/[0\ ]*//' | tr -d ' \n')
|
||||
[[ $1 ]] || return 11
|
||||
[[ $3 ]] && return 8
|
||||
[[ -f $1 ]] || return 21
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) \
|
||||
&& ( $2 -ge 0 ) ]] || return 22; }
|
||||
# args are valid
|
||||
charX="$(dd if="$1" bs=1 skip=$(($2)) \
|
||||
count=1 2> /dev/null; echo -n X)"
|
||||
[[ ${#charX} -gt 1 ]] || { echo -n "00"; return 0; }
|
||||
printf %02X $(echo -n "${charX:0:1}" | od -t u1 | \
|
||||
head -1 | sed 's/[0\ ]*//' | tr -d ' \n')
|
||||
}
|
||||
|
||||
### start
|
||||
|
||||
usage () {
|
||||
echo "Usage:"
|
||||
echo "all files: dos2pro dosImageName"
|
||||
echo "one file : dos2pro dosImageName DOSFILE"
|
||||
echo "notes:"
|
||||
echo " Wildcard matching (*) is not supported."
|
||||
echo " Illegal prodos characters will be made into periods, and names"
|
||||
echo " will be truncated at 15 characters and possibly overwrite"
|
||||
echo " other files if they match a previous name conversion."
|
||||
exit 1
|
||||
echo "Usage:"
|
||||
echo "all files: dos2pro dosImageName"
|
||||
echo "one file : dos2pro dosImageName DOSFILE"
|
||||
echo "notes:"
|
||||
echo " Wildcard matching (*) is not supported."
|
||||
echo " Illegal prodos characters will be made into periods, and names"
|
||||
echo " will be truncated at 15 characters and possibly overwrite"
|
||||
echo " other files if they match a previous name conversion."
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ $1 == "-h" || $1 == "--help" || ! $1 || ! -f "$1" ]] && usage
|
||||
@ -64,62 +64,62 @@ dosImageBasename=$(basename "$dosImage")
|
||||
proImage="${dosImageBasename%.*}_prodos.po"
|
||||
|
||||
if [[ ! -f "$proImage" ]]; then
|
||||
echo "Creating $proImage..."
|
||||
mkpo -b 280 "$proImage"
|
||||
echo "Creating $proImage..."
|
||||
mkpo -b 280 "$proImage"
|
||||
else
|
||||
echo "Found $proImage..."
|
||||
echo "Found $proImage..."
|
||||
fi
|
||||
|
||||
if [[ ! $(acmd -i "$dosImage" 2> /dev/null | grep "Disk Format: DOS 3.3") ]]; then
|
||||
echo "The file '$dosImage' doesn't appear to be a DOS 3.3 disk image."
|
||||
exit 2
|
||||
echo "The file '$dosImage' doesn't appear to be a DOS 3.3 disk image."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
dosLines=$(acmd -ll "$dosImage")
|
||||
|
||||
IFS=''
|
||||
while read thisLine; do
|
||||
if [[ ${thisLine:0:2} == "* " || ${thisLine:0:2} == " " ]]; then
|
||||
dosName=$(cut -c 5- <<< $thisLine | rev | sed 's/^[^ ]* [^ ]* [^ ]* [^ ]* [^ ]* \(.*$\)/\1/' | rev)
|
||||
if [[ ! $fileName || "$fileName" == "$dosName" ]]; then
|
||||
if [[ ${thisLine:0:2} == "* " || ${thisLine:0:2} == " " ]]; then
|
||||
dosName=$(cut -c 5- <<< $thisLine | rev | sed 's/^[^ ]* [^ ]* [^ ]* [^ ]* [^ ]* \(.*$\)/\1/' | rev)
|
||||
if [[ ! $fileName || "$fileName" == "$dosName" ]]; then
|
||||
|
||||
dosType=$(cut -c 3 <<< $thisLine)
|
||||
if [[ $dosType == "A" ]]; then
|
||||
proType="BAS"
|
||||
binAddr="0801"
|
||||
elif [[ $dosType == "I" ]]; then
|
||||
proType="INT"
|
||||
elif [[ $dosType == "T" ]]; then
|
||||
proType="TXT"
|
||||
elif [[ $dosType == "B" ]]; then
|
||||
proType="BIN"
|
||||
sector=$(rev <<< $thisLine | cut -f2 -d ' ' | rev | cut -c 2-)
|
||||
track=$(rev <<< $thisLine | cut -f3 -d ' ' | rev | cut -c 2-)
|
||||
offset=$(( (track * 16 + sector) * 256 + 12 ))
|
||||
track=$(readcharDec "$dosImage" $offset)
|
||||
sector=$(readcharDec "$dosImage" $((offset+1)))
|
||||
offset=$(( (track * 16 + sector) * 256 ))
|
||||
binAddr=$(readcharHex "$dosImage" $((offset+1)))$(readcharHex "$dosImage" $offset)
|
||||
else
|
||||
echo "Error: Unknown DOS 3.3 file type."
|
||||
exit 2
|
||||
fi
|
||||
dosType=$(cut -c 3 <<< $thisLine)
|
||||
if [[ $dosType == "A" ]]; then
|
||||
proType="BAS"
|
||||
binAddr="0801"
|
||||
elif [[ $dosType == "I" ]]; then
|
||||
proType="INT"
|
||||
elif [[ $dosType == "T" ]]; then
|
||||
proType="TXT"
|
||||
elif [[ $dosType == "B" ]]; then
|
||||
proType="BIN"
|
||||
sector=$(rev <<< $thisLine | cut -f2 -d ' ' | rev | cut -c 2-)
|
||||
track=$(rev <<< $thisLine | cut -f3 -d ' ' | rev | cut -c 2-)
|
||||
offset=$(( (track * 16 + sector) * 256 + 12 ))
|
||||
track=$(readcharDec "$dosImage" $offset)
|
||||
sector=$(readcharDec "$dosImage" $((offset+1)))
|
||||
offset=$(( (track * 16 + sector) * 256 ))
|
||||
binAddr=$(readcharHex "$dosImage" $((offset+1)))$(readcharHex "$dosImage" $offset)
|
||||
else
|
||||
echo "Error: Unknown DOS 3.3 file type."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
proName=$(sed 's/^[^A-Za-z]/A/' <<< $dosName | sed 's/[^A-Za-z0-9\.]/./g')
|
||||
proName=$(sed 's/^[^A-Za-z]/A/' <<< $dosName | sed 's/[^A-Za-z0-9\.]/./g')
|
||||
|
||||
auxType=
|
||||
[[ $binAddr ]] && auxType="\$$binAddr"
|
||||
echo "Copying '$dosName' to '$proName'"
|
||||
acmd -g "$dosImage" "$dosName" - | acmd -p "$proImage" "$proName" "$proType" "$auxType"
|
||||
filesCopied=1
|
||||
fi
|
||||
fi
|
||||
auxType=
|
||||
[[ $binAddr ]] && auxType="\$$binAddr"
|
||||
echo "Copying '$dosName' to '$proName'"
|
||||
acmd -g "$dosImage" "$dosName" - | acmd -p "$proImage" "$proName" "$proType" "$auxType"
|
||||
filesCopied=1
|
||||
fi
|
||||
fi
|
||||
done <<< $dosLines
|
||||
|
||||
if [[ ! $filesCopied ]]; then
|
||||
if [[ $fileName ]]; then
|
||||
echo "File '$fileName' not found on DOS 3.3 disk image."
|
||||
else
|
||||
echo "No files copied."
|
||||
fi
|
||||
if [[ $fileName ]]; then
|
||||
echo "File '$fileName' not found on DOS 3.3 disk image."
|
||||
else
|
||||
echo "No files copied."
|
||||
fi
|
||||
fi
|
||||
|
6
setup/gsport-setup-shell.txt
Normal file → Executable file
6
setup/gsport-setup-shell.txt
Normal file → Executable file
@ -1,9 +1,9 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
wget -qO /tmp/gsport-setup https://raw.githubusercontent.com/RasppleII/a2cloud/master/setup/gsport-setup.txt
|
||||
if [[ $(wc -c /tmp/gsport-setup | grep '^0 ') ]]; then
|
||||
echo "Please connect to the internet to set up GSport."
|
||||
echo "Please connect to the internet to set up GSport."
|
||||
else
|
||||
source /tmp/gsport-setup "$@"
|
||||
source /tmp/gsport-setup "$@"
|
||||
fi
|
||||
|
File diff suppressed because it is too large
Load Diff
176
setup/gsport.txt
Normal file → Executable file
176
setup/gsport.txt
Normal file → Executable file
@ -1,105 +1,105 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
if [[ -f /tmp/no-gsport ]]; then
|
||||
echo
|
||||
echo "Your system needs to be rebooted before you can use GSport."
|
||||
echo -n "Do you want to reboot now? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
sudo shutdown -r now
|
||||
fi
|
||||
exit 0
|
||||
echo
|
||||
echo "Your system needs to be rebooted before you can use GSport."
|
||||
echo -n "Do you want to reboot now? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
sudo shutdown -r now
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ ( $(grep USB <<< $myTTY) || $(grep AMA <<< $myTTY) || $SSH_CLIENT || $REMOTEHOST ) && ! $DISPLAY ]]; then
|
||||
echo "Please run GSport on the console, or in an X Window."
|
||||
echo "Please run GSport on the console, or in an X Window."
|
||||
else
|
||||
|
||||
if [[ -f /usr/local/lib/ROM ]]; then
|
||||
if [[ ! $(grep snd-pcm-oss /etc/modules) ]]; then
|
||||
echo "Configuring GSport sound..."
|
||||
echo "snd-pcm-oss" | sudo tee -a /etc/modules > /dev/null
|
||||
[[ ! $(lsmod | grep snd_pcm_oss) ]] && sudo modprobe snd-pcm-oss
|
||||
fi
|
||||
if [[ -f /usr/local/lib/ROM ]]; then
|
||||
if [[ ! $(grep snd-pcm-oss /etc/modules) ]]; then
|
||||
echo "Configuring GSport sound..."
|
||||
echo "snd-pcm-oss" | sudo tee -a /etc/modules > /dev/null
|
||||
[[ ! $(lsmod | grep snd_pcm_oss) ]] && sudo modprobe snd-pcm-oss
|
||||
fi
|
||||
|
||||
if [[ ! $(dpkg -l xfonts-base 2> /dev/null | grep '^ii') ]]; then
|
||||
echo "Configuring GSport fonts..."
|
||||
sudo apt-get -y update
|
||||
touch /tmp/updated
|
||||
sudo apt-get -y install xfonts-base &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
fi
|
||||
if [[ ! $(dpkg -l xfonts-base 2> /dev/null | grep '^ii') ]]; then
|
||||
echo "Configuring GSport fonts..."
|
||||
sudo apt-get -y update
|
||||
touch /tmp/updated
|
||||
sudo apt-get -y install xfonts-base &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
fi
|
||||
|
||||
if [[ ! $(dpkg -l libpcap0.8-dev 2> /dev/null | grep '^ii') ]]; then
|
||||
echo "Configuring GSport networking..."
|
||||
[[ ! -f /tmp/updated ]] && sudo apt-get -y update
|
||||
sudo apt-get -y install libpcap0.8-dev &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
fi
|
||||
if [[ ! $(dpkg -l libpcap0.8-dev 2> /dev/null | grep '^ii') ]]; then
|
||||
echo "Configuring GSport networking..."
|
||||
[[ ! -f /tmp/updated ]] && sudo apt-get -y update
|
||||
sudo apt-get -y install libpcap0.8-dev &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
fi
|
||||
|
||||
rm /tmp/updated &> /dev/null
|
||||
else
|
||||
gsport-setup
|
||||
[[ $? -ne 0 ]] && exit 1
|
||||
fi
|
||||
rm /tmp/updated &> /dev/null
|
||||
else
|
||||
gsport-setup
|
||||
[[ $? -ne 0 ]] && exit 1
|
||||
fi
|
||||
|
||||
displayOK=
|
||||
if [[ $DISPLAY ]]; then # X Window
|
||||
displayOK=1
|
||||
else # console/framebuffer
|
||||
if [[ ! -f /usr/local/etc/gsportconsolewarningoff ]] && { dpkg -l | grep -q -i virtualbox; }; then
|
||||
echo
|
||||
echo "If you have difficulties moving the mouse in GS/OS, choose"
|
||||
echo "'Disable Mouse Integration' from the Machine menu. To free the mouse"
|
||||
echo "from the virtual machine, press the Host key (shown in the lower right"
|
||||
echo "corner of the virtual machine window)."
|
||||
echo
|
||||
echo "Press alt-F4 to exit GSport."
|
||||
echo
|
||||
echo "Press return to continue,"
|
||||
echo -n " or type 'OK' if you want to stop seeing this message: "
|
||||
read
|
||||
if [[ $REPLY == "ok" || $REPLY == "ok" || $REPLY == "Ok" ]]; then
|
||||
sudo touch /usr/local/etc/gsportconsolewarningoff
|
||||
fi
|
||||
fi
|
||||
displayOK=
|
||||
if [[ $DISPLAY ]]; then # X Window
|
||||
displayOK=1
|
||||
else # console/framebuffer
|
||||
if [[ ! -f /usr/local/etc/gsportconsolewarningoff ]] && { dpkg -l | grep -q -i virtualbox; }; then
|
||||
echo
|
||||
echo "If you have difficulties moving the mouse in GS/OS, choose"
|
||||
echo "'Disable Mouse Integration' from the Machine menu. To free the mouse"
|
||||
echo "from the virtual machine, press the Host key (shown in the lower right"
|
||||
echo "corner of the virtual machine window)."
|
||||
echo
|
||||
echo "Press alt-F4 to exit GSport."
|
||||
echo
|
||||
echo "Press return to continue,"
|
||||
echo -n " or type 'OK' if you want to stop seeing this message: "
|
||||
read
|
||||
if [[ $REPLY == "ok" || $REPLY == "ok" || $REPLY == "Ok" ]]; then
|
||||
sudo touch /usr/local/etc/gsportconsolewarningoff
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! $(grep 'input' <<< $(groups) ) ]]; then
|
||||
sudo groupadd input &> /dev/null
|
||||
sudo usermod -a -G input $USER
|
||||
echo 'SUBSYSTEM=="input", GROUP="input", MODE="0660"' | sudo tee /etc/udev/rules.d/99-input.rules > /dev/null
|
||||
touch /tmp/gsport-consolesetup
|
||||
fi
|
||||
if [[ ! $(grep 'input' <<< $(groups) ) ]]; then
|
||||
sudo groupadd input &> /dev/null
|
||||
sudo usermod -a -G input $USER
|
||||
echo 'SUBSYSTEM=="input", GROUP="input", MODE="0660"' | sudo tee /etc/udev/rules.d/99-input.rules > /dev/null
|
||||
touch /tmp/gsport-consolesetup
|
||||
fi
|
||||
|
||||
if [[ -c /dev/fb0 ]]; then
|
||||
[[ ! -f /tmp/gsport-consolesetup ]] && displayOK=1
|
||||
else
|
||||
if [[ -f /etc/default/grub ]]; then
|
||||
if [[ ! $(grep 'GRUB_GFXPAYLOAD_LINUX' /etc/default/grub) ]]; then
|
||||
echo "Preparing GSport for console use..."
|
||||
sudo sed -i 's/^\(GRUB_CMDLINE_LINUX=.*\)$/\1\nGRUB_GFXPAYLOAD_LINUX=640x480/' /etc/default/grub
|
||||
sudo update-grub &> /dev/null
|
||||
touch /tmp/gsport-consolesetup
|
||||
fi
|
||||
else
|
||||
echo "No framebuffer available. Please run GSport in an X window."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ -c /dev/fb0 ]]; then
|
||||
[[ ! -f /tmp/gsport-consolesetup ]] && displayOK=1
|
||||
else
|
||||
if [[ -f /etc/default/grub ]]; then
|
||||
if [[ ! $(grep 'GRUB_GFXPAYLOAD_LINUX' /etc/default/grub) ]]; then
|
||||
echo "Preparing GSport for console use..."
|
||||
sudo sed -i 's/^\(GRUB_CMDLINE_LINUX=.*\)$/\1\nGRUB_GFXPAYLOAD_LINUX=640x480/' /etc/default/grub
|
||||
sudo update-grub &> /dev/null
|
||||
touch /tmp/gsport-consolesetup
|
||||
fi
|
||||
else
|
||||
echo "No framebuffer available. Please run GSport in an X window."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! $DISPLAY && -f /tmp/gsport-consolesetup ]]; then
|
||||
echo "GSport will be ready for console use after you restart your system."
|
||||
echo "You can restart now by typing 'system-restart'."
|
||||
elif [[ $displayOK ]]; then
|
||||
if [[ $(xdpyinfo 2> /dev/null) ]]; then
|
||||
exec /usr/local/bin/gsportx
|
||||
else
|
||||
exec /usr/local/bin/gsportfb
|
||||
fi
|
||||
else
|
||||
echo "GSport has a problem. Please try updating A2CLOUD by"
|
||||
echo "typing 'a2cloud-setup'."
|
||||
fi
|
||||
if [[ ! $DISPLAY && -f /tmp/gsport-consolesetup ]]; then
|
||||
echo "GSport will be ready for console use after you restart your system."
|
||||
echo "You can restart now by typing 'system-restart'."
|
||||
elif [[ $displayOK ]]; then
|
||||
if [[ $(xdpyinfo 2> /dev/null) ]]; then
|
||||
exec /usr/local/bin/gsportx
|
||||
else
|
||||
exec /usr/local/bin/gsportfb
|
||||
fi
|
||||
else
|
||||
echo "GSport has a problem. Please try updating A2CLOUD by"
|
||||
echo "typing 'a2cloud-setup'."
|
||||
fi
|
||||
|
||||
fi
|
||||
|
86
setup/linapple.txt
Normal file → Executable file
86
setup/linapple.txt
Normal file → Executable file
@ -1,53 +1,53 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
if [[ ( $(grep USB <<< $myTTY) || $(grep AMA <<< $myTTY) || $SSH_CLIENT || $REMOTEHOST ) && ! $DISPLAY ]]; then
|
||||
echo "Please run LinApple on the console, or in an X Window."
|
||||
echo "Please run LinApple on the console, or in an X Window."
|
||||
else
|
||||
if [[ $(dpkg -l libsdl1.2debian libcurl3 zlib1g libzip2 2> /dev/null | grep ^ii | wc -l) -ne 4 ]]; then
|
||||
echo "Configuring LinApple libraries (this may take a moment)..."
|
||||
sudo apt-get -y update &> /dev/null
|
||||
sudo apt-get -y install libsdl1.2debian libcurl3 zlib1g libzip2 &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
fi
|
||||
if [[ $(dpkg -l libsdl1.2debian libcurl3 zlib1g libzip2 2> /dev/null | grep ^ii | wc -l) -ne 4 ]]; then
|
||||
echo "Configuring LinApple libraries (this may take a moment)..."
|
||||
sudo apt-get -y update &> /dev/null
|
||||
sudo apt-get -y install libsdl1.2debian libcurl3 zlib1g libzip2 &> /dev/null
|
||||
sudo apt-get -y clean
|
||||
fi
|
||||
|
||||
linappleOk=
|
||||
linappleOk=
|
||||
|
||||
if [[ $DISPLAY ]]; then # X Window
|
||||
linappleOk=1
|
||||
else # console/framebuffer
|
||||
if [[ ! -f /tmp/linapple-consolesetup && ! $(grep 'input' <<< $(groups) ) ]]; then
|
||||
sudo groupadd input &> /dev/null
|
||||
sudo usermod -a -G input $USER
|
||||
echo 'SUBSYSTEM=="input", GROUP="input", MODE="0660"' | sudo tee /etc/udev/rules.d/99-input.rules > /dev/null
|
||||
touch /tmp/linapple-consolesetup
|
||||
fi
|
||||
if [[ $DISPLAY ]]; then # X Window
|
||||
linappleOk=1
|
||||
else # console/framebuffer
|
||||
if [[ ! -f /tmp/linapple-consolesetup && ! $(grep 'input' <<< $(groups) ) ]]; then
|
||||
sudo groupadd input &> /dev/null
|
||||
sudo usermod -a -G input $USER
|
||||
echo 'SUBSYSTEM=="input", GROUP="input", MODE="0660"' | sudo tee /etc/udev/rules.d/99-input.rules > /dev/null
|
||||
touch /tmp/linapple-consolesetup
|
||||
fi
|
||||
|
||||
if [[ -c /dev/fb0 ]]; then
|
||||
[[ ! -f /tmp/linapple-consolesetup ]] && linappleOk=1
|
||||
else
|
||||
if [[ -f /etc/default/grub ]]; then
|
||||
if [[ ! $(grep 'GRUB_GFXPAYLOAD_LINUX' /etc/default/grub) ]]; then
|
||||
echo "Preparing LinApple for console use..."
|
||||
sudo sed -i 's/^\(GRUB_CMDLINE_LINUX=.*\)$/\1\nGRUB_GFXPAYLOAD_LINUX=640x480/' /etc/default/grub
|
||||
sudo update-grub &> /dev/null
|
||||
touch /tmp/linapple-consolesetup
|
||||
fi
|
||||
else
|
||||
echo "No framebuffer available. Please run LinApple in an X window."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ -c /dev/fb0 ]]; then
|
||||
[[ ! -f /tmp/linapple-consolesetup ]] && linappleOk=1
|
||||
else
|
||||
if [[ -f /etc/default/grub ]]; then
|
||||
if [[ ! $(grep 'GRUB_GFXPAYLOAD_LINUX' /etc/default/grub) ]]; then
|
||||
echo "Preparing LinApple for console use..."
|
||||
sudo sed -i 's/^\(GRUB_CMDLINE_LINUX=.*\)$/\1\nGRUB_GFXPAYLOAD_LINUX=640x480/' /etc/default/grub
|
||||
sudo update-grub &> /dev/null
|
||||
touch /tmp/linapple-consolesetup
|
||||
fi
|
||||
else
|
||||
echo "No framebuffer available. Please run LinApple in an X window."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! $DISPLAY && -f /tmp/linapple-consolesetup ]]; then
|
||||
echo "LinApple will be ready for console use after you restart your system."
|
||||
echo "You can restart now by typing 'system-restart'."
|
||||
elif [[ $linappleOk ]]; then
|
||||
cd /usr/local/linapple
|
||||
./linapple
|
||||
else
|
||||
echo "LinApple has a problem. Please try updating A2CLOUD by"
|
||||
echo "typing 'a2cloud-setup'."
|
||||
fi
|
||||
if [[ ! $DISPLAY && -f /tmp/linapple-consolesetup ]]; then
|
||||
echo "LinApple will be ready for console use after you restart your system."
|
||||
echo "You can restart now by typing 'system-restart'."
|
||||
elif [[ $linappleOk ]]; then
|
||||
cd /usr/local/linapple
|
||||
./linapple
|
||||
else
|
||||
echo "LinApple has a problem. Please try updating A2CLOUD by"
|
||||
echo "typing 'a2cloud-setup'."
|
||||
fi
|
||||
|
||||
fi
|
||||
|
210
setup/mkpo.txt
Normal file → Executable file
210
setup/mkpo.txt
Normal file → Executable file
@ -1,50 +1,50 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# ID-bashByter routines
|
||||
|
||||
function binToDec ()
|
||||
{
|
||||
dec=0;
|
||||
bits=$1;
|
||||
while (( ${#bits} < 8 )); do
|
||||
bits="0$bits";
|
||||
done;
|
||||
for n in {0..7};
|
||||
do
|
||||
(( dec+=( ${bits:$n:1} * ( 2**(7-$n) ) ) ));
|
||||
done;
|
||||
echo -n $dec
|
||||
dec=0;
|
||||
bits=$1;
|
||||
while (( ${#bits} < 8 )); do
|
||||
bits="0$bits";
|
||||
done;
|
||||
for n in {0..7};
|
||||
do
|
||||
(( dec+=( ${bits:$n:1} * ( 2**(7-$n) ) ) ));
|
||||
done;
|
||||
echo -n $dec
|
||||
};
|
||||
|
||||
function writecharDec ()
|
||||
{
|
||||
[[ -n $1 ]] || return 11;
|
||||
[[ -n $2 ]] || return 12;
|
||||
[[ -n $3 ]] || return 13;
|
||||
[[ -n $4 ]] && return 8;
|
||||
[[ ( $(printf %d "$2" 2> /dev/null) == $2 ) && ( $2 -ge 0 ) ]] || return 22;
|
||||
[[ ( $(printf %d "$3" 2> /dev/null) == $3 ) && ( $3 -ge 0 ) && ( $3 -lt 255 ) ]] || return 23;
|
||||
echo -n -e "\x$(printf %02X "$3")" | dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
[[ -n $1 ]] || return 11;
|
||||
[[ -n $2 ]] || return 12;
|
||||
[[ -n $3 ]] || return 13;
|
||||
[[ -n $4 ]] && return 8;
|
||||
[[ ( $(printf %d "$2" 2> /dev/null) == $2 ) && ( $2 -ge 0 ) ]] || return 22;
|
||||
[[ ( $(printf %d "$3" 2> /dev/null) == $3 ) && ( $3 -ge 0 ) && ( $3 -lt 255 ) ]] || return 23;
|
||||
echo -n -e "\x$(printf %02X "$3")" | dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
};
|
||||
|
||||
function writecharsHex ()
|
||||
{
|
||||
[[ -n $1 ]] || return 11;
|
||||
[[ -n $2 ]] || return 12;
|
||||
[[ -n $3 ]] || return 13;
|
||||
[[ -n $4 ]] && return 8;
|
||||
[[ ( $(printf %d "$2" 2> /dev/null) == $2 ) && ( $2 -ge 0 ) ]] || return 22;
|
||||
p=0;
|
||||
offset=$2;
|
||||
len=${#3};
|
||||
while (( p < len )); do
|
||||
outByte=${3:$p:2};
|
||||
[[ $(printf %02X "0x$outByte" 2> /dev/null) == $(echo -n "$outByte" | tr [a-z] [A-Z]) ]] || return 23;
|
||||
echo -n -e "\x$outByte" | dd of="$1" bs=1 seek=$offset conv=notrunc 2> /dev/null;
|
||||
(( p += 3 ));
|
||||
(( offset++ ));
|
||||
done
|
||||
[[ -n $1 ]] || return 11;
|
||||
[[ -n $2 ]] || return 12;
|
||||
[[ -n $3 ]] || return 13;
|
||||
[[ -n $4 ]] && return 8;
|
||||
[[ ( $(printf %d "$2" 2> /dev/null) == $2 ) && ( $2 -ge 0 ) ]] || return 22;
|
||||
p=0;
|
||||
offset=$2;
|
||||
len=${#3};
|
||||
while (( p < len )); do
|
||||
outByte=${3:$p:2};
|
||||
[[ $(printf %02X "0x$outByte" 2> /dev/null) == $(echo -n "$outByte" | tr [a-z] [A-Z]) ]] || return 23;
|
||||
echo -n -e "\x$outByte" | dd of="$1" bs=1 seek=$offset conv=notrunc 2> /dev/null;
|
||||
(( p += 3 ));
|
||||
(( offset++ ));
|
||||
done
|
||||
};
|
||||
|
||||
# mkpo
|
||||
@ -55,9 +55,9 @@ function writecharsHex ()
|
||||
[[ ! -d "$adtPath" ]] && { echo "AppleCommander not found."; exit 1; }
|
||||
|
||||
if [[ $1 == "-b" ]]; then
|
||||
totalBlocks="$2"
|
||||
shift
|
||||
shift
|
||||
totalBlocks="$2"
|
||||
shift
|
||||
shift
|
||||
fi
|
||||
|
||||
[[ -f $1 ]] && { echo "Image '$1' already exists."; exit 1; }
|
||||
@ -66,7 +66,7 @@ fi
|
||||
# test ProDOS name legitimacy
|
||||
prodosVolName=$(tr [:lower:] [:upper:] <<< $prodosVolName )
|
||||
if [[ ${#prodosVolName} -gt 15 || ! $(grep ^[A-Z][0-9A-Z\.]*$ <<< $prodosVolName) ]]; then
|
||||
echo "Invalid ProDOS name: $prodosVolName"; exit 1;
|
||||
echo "Invalid ProDOS name: $prodosVolName"; exit 1;
|
||||
fi
|
||||
|
||||
# see if nulib2 is available; if so, acmd -convert will create image
|
||||
@ -74,88 +74,88 @@ fi
|
||||
nulib2 &> /dev/null
|
||||
[[ $? == 2 ]] && nulib2=1 || nulib2=
|
||||
if [[ $nulib2 ]]; then
|
||||
if [[ $totalBlocks ]]; then
|
||||
imageBlocks="$totalBlocks"
|
||||
else
|
||||
if [[ $(tr [:upper:] [:lower:] <<< "${1##*.}") == "dsk" ]]; then
|
||||
imageBlocks=280
|
||||
else
|
||||
imageBlocks=1600
|
||||
fi
|
||||
fi
|
||||
rm /tmp/blank.shk &> /dev/null
|
||||
orig_dir="$PWD"
|
||||
cd /tmp
|
||||
rm blank.shk EMPTY &> /dev/null
|
||||
touch EMPTY
|
||||
nulib2 -a blank.shk EMPTY &> /dev/null
|
||||
cd "$orig_dir"
|
||||
acmd -convert /tmp/blank.shk "$1" $imageBlocks
|
||||
acmd -d "$1" EMPTY
|
||||
rm /tmp/blank.shk /tmp/EMPTY
|
||||
acmd -n "$1" "$prodosVolName"
|
||||
if [[ $totalBlocks ]]; then
|
||||
imageBlocks="$totalBlocks"
|
||||
else
|
||||
if [[ $(tr [:upper:] [:lower:] <<< "${1##*.}") == "dsk" ]]; then
|
||||
imageBlocks=280
|
||||
else
|
||||
imageBlocks=1600
|
||||
fi
|
||||
fi
|
||||
rm /tmp/blank.shk &> /dev/null
|
||||
orig_dir="$PWD"
|
||||
cd /tmp
|
||||
rm blank.shk EMPTY &> /dev/null
|
||||
touch EMPTY
|
||||
nulib2 -a blank.shk EMPTY &> /dev/null
|
||||
cd "$orig_dir"
|
||||
acmd -convert /tmp/blank.shk "$1" $imageBlocks
|
||||
acmd -d "$1" EMPTY
|
||||
rm /tmp/blank.shk /tmp/EMPTY
|
||||
acmd -n "$1" "$prodosVolName"
|
||||
else
|
||||
# make the disk image without converting archive
|
||||
if [[ $totalBlocks || $(tr [:upper:] [:lower:] <<< "${1##*.}") == "dsk" ]]; then
|
||||
acmd -pro140 "$1" $prodosVolName;
|
||||
else
|
||||
acmd -pro800 "$1" $prodosVolName;
|
||||
fi
|
||||
# make the disk image without converting archive
|
||||
if [[ $totalBlocks || $(tr [:upper:] [:lower:] <<< "${1##*.}") == "dsk" ]]; then
|
||||
acmd -pro140 "$1" $prodosVolName;
|
||||
else
|
||||
acmd -pro800 "$1" $prodosVolName;
|
||||
fi
|
||||
fi
|
||||
|
||||
# make the disk bootable
|
||||
if [ -f "$adtPath"/disks/ADTPRO*PO ]; then
|
||||
dd bs=512 count=1 of="$1" conv=notrunc < "$adtPath"/disks/ADTPRO*PO 2> /dev/null
|
||||
dd bs=512 count=1 of="$1" conv=notrunc < "$adtPath"/disks/ADTPRO*PO 2> /dev/null
|
||||
fi
|
||||
|
||||
# change .DSK to DOS-ordered
|
||||
if [[ ! $totalBlocks && $(tr [:upper:] [:lower:] <<< "${1##*.}") == "dsk" ]]; then
|
||||
mv "$1" "$1".tmp
|
||||
for t in {0..34}; do
|
||||
for s in 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 15; do
|
||||
dd bs=256 count=1 if="$1".tmp of="$1" skip=$(( $t*16 + $s )) seek=$(( $t*16 + ( $s==0||$s==15 ? $s : 15-$s ) )) 2> /dev/null;
|
||||
done;
|
||||
done
|
||||
rm "$1".tmp
|
||||
mv "$1" "$1".tmp
|
||||
for t in {0..34}; do
|
||||
for s in 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 15; do
|
||||
dd bs=256 count=1 if="$1".tmp of="$1" skip=$(( $t*16 + $s )) seek=$(( $t*16 + ( $s==0||$s==15 ? $s : 15-$s ) )) 2> /dev/null;
|
||||
done;
|
||||
done
|
||||
rm "$1".tmp
|
||||
fi
|
||||
|
||||
# if nulib2 isn't available, patch the disk image to use specified block size
|
||||
if [[ ! $nulib2 && $totalBlocks ]]; then
|
||||
# change total block count
|
||||
bcHex=$(printf "%04X" $totalBlocks);
|
||||
writecharsHex "$1" 1065 "${bcHex:2:2}.${bcHex:0:2}";
|
||||
# change total block count
|
||||
bcHex=$(printf "%04X" $totalBlocks);
|
||||
writecharsHex "$1" 1065 "${bcHex:2:2}.${bcHex:0:2}";
|
||||
|
||||
# fix FSB
|
||||
dd if=/dev/zero of="$1" bs=512 seek=280 count=$(( $totalBlocks - 280 )) 2> /dev/null;
|
||||
dd if="$1" of="$1" bs=1 skip=3073 seek=3107 count=$(( ($totalBlocks / 8) - 35 )) conv=notrunc 2> /dev/null;
|
||||
bits=$(( $totalBlocks % 8 ));
|
||||
if (( bits > 0 )); then
|
||||
usedString="00000000";
|
||||
freeString=;
|
||||
for ((b=0; b<$bits; b++))
|
||||
do
|
||||
freeString=$freeString"1";
|
||||
done;
|
||||
binString=$freeString${usedString:$bits};
|
||||
writecharDec "$1" $(( ( ($totalBlocks / 8) - 35) + 3107 )) $(binToDec $binString);
|
||||
fi;
|
||||
# fix FSB
|
||||
dd if=/dev/zero of="$1" bs=512 seek=280 count=$(( $totalBlocks - 280 )) 2> /dev/null;
|
||||
dd if="$1" of="$1" bs=1 skip=3073 seek=3107 count=$(( ($totalBlocks / 8) - 35 )) conv=notrunc 2> /dev/null;
|
||||
bits=$(( $totalBlocks % 8 ));
|
||||
if (( bits > 0 )); then
|
||||
usedString="00000000";
|
||||
freeString=;
|
||||
for ((b=0; b<$bits; b++))
|
||||
do
|
||||
freeString=$freeString"1";
|
||||
done;
|
||||
binString=$freeString${usedString:$bits};
|
||||
writecharDec "$1" $(( ( ($totalBlocks / 8) - 35) + 3107 )) $(binToDec $binString);
|
||||
fi;
|
||||
|
||||
# assign extra blocks to FSB if needed
|
||||
fsbExtraBlocks=$(( ($totalBlocks-1)/4096 ));
|
||||
if (( fsbExtraBlocks > 0 )); then
|
||||
dd if=/dev/zero of="$1" bs=1 seek=3072 count=$(( (fsbExtraBlocks > 8) + 1 )) conv=notrunc 2> /dev/null;
|
||||
(( fsbExtraBlocks-- ));
|
||||
fi;
|
||||
# assign extra blocks to FSB if needed
|
||||
fsbExtraBlocks=$(( ($totalBlocks-1)/4096 ));
|
||||
if (( fsbExtraBlocks > 0 )); then
|
||||
dd if=/dev/zero of="$1" bs=1 seek=3072 count=$(( (fsbExtraBlocks > 8) + 1 )) conv=notrunc 2> /dev/null;
|
||||
(( fsbExtraBlocks-- ));
|
||||
fi;
|
||||
|
||||
bits=$(( fsbExtraBlocks % 8 ));
|
||||
if (( bits > 0 )); then
|
||||
freeString="11111111";
|
||||
usedString=;
|
||||
for ((b=0; b<$bits; b++))
|
||||
do
|
||||
usedString=$usedString"0";
|
||||
done;
|
||||
binString=$usedString${freeString:$bits};
|
||||
writecharDec "$1" $(( (fsbExtraBlocks>7)+3073 )) $(binToDec $binString);
|
||||
fi;
|
||||
bits=$(( fsbExtraBlocks % 8 ));
|
||||
if (( bits > 0 )); then
|
||||
freeString="11111111";
|
||||
usedString=;
|
||||
for ((b=0; b<$bits; b++))
|
||||
do
|
||||
usedString=$usedString"0";
|
||||
done;
|
||||
binString=$usedString${freeString:$bits};
|
||||
writecharDec "$1" $(( (fsbExtraBlocks>7)+3073 )) $(binToDec $binString);
|
||||
fi;
|
||||
fi
|
||||
|
346
setup/raspbian-update.txt
Normal file → Executable file
346
setup/raspbian-update.txt
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# raspbian-update
|
||||
# updates Raspbian to latest version, including NOOBS if installed
|
||||
@ -7,8 +7,8 @@
|
||||
[[ -f /usr/bin/raspi-config ]] && isRpi=1 || isRpi=
|
||||
|
||||
if [[ ! $isRpi ]]; then
|
||||
echo "This ain't a Raspberry Pi."
|
||||
[[ $0 == "-bash" ]] && return 1 || exit 1
|
||||
echo "This ain't a Raspberry Pi."
|
||||
[[ $0 == "-bash" ]] && return 1 || exit 1
|
||||
fi
|
||||
|
||||
skipRepoUpdate=
|
||||
@ -16,172 +16,172 @@ autoYes=
|
||||
updateA2Cloud=
|
||||
updateA2Server=
|
||||
while [[ $1 ]]; do
|
||||
if [[ $1 == "-r" ]]; then
|
||||
shift
|
||||
skipRepoUpdate="-r"
|
||||
elif [[ $1 == "-y" ]]; then
|
||||
shift
|
||||
autoYes="-y"
|
||||
elif [[ $1 == "-n" ]]; then
|
||||
shift
|
||||
noobsOnly="-n"
|
||||
elif [[ $1 == "a2cloud" ]]; then
|
||||
shift
|
||||
updateA2Cloud=1
|
||||
elif [[ $1 == "a2server" ]]; then
|
||||
shift
|
||||
updateA2Server=1
|
||||
elif [[ $1 ]]; then
|
||||
echo "options:"
|
||||
echo "-y: auto-answer yes to all prompts and don't prompt for restart"
|
||||
echo "-r: don't update package repositories"
|
||||
echo "-n: update NOOBS only; don't update Raspbian"
|
||||
echo "a2cloud : update A2CLOUD when complete"
|
||||
echo "a2server: update A2SERVER when complete"
|
||||
[[ $0 == "-bash" ]] && return 1 || exit 1
|
||||
fi
|
||||
if [[ $1 == "-r" ]]; then
|
||||
shift
|
||||
skipRepoUpdate="-r"
|
||||
elif [[ $1 == "-y" ]]; then
|
||||
shift
|
||||
autoYes="-y"
|
||||
elif [[ $1 == "-n" ]]; then
|
||||
shift
|
||||
noobsOnly="-n"
|
||||
elif [[ $1 == "a2cloud" ]]; then
|
||||
shift
|
||||
updateA2Cloud=1
|
||||
elif [[ $1 == "a2server" ]]; then
|
||||
shift
|
||||
updateA2Server=1
|
||||
elif [[ $1 ]]; then
|
||||
echo "options:"
|
||||
echo "-y: auto-answer yes to all prompts and don't prompt for restart"
|
||||
echo "-r: don't update package repositories"
|
||||
echo "-n: update NOOBS only; don't update Raspbian"
|
||||
echo "a2cloud : update A2CLOUD when complete"
|
||||
echo "a2server: update A2SERVER when complete"
|
||||
[[ $0 == "-bash" ]] && return 1 || exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
noobs=
|
||||
readarray -t partitions < <(sudo fdisk -l | grep '^/dev')
|
||||
if [[ \
|
||||
${partitions[0]:0:14} == "/dev/mmcblk0p1" && ${partitions[0]:57:2} == " e" &&
|
||||
${partitions[1]:0:14} == "/dev/mmcblk0p2" && ${partitions[1]:57:2} == "85" &&
|
||||
${partitions[2]:0:14} == "/dev/mmcblk0p3" && ${partitions[2]:57:2} == "83" &&
|
||||
${partitions[3]:0:14} == "/dev/mmcblk0p5" && ${partitions[3]:57:2} == " c" &&
|
||||
${partitions[4]:0:14} == "/dev/mmcblk0p6" && ${partitions[4]:57:2} == "83" ]]; then
|
||||
noobs=" and the NOOBS install manager"
|
||||
${partitions[0]:0:14} == "/dev/mmcblk0p1" && ${partitions[0]:57:2} == " e" &&
|
||||
${partitions[1]:0:14} == "/dev/mmcblk0p2" && ${partitions[1]:57:2} == "85" &&
|
||||
${partitions[2]:0:14} == "/dev/mmcblk0p3" && ${partitions[2]:57:2} == "83" &&
|
||||
${partitions[3]:0:14} == "/dev/mmcblk0p5" && ${partitions[3]:57:2} == " c" &&
|
||||
${partitions[4]:0:14} == "/dev/mmcblk0p6" && ${partitions[4]:57:2} == "83" ]]; then
|
||||
noobs=" and the NOOBS install manager"
|
||||
fi
|
||||
|
||||
if [[ ! $autoYes ]]; then
|
||||
echo
|
||||
echo "You are about to update your SD card to the latest version of the"
|
||||
echo "Raspbian operating system${noobs}."
|
||||
echo
|
||||
echo "This may take an hour or more, and will require restarting when complete."
|
||||
echo "You might want a backup before continuing in case it doesn't go as planned."
|
||||
echo
|
||||
echo -n "Update Raspbian? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} != "Y" && ${REPLY:0:1} != "y" ]]; then
|
||||
[[ $0 == "-bash" ]] && return 2 || exit 2
|
||||
fi
|
||||
echo
|
||||
echo "You are about to update your SD card to the latest version of the"
|
||||
echo "Raspbian operating system${noobs}."
|
||||
echo
|
||||
echo "This may take an hour or more, and will require restarting when complete."
|
||||
echo "You might want a backup before continuing in case it doesn't go as planned."
|
||||
echo
|
||||
echo -n "Update Raspbian? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} != "Y" && ${REPLY:0:1} != "y" ]]; then
|
||||
[[ $0 == "-bash" ]] && return 2 || exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
origDir="$PWD"
|
||||
cd /tmp
|
||||
|
||||
if [[ ! $skipRepoUpdate ]]; then
|
||||
echo "Updating package repositories..."
|
||||
sudo apt-get -y update > /dev/null
|
||||
echo "Updating package repositories..."
|
||||
sudo apt-get -y update > /dev/null
|
||||
else
|
||||
echo "Not updating package repositories..."
|
||||
echo
|
||||
echo "Not updating package repositories..."
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ ! $noobsOnly ]]; then
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
freeSpace=$(df / | tail -1 | awk '{ print $4 }')
|
||||
if (( $freeSpace < 400000 )); then
|
||||
if dpkg -l | grep -q wolfram-engine; then
|
||||
if [[ ! $autoYes ]]; then
|
||||
echo "In order to create enough space on your SD card to upgrade,"
|
||||
echo "the Wolfram Language and Mathematica software packages must be removed."
|
||||
echo "If you don't know what these are, this won't affect you at all."
|
||||
echo
|
||||
echo -n "Remove Wolfram software? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} != "Y" && ${REPLY:0:1} != "y" ]]; then
|
||||
[[ $0 == "-bash" ]] && return 2 || exit 2
|
||||
fi
|
||||
sudo rm /opt/Wolfram/WolframEngine/10.0/SystemFiles/Java/Linux-ARM 2> /dev/null
|
||||
sudo apt-get -y purge wolfram-engine
|
||||
else
|
||||
echo "Removing Wolfram software due to space constraints..."
|
||||
sudo rm /opt/Wolfram/WolframEngine/10.0/SystemFiles/Java/Linux-ARM 2> /dev/null
|
||||
sudo apt-get -y purge wolfram-engine
|
||||
fi
|
||||
else
|
||||
echo "You don't have enough free space on your SD card to upgrade."
|
||||
echo "Sorry, man. Delete some stuff or get a bigger card."
|
||||
[[ $0 == "-bash" ]] && return 1 || exit 1
|
||||
fi
|
||||
fi
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
freeSpace=$(df / | tail -1 | awk '{ print $4 }')
|
||||
if (( $freeSpace < 400000 )); then
|
||||
if dpkg -l | grep -q wolfram-engine; then
|
||||
if [[ ! $autoYes ]]; then
|
||||
echo "In order to create enough space on your SD card to upgrade,"
|
||||
echo "the Wolfram Language and Mathematica software packages must be removed."
|
||||
echo "If you don't know what these are, this won't affect you at all."
|
||||
echo
|
||||
echo -n "Remove Wolfram software? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} != "Y" && ${REPLY:0:1} != "y" ]]; then
|
||||
[[ $0 == "-bash" ]] && return 2 || exit 2
|
||||
fi
|
||||
sudo rm /opt/Wolfram/WolframEngine/10.0/SystemFiles/Java/Linux-ARM 2> /dev/null
|
||||
sudo apt-get -y purge wolfram-engine
|
||||
else
|
||||
echo "Removing Wolfram software due to space constraints..."
|
||||
sudo rm /opt/Wolfram/WolframEngine/10.0/SystemFiles/Java/Linux-ARM 2> /dev/null
|
||||
sudo apt-get -y purge wolfram-engine
|
||||
fi
|
||||
else
|
||||
echo "You don't have enough free space on your SD card to upgrade."
|
||||
echo "Sorry, man. Delete some stuff or get a bigger card."
|
||||
[[ $0 == "-bash" ]] && return 1 || exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
dpkg -l | grep -q a2pi && sudo apt-get -y --force-yes install a2pi
|
||||
dpkg -l | grep -q apple2user && sudo apt-get -y --force-yes install apple2user gsport
|
||||
if dpkg -l | grep -q wolfram-engine; then
|
||||
sudo rm /opt/Wolfram/WolframEngine/10.0/SystemFiles/Java/Linux-ARM 2> /dev/null
|
||||
if [[ $freeSpace -lt 750000 && $(apt-get -s install wolfram-engine | grep upgraded) ]]; then
|
||||
sudo apt-get -y purge wolfram-engine
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
fi
|
||||
sudo apt-get -y install wolfram-engine
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
fi
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
sudo apt-get -y install raspberrypi-ui-mods
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
dpkg -l | grep -q a2pi && sudo apt-get -y --force-yes install a2pi
|
||||
dpkg -l | grep -q apple2user && sudo apt-get -y --force-yes install apple2user gsport
|
||||
if dpkg -l | grep -q wolfram-engine; then
|
||||
sudo rm /opt/Wolfram/WolframEngine/10.0/SystemFiles/Java/Linux-ARM 2> /dev/null
|
||||
if [[ $freeSpace -lt 750000 && $(apt-get -s install wolfram-engine | grep upgraded) ]]; then
|
||||
sudo apt-get -y purge wolfram-engine
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
fi
|
||||
sudo apt-get -y install wolfram-engine
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
fi
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
sudo apt-get -y install raspberrypi-ui-mods
|
||||
{ cd /tmp; sudo apt-get -y autoremove; sudo apt-get -y autoclean; sudo apt-get -y clean; } > /dev/null
|
||||
fi
|
||||
|
||||
if [[ $noobs ]]; then
|
||||
echo "Updating NOOBS..."
|
||||
echo "Updating NOOBS..."
|
||||
|
||||
# update Partition 3
|
||||
mkdir -p /tmp/p3
|
||||
sudo mount /dev/mmcblk0p3 /tmp/p3
|
||||
sudo rm -rf /tmp/p3/os/* 2> /dev/null
|
||||
if grep -q 'Raspple II' /tmp/p3/installed_os.json; then
|
||||
echo "Downloading Raspple II lite..."
|
||||
noobsUrl="ivanx.com/rasppleii/files/RasppleII_lite.zip"
|
||||
noobsOSurl="ivanx.com/rasppleii/noobs-os"
|
||||
distDir="Raspple_II"
|
||||
sudo mkdir -p /tmp/p3/os/$distDir
|
||||
sudo sed -i 's:/Raspbian:/Raspple_II:' /tmp/p3/installed_os.json
|
||||
sudo wget -qO /tmp/p3/icon.png $noobsOSurl/Raspple_II.png
|
||||
wget -qO- $noobsOSurl/slidesAB.tar | sudo tar -C /tmp/p3/os/$distDir -x
|
||||
else
|
||||
echo "Downloading NOOBS lite..."
|
||||
noobsRoot="downloads.raspberrypi.org/NOOBS_lite/images/"
|
||||
noobsDir=$(wget -qO- $noobsRoot | grep '^<tr><td' | tail -1 | grep -P -o 'href=".*?"' | cut -c 6- | tr -d '"')
|
||||
noobsUrl=$noobsRoot$noobsDir$(wget -qO- $noobsRoot$noobsDir | grep -P -o 'href=".*.zip"' | cut -c 6- | tr -d '"')
|
||||
noobsOSurl="downloads.raspberrypi.org/raspbian"
|
||||
distDir="Raspbian"
|
||||
sudo mkdir -p /tmp/p3/os/$distDir
|
||||
sudo wget -qO /tmp/p3/icon.png $noobsOSurl/Raspbian.png
|
||||
wget -qO- $noobsOSurl/marketing.tar | sudo tar -C /tmp/p3/os/$distDir -x
|
||||
fi
|
||||
sudo rm -rf /tmp/p3/cache 2> /dev/null
|
||||
releaseDate=$(wget -qO- $noobsOSurl/os.json | grep 'release_date' | cut -f 4 -d '"')
|
||||
sudo sed -i 's/"release_date".*$/"release_date" : "'$releaseDate'"/' /tmp/p3/installed_os.json
|
||||
sudo sed -i 's/keyboard_layout=gb/keyboard_layout=us/' /tmp/p3/noobs.conf
|
||||
sudo sed -i 's:/mnt/:/settings/:' /tmp/p3/installed_os.json
|
||||
sudo sed -i 's@"icon".*,@"icon" : "/settings/os/'$distDir'/icon.png",@' /tmp/p3/installed_os.json
|
||||
sudo cp /tmp/p3/icon.png /tmp/p3/os/$distDir
|
||||
sudo wget -qO /tmp/p3/os/$distDir/os.json $noobsOSurl/os.json
|
||||
sudo wget -qO /tmp/p3/os/$distDir/partition_setup.sh $noobsOSurl/partition_setup.sh
|
||||
sudo wget -qO /tmp/p3/os/$distDir/partitions.json $noobsOSurl/partitions.json
|
||||
sudo umount /tmp/p3
|
||||
rmdir /tmp/p3
|
||||
# update Partition 3
|
||||
mkdir -p /tmp/p3
|
||||
sudo mount /dev/mmcblk0p3 /tmp/p3
|
||||
sudo rm -rf /tmp/p3/os/* 2> /dev/null
|
||||
if grep -q 'Raspple II' /tmp/p3/installed_os.json; then
|
||||
echo "Downloading Raspple II lite..."
|
||||
noobsUrl="ivanx.com/rasppleii/files/RasppleII_lite.zip"
|
||||
noobsOSurl="ivanx.com/rasppleii/noobs-os"
|
||||
distDir="Raspple_II"
|
||||
sudo mkdir -p /tmp/p3/os/$distDir
|
||||
sudo sed -i 's:/Raspbian:/Raspple_II:' /tmp/p3/installed_os.json
|
||||
sudo wget -qO /tmp/p3/icon.png $noobsOSurl/Raspple_II.png
|
||||
wget -qO- $noobsOSurl/slidesAB.tar | sudo tar -C /tmp/p3/os/$distDir -x
|
||||
else
|
||||
echo "Downloading NOOBS lite..."
|
||||
noobsRoot="downloads.raspberrypi.org/NOOBS_lite/images/"
|
||||
noobsDir=$(wget -qO- $noobsRoot | grep '^<tr><td' | tail -1 | grep -P -o 'href=".*?"' | cut -c 6- | tr -d '"')
|
||||
noobsUrl=$noobsRoot$noobsDir$(wget -qO- $noobsRoot$noobsDir | grep -P -o 'href=".*.zip"' | cut -c 6- | tr -d '"')
|
||||
noobsOSurl="downloads.raspberrypi.org/raspbian"
|
||||
distDir="Raspbian"
|
||||
sudo mkdir -p /tmp/p3/os/$distDir
|
||||
sudo wget -qO /tmp/p3/icon.png $noobsOSurl/Raspbian.png
|
||||
wget -qO- $noobsOSurl/marketing.tar | sudo tar -C /tmp/p3/os/$distDir -x
|
||||
fi
|
||||
sudo rm -rf /tmp/p3/cache 2> /dev/null
|
||||
releaseDate=$(wget -qO- $noobsOSurl/os.json | grep 'release_date' | cut -f 4 -d '"')
|
||||
sudo sed -i 's/"release_date".*$/"release_date" : "'$releaseDate'"/' /tmp/p3/installed_os.json
|
||||
sudo sed -i 's/keyboard_layout=gb/keyboard_layout=us/' /tmp/p3/noobs.conf
|
||||
sudo sed -i 's:/mnt/:/settings/:' /tmp/p3/installed_os.json
|
||||
sudo sed -i 's@"icon".*,@"icon" : "/settings/os/'$distDir'/icon.png",@' /tmp/p3/installed_os.json
|
||||
sudo cp /tmp/p3/icon.png /tmp/p3/os/$distDir
|
||||
sudo wget -qO /tmp/p3/os/$distDir/os.json $noobsOSurl/os.json
|
||||
sudo wget -qO /tmp/p3/os/$distDir/partition_setup.sh $noobsOSurl/partition_setup.sh
|
||||
sudo wget -qO /tmp/p3/os/$distDir/partitions.json $noobsOSurl/partitions.json
|
||||
sudo umount /tmp/p3
|
||||
rmdir /tmp/p3
|
||||
|
||||
# update Partition 1
|
||||
mkdir -p /tmp/p1
|
||||
sudo mount /dev/mmcblk0p1 /tmp/p1
|
||||
wget -qO /tmp/noobs_lite.zip $noobsUrl
|
||||
sudo rm -rf /tmp/p1/*
|
||||
sudo unzip -d /tmp/p1 /tmp/noobs_lite.zip
|
||||
sudo sed -i 's/^runinstaller //' /tmp/p1/recovery.cmdline
|
||||
sudo sed -i 's/silentinstall//' /tmp/p1/recovery.cmdline
|
||||
grep -q 'keyboard=us' /tmp/p1/recovery.cmdline || sudo sed -i '1 s/^\(.*\)$/\1 keyboard=us/' /tmp/p1/recovery.cmdline
|
||||
grep -q 'disablesafemode' /tmp/p1/recovery.cmdline || sudo sed -i '1 s/^\(.*\)$/\1 disablesafemode/' /tmp/p1/recovery.cmdline
|
||||
sudo umount /tmp/p1
|
||||
rmdir /tmp/p1
|
||||
# update Partition 1
|
||||
mkdir -p /tmp/p1
|
||||
sudo mount /dev/mmcblk0p1 /tmp/p1
|
||||
wget -qO /tmp/noobs_lite.zip $noobsUrl
|
||||
sudo rm -rf /tmp/p1/*
|
||||
sudo unzip -d /tmp/p1 /tmp/noobs_lite.zip
|
||||
sudo sed -i 's/^runinstaller //' /tmp/p1/recovery.cmdline
|
||||
sudo sed -i 's/silentinstall//' /tmp/p1/recovery.cmdline
|
||||
grep -q 'keyboard=us' /tmp/p1/recovery.cmdline || sudo sed -i '1 s/^\(.*\)$/\1 keyboard=us/' /tmp/p1/recovery.cmdline
|
||||
grep -q 'disablesafemode' /tmp/p1/recovery.cmdline || sudo sed -i '1 s/^\(.*\)$/\1 disablesafemode/' /tmp/p1/recovery.cmdline
|
||||
sudo umount /tmp/p1
|
||||
rmdir /tmp/p1
|
||||
|
||||
sudo sed -i 's/\(Raspple II release.*[^u]$\)/\1u/' /etc/issue
|
||||
sudo sed -i 's/\(Raspple II release.*[^u]$\)/\1u/' /etc/issue
|
||||
fi
|
||||
|
||||
echo
|
||||
@ -191,44 +191,44 @@ echo
|
||||
cd /tmp
|
||||
|
||||
if [[ $updateA2Cloud ]]; then
|
||||
wget -qO /tmp/a2cloud-setup ivanx.com/a2cloud/setup/
|
||||
source /tmp/a2cloud-setup -y -r noSetGroups
|
||||
if acmd -g /usr/share/gsport/disks/GSport\ Internet\ Starter\ Kit.2mg SYSTEM/FONTS/SIS.4.10 &> /dev/null; then
|
||||
wget -qO /tmp/ua2.txt ivanx.com/rasppleii/files/a/ua2.txt
|
||||
source /tmp/ua2.txt
|
||||
fi
|
||||
echo
|
||||
echo "*** A2CLOUD update completed. ***"
|
||||
echo
|
||||
wget -qO /tmp/a2cloud-setup ivanx.com/a2cloud/setup/
|
||||
source /tmp/a2cloud-setup -y -r noSetGroups
|
||||
if acmd -g /usr/share/gsport/disks/GSport\ Internet\ Starter\ Kit.2mg SYSTEM/FONTS/SIS.4.10 &> /dev/null; then
|
||||
wget -qO /tmp/ua2.txt ivanx.com/rasppleii/files/a/ua2.txt
|
||||
source /tmp/ua2.txt
|
||||
fi
|
||||
echo
|
||||
echo "*** A2CLOUD update completed. ***"
|
||||
echo
|
||||
fi
|
||||
|
||||
cd /tmp
|
||||
|
||||
if [[ $updateA2Server ]]; then
|
||||
wget -q -O /tmp/a2server-setup ivanx.com/a2server/setup/
|
||||
if ps aux | grep -q [s]mbd; then
|
||||
source /tmp/a2server-setup -y -r -w
|
||||
else
|
||||
source /tmp/a2server-setup -y -r
|
||||
fi
|
||||
echo
|
||||
echo "*** A2SERVER update completed. ***"
|
||||
echo
|
||||
wget -q -O /tmp/a2server-setup ivanx.com/a2server/setup/
|
||||
if ps aux | grep -q [s]mbd; then
|
||||
source /tmp/a2server-setup -y -r -w
|
||||
else
|
||||
source /tmp/a2server-setup -y -r
|
||||
fi
|
||||
echo
|
||||
echo "*** A2SERVER update completed. ***"
|
||||
echo
|
||||
fi
|
||||
|
||||
cd "$origDir"
|
||||
|
||||
if [[ ! $autoYes ]]; then
|
||||
echo
|
||||
echo
|
||||
echo "Your system has been updated and needs to reboot to use its new software."
|
||||
echo
|
||||
echo -n "Reboot now (recommended)? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
sudo shutdown -r now
|
||||
fi
|
||||
echo
|
||||
echo
|
||||
echo "Your system has been updated and needs to reboot to use its new software."
|
||||
echo
|
||||
echo -n "Reboot now (recommended)? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
sudo shutdown -r now
|
||||
fi
|
||||
else
|
||||
echo "*** raspbian-update completed. ***"
|
||||
sudo shutdown -r now
|
||||
echo "*** raspbian-update completed. ***"
|
||||
sudo shutdown -r now
|
||||
fi
|
||||
|
2740
setup/setup.txt
2740
setup/setup.txt
File diff suppressed because it is too large
Load Diff
14
setup/shk2image.txt
Normal file → Executable file
14
setup/shk2image.txt
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
origDir="$PWD"
|
||||
[[ ! -n $1 || ! -n $2 ]] && { echo "Usage: shk2image archiveFileName imageFileName [PRODOS.DIR.NAME]"; exit 1; };
|
||||
@ -15,11 +15,11 @@ cd /tmp/shk2image_temp
|
||||
shkFiles=$(nulib2 -xse "$archiveFile" | tr "\r" "~" | cut -d "~" -f 2 | cut -c 18-);
|
||||
cd "$origDir"
|
||||
while read thisFile; do
|
||||
fileName=${thisFile%%#*};
|
||||
fileType=${thisFile##*#};
|
||||
echo "extracting $fileName...";
|
||||
acmd -d "$imageFileName" $dirName$fileName &>/dev/null;
|
||||
acmd -p "$imageFileName" $dirName$fileName \$${fileType:0:2} \$${fileType:2:4} < /tmp/shk2image_temp/"$thisFile"
|
||||
rm /tmp/shk2image_temp/"$thisFile"
|
||||
fileName=${thisFile%%#*};
|
||||
fileType=${thisFile##*#};
|
||||
echo "extracting $fileName...";
|
||||
acmd -d "$imageFileName" $dirName$fileName &>/dev/null;
|
||||
acmd -p "$imageFileName" $dirName$fileName \$${fileType:0:2} \$${fileType:2:4} < /tmp/shk2image_temp/"$thisFile"
|
||||
rm /tmp/shk2image_temp/"$thisFile"
|
||||
done <<< $shkFiles
|
||||
rm -r /tmp/shk2image_temp
|
||||
|
66
setup/term.txt
Normal file → Executable file
66
setup/term.txt
Normal file → Executable file
@ -1,48 +1,48 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
if [[ $1 == "-d" ]]; then
|
||||
shift
|
||||
setgetty=1
|
||||
shift
|
||||
setgetty=1
|
||||
else
|
||||
setgetty=
|
||||
setgetty=
|
||||
fi
|
||||
|
||||
if [[ $1 == "-f" ]]; then
|
||||
shift
|
||||
force=1
|
||||
shift
|
||||
force=1
|
||||
else
|
||||
force=
|
||||
force=
|
||||
fi
|
||||
|
||||
if [[ ! $1 || $1 == "--help" || $1 == "-h" ]]; then
|
||||
echo 'Usage: term [-d] mono|color|none|<terminalName>';
|
||||
echo ' -d sets default emulation for all serial port shells (takes effect on logout)'
|
||||
echo ' omitting -d makes change temporary and immediate'
|
||||
echo ' -f forces change even if not running on serial port (e.g. within "screen")'
|
||||
echo ' Terminal emulation: mono->VT-100, color->PC-ANSI/ANSI-BBS, none->no emulation'
|
||||
echo 'Usage: term [-d] mono|color|none|<terminalName>';
|
||||
echo ' -d sets default emulation for all serial port shells (takes effect on logout)'
|
||||
echo ' omitting -d makes change temporary and immediate'
|
||||
echo ' -f forces change even if not running on serial port (e.g. within "screen")'
|
||||
echo ' Terminal emulation: mono->VT-100, color->PC-ANSI/ANSI-BBS, none->no emulation'
|
||||
else
|
||||
if [[ $(tr [:upper:] [:lower:] <<< $1) == "mono" ]]; then
|
||||
term="vt100"
|
||||
elif [[ $(tr [:upper:] [:lower:] <<< $1) == "color" ]]; then
|
||||
term="pcansi"
|
||||
elif [[ $(tr [:upper:] [:lower:] <<< $1) == "none" ]]; then
|
||||
term="dumb"
|
||||
else
|
||||
term="$1"
|
||||
fi
|
||||
if [[ $setgetty ]]; then
|
||||
sudo sed -i "s/\(ttyAMA0 .*\) .*$/\1 $term/" /etc/inittab;
|
||||
sudo sed -i "s/\(ttyUSB.* .*\) .*$/\1 $term/g" /etc/inittab;
|
||||
sudo init q;
|
||||
sudo pkill -f "/sbin/getty"
|
||||
else
|
||||
if [[ $force || $(tty | grep tty) ]]; then
|
||||
TERM="$term"
|
||||
else
|
||||
echo 1>&2 "Not running on serial port. No action taken. Use -f to set anyway."
|
||||
fi
|
||||
fi
|
||||
if [[ $(tr [:upper:] [:lower:] <<< $1) == "mono" ]]; then
|
||||
term="vt100"
|
||||
elif [[ $(tr [:upper:] [:lower:] <<< $1) == "color" ]]; then
|
||||
term="pcansi"
|
||||
elif [[ $(tr [:upper:] [:lower:] <<< $1) == "none" ]]; then
|
||||
term="dumb"
|
||||
else
|
||||
term="$1"
|
||||
fi
|
||||
if [[ $setgetty ]]; then
|
||||
sudo sed -i "s/\(ttyAMA0 .*\) .*$/\1 $term/" /etc/inittab;
|
||||
sudo sed -i "s/\(ttyUSB.* .*\) .*$/\1 $term/g" /etc/inittab;
|
||||
sudo init q;
|
||||
sudo pkill -f "/sbin/getty"
|
||||
else
|
||||
if [[ $force || $(tty | grep tty) ]]; then
|
||||
TERM="$term"
|
||||
else
|
||||
echo 1>&2 "Not running on serial port. No action taken. Use -f to set anyway."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "$(tty) current emulation: $(tput bold)$TERM$(tput sgr0)"
|
||||
|
74
setup/ttyusbhandler.txt
Normal file → Executable file
74
setup/ttyusbhandler.txt
Normal file → Executable file
@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# called by udev as:
|
||||
# ttyusbhandler [add|remove] ttyUSBname
|
||||
@ -21,42 +21,42 @@
|
||||
# rescan for getty
|
||||
|
||||
if [[ $1 == "remove" ]]; then
|
||||
rm /tmp/udev-$2-removed &> /dev/null
|
||||
touch /tmp/udev-$2-removed
|
||||
pkill -f "$2.*ADTPro"
|
||||
rm /tmp/udev-$2-removed &> /dev/null
|
||||
touch /tmp/udev-$2-removed
|
||||
pkill -f "$2.*ADTPro"
|
||||
elif [[ $1 == "add" ]]; then
|
||||
[[ $2 == "ttyUSBlower" ]] && sleep 1.5
|
||||
[[ ${#2} -gt 11 ]] && sleep "${2:15:2}"
|
||||
if [[ $2 == "ttyUSBlower" || \
|
||||
$2 == $(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | head -1 | cut -c 6-) || \
|
||||
( ${2:0:12} == "ttyUSBlower_" && $2 != $(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | tail -1 | cut -c 6-) ) \
|
||||
]]; then
|
||||
rm /tmp/udev-ttyUSBlower-added &> /dev/null
|
||||
touch /tmp/udev-ttyUSBlower-added
|
||||
pkill -f "[A]DTPro"
|
||||
pkill -f "[u]sbgetty"
|
||||
exec echo "/usr/local/adtpro/adtpro.sh headless serial" | at -M now
|
||||
else # ttyUSBupper
|
||||
rm /tmp/udev-ttyUSBupper-added &> /dev/null
|
||||
touch /tmp/udev-ttyUSBupper-added
|
||||
pkill -f "[g]etty.*ttyUSB"
|
||||
if [[ -f /bin/systemctl ]]; then # if systemd
|
||||
# if USB-to-serial adapter is directly attached to upper port
|
||||
if [[ -c /dev/ttyUSBupper ]]; then
|
||||
ttyUSB=ttyUSBupper
|
||||
# if hub in upper port, use highest numbered port on hub
|
||||
elif [[ $(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | wc -l) -gt 0 ]]; then
|
||||
ttyUSB=$(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | tail -1 | cut -c 6-)
|
||||
# if hub in lower port with multiple adapters, use highest numbered port on hub
|
||||
elif [[ $(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | wc -l) -gt 1 ]]; then
|
||||
ttyUSB=$(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | tail -1 | cut -c 6-)
|
||||
else
|
||||
# by definition, this shouldn't happen
|
||||
ttyUSB=
|
||||
fi
|
||||
exec systemctl restart usbgetty@$ttyUSB
|
||||
fi
|
||||
fi
|
||||
[[ $2 == "ttyUSBlower" ]] && sleep 1.5
|
||||
[[ ${#2} -gt 11 ]] && sleep "${2:15:2}"
|
||||
if [[ $2 == "ttyUSBlower" || \
|
||||
$2 == $(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | head -1 | cut -c 6-) || \
|
||||
( ${2:0:12} == "ttyUSBlower_" && $2 != $(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | tail -1 | cut -c 6-) ) \
|
||||
]]; then
|
||||
rm /tmp/udev-ttyUSBlower-added &> /dev/null
|
||||
touch /tmp/udev-ttyUSBlower-added
|
||||
pkill -f "[A]DTPro"
|
||||
pkill -f "[u]sbgetty"
|
||||
exec echo "/usr/local/adtpro/adtpro.sh headless serial" | at -M now
|
||||
else # ttyUSBupper
|
||||
rm /tmp/udev-ttyUSBupper-added &> /dev/null
|
||||
touch /tmp/udev-ttyUSBupper-added
|
||||
pkill -f "[g]etty.*ttyUSB"
|
||||
if [[ -f /bin/systemctl ]]; then # if systemd
|
||||
# if USB-to-serial adapter is directly attached to upper port
|
||||
if [[ -c /dev/ttyUSBupper ]]; then
|
||||
ttyUSB=ttyUSBupper
|
||||
# if hub in upper port, use highest numbered port on hub
|
||||
elif [[ $(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | wc -l) -gt 0 ]]; then
|
||||
ttyUSB=$(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | tail -1 | cut -c 6-)
|
||||
# if hub in lower port with multiple adapters, use highest numbered port on hub
|
||||
elif [[ $(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | wc -l) -gt 1 ]]; then
|
||||
ttyUSB=$(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | tail -1 | cut -c 6-)
|
||||
else
|
||||
# by definition, this shouldn't happen
|
||||
ttyUSB=
|
||||
fi
|
||||
exec systemctl restart usbgetty@$ttyUSB
|
||||
fi
|
||||
fi
|
||||
else
|
||||
exit 2
|
||||
exit 2
|
||||
fi
|
||||
|
58
setup/usbgetty.txt
Normal file → Executable file
58
setup/usbgetty.txt
Normal file → Executable file
@ -1,48 +1,48 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
ttyUSB=
|
||||
|
||||
pkill -f "sleep 86399"
|
||||
|
||||
if [[ $(grep -e '-scanttyUSB' <<< "$*") ]]; then
|
||||
# called with -scantty isntead of device name?
|
||||
# echo "-scantty mode"
|
||||
# called with -scantty isntead of device name?
|
||||
# echo "-scantty mode"
|
||||
|
||||
# if upper USB port
|
||||
if [[ -c /dev/ttyUSBupper ]]; then
|
||||
ttyUSB=ttyUSBupper
|
||||
# if upper USB port
|
||||
if [[ -c /dev/ttyUSBupper ]]; then
|
||||
ttyUSB=ttyUSBupper
|
||||
|
||||
# if hub in upper port, use highest numbered port on hub
|
||||
elif [[ $(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | wc -l) -gt 0 ]]; then
|
||||
ttyUSB=$(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | tail -1 | cut -c 6-)
|
||||
# if hub in upper port, use highest numbered port on hub
|
||||
elif [[ $(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | wc -l) -gt 0 ]]; then
|
||||
ttyUSB=$(ls -1 /dev/ttyUSBupper_hub* 2> /dev/null | tail -1 | cut -c 6-)
|
||||
|
||||
# if hub in lower port with multiple adapters, use highest numbered port on hub
|
||||
elif [[ $(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | wc -l) -gt 1 ]]; then
|
||||
ttyUSB=$(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | tail -1 | cut -c 6-)
|
||||
# if hub in lower port with multiple adapters, use highest numbered port on hub
|
||||
elif [[ $(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | wc -l) -gt 1 ]]; then
|
||||
ttyUSB=$(ls -1 /dev/ttyUSBlower_hub* 2> /dev/null | tail -1 | cut -c 6-)
|
||||
|
||||
# no port found eligible for getty
|
||||
else
|
||||
# echo "scantty no devices eligible: sleeping"
|
||||
sleep 86399
|
||||
fi
|
||||
# no port found eligible for getty
|
||||
else
|
||||
# echo "scantty no devices eligible: sleeping"
|
||||
sleep 86399
|
||||
fi
|
||||
|
||||
# echo "result:$ttyUSB"
|
||||
# echo "result:$ttyUSB"
|
||||
elif [[ $(grep -o 'ttyUSB[^ ]*' <<< "$*") ]]; then
|
||||
# echo "device specified"
|
||||
# if specified USB device name is found
|
||||
ttyUSB=$(grep -o 'ttyUSB[^ ]*' <<< "$*")
|
||||
# echo "device specified"
|
||||
# if specified USB device name is found
|
||||
ttyUSB=$(grep -o 'ttyUSB[^ ]*' <<< "$*")
|
||||
else
|
||||
# echo "specified device failed: sleeping"
|
||||
sleep 86399
|
||||
# echo "specified device failed: sleeping"
|
||||
sleep 86399
|
||||
fi
|
||||
|
||||
if [[ -c /dev/$ttyUSB && ! $(ps aux | grep "[g]etty.*$ttyUSB") ]]; then
|
||||
# if adapter seems to exist and doesn't already have a getty,
|
||||
# kill all USB gettys and start the getty, otherwise do nothing
|
||||
pkill -f "/sbin/getty.*ttyUSB"
|
||||
exec /sbin/getty $(sed "s/-scanttyUSB/$ttyUSB/" <<< "$@");
|
||||
# if adapter seems to exist and doesn't already have a getty,
|
||||
# kill all USB gettys and start the getty, otherwise do nothing
|
||||
pkill -f "/sbin/getty.*ttyUSB"
|
||||
exec /sbin/getty $(sed "s/-scanttyUSB/$ttyUSB/" <<< "$@");
|
||||
else
|
||||
# echo "getty already running or doesn't exist: sleeping"
|
||||
sleep 86399
|
||||
# echo "getty already running or doesn't exist: sleeping"
|
||||
sleep 86399
|
||||
fi
|
||||
|
60
setup/vsd.txt
Normal file → Executable file
60
setup/vsd.txt
Normal file → Executable file
@ -1,42 +1,42 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
skipWarning=
|
||||
drive=
|
||||
if [[ $1 == "-1" || $1 == "-d1" ]]; then
|
||||
shift
|
||||
shift
|
||||
elif [[ $1 = "-2" || $1 == "-d2" ]]; then
|
||||
drive=2
|
||||
shift
|
||||
drive=2
|
||||
shift
|
||||
fi
|
||||
if [[ ! $1 ]]; then
|
||||
echo "virtual drive $(( drive ? 2 : 1 )): $(readlink /usr/local/adtpro/disks/Virtual${drive}.po)"
|
||||
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
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user