mirror of
https://github.com/RasppleII/a2server.git
synced 2026-04-20 14:16:36 +00:00
Scripts: re-indent (tab indentation)
One of the reasons I held off on doing this before is that there are a lot of complex one-line seds in here that I expect _will_ be broken by this. More than a few of these will assume, depend on, require, and break if specific hardcoded whitespace is not found. That's problematic anyway--when whitespace isn't syntactic, you shouldn't do that. So it's time to fix these anyway.
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# --- Setting up the share volume
|
||||
|
||||
# 1.3.0: move /media/A2SHARED (pre-1.3.0) to /srv/A2SERVER
|
||||
if [[ -d /media/A2SHARED ]]; then
|
||||
echo "A2SERVER: Moving /media/A2SHARED to /srv/A2SERVER..."
|
||||
sudo /etc/init.d/netatalk stop &> /dev/null
|
||||
sudo /etc/init.d/samba stop &> /dev/null
|
||||
[[ ! -d /srv ]] && sudo mkdir -p /srv
|
||||
sudo mv /media/A2SHARED /srv/A2SERVER
|
||||
sudo sed -i 's|/media/A2SHARED|/srv/A2SERVER|g' /usr/local/etc/netatalk/AppleVolumes.default
|
||||
[[ -f /etc/samba/smbd.conf ]] && sudo sed -i 's|/media/A2SHARED|/srv/A2SERVER|g' /etc/samba/smbd.conf
|
||||
echo "A2SERVER: Moving /media/A2SHARED to /srv/A2SERVER..."
|
||||
sudo /etc/init.d/netatalk stop &> /dev/null
|
||||
sudo /etc/init.d/samba stop &> /dev/null
|
||||
[[ ! -d /srv ]] && sudo mkdir -p /srv
|
||||
sudo mv /media/A2SHARED /srv/A2SERVER
|
||||
sudo sed -i 's|/media/A2SHARED|/srv/A2SERVER|g' /usr/local/etc/netatalk/AppleVolumes.default
|
||||
[[ -f /etc/samba/smbd.conf ]] && sudo sed -i 's|/media/A2SHARED|/srv/A2SERVER|g' /etc/samba/smbd.conf
|
||||
|
||||
fi
|
||||
|
||||
# skip if we're already set up
|
||||
if [[ -d /srv/A2SERVER ]]; then
|
||||
|
||||
echo "A2SERVER: Shared volume is already prepared for use."
|
||||
echo "A2SERVER: Shared volume is already prepared for use."
|
||||
|
||||
else
|
||||
|
||||
echo "A2SERVER: Preparing the shared files volume..."
|
||||
echo "A2SERVER: Preparing the shared files volume..."
|
||||
|
||||
sudo mkdir -p /srv/A2SERVER
|
||||
sudo mkdir -p /srv/A2SERVER
|
||||
|
||||
sudo chown $USER:$USER /srv/A2SERVER
|
||||
sudo chown $USER:$USER /srv/A2SERVER
|
||||
|
||||
fi
|
||||
|
||||
+123
-123
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# download and install a2server tools:
|
||||
# mkatinit, mkvolinfo, afptype, afpsync, aliases, nulib2
|
||||
@@ -20,90 +20,90 @@ debianVersion=$(cat /etc/debian_version 2> /dev/null)
|
||||
isRpi=
|
||||
arch=
|
||||
if [[ -f /usr/bin/raspi-config ]]; then
|
||||
isRpi=1
|
||||
arch='rpi'
|
||||
isRpi=1
|
||||
arch='rpi'
|
||||
elif lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian' && [[ $(cut -d . -f 1 <<< $debianVersion) -ge "7" ]]; then
|
||||
uname_m="$(uname -m)"
|
||||
if [[ $uname_m == "i686" ]]; then
|
||||
arch='debian_x86'
|
||||
elif [[ $uname_m == "x86_64" ]]; then
|
||||
arch='debian_x64'
|
||||
fi
|
||||
uname_m="$(uname -m)"
|
||||
if [[ $uname_m == "i686" ]]; then
|
||||
arch='debian_x86'
|
||||
elif [[ $uname_m == "x86_64" ]]; then
|
||||
arch='debian_x64'
|
||||
fi
|
||||
fi
|
||||
|
||||
debianName=
|
||||
if [[ $debianVersion ]]; then
|
||||
debianMajor=$(cut -d . -f 1 <<< $debianVersion)
|
||||
if [[ $debianMajor == "8" ]]; then
|
||||
debianName="jessie"
|
||||
elif [[ $debianMajor == "7" ]]; then
|
||||
debianName="wheezy"
|
||||
else
|
||||
debianName="unknown"
|
||||
fi
|
||||
debianMajor=$(cut -d . -f 1 <<< $debianVersion)
|
||||
if [[ $debianMajor == "8" ]]; then
|
||||
debianName="jessie"
|
||||
elif [[ $debianMajor == "7" ]]; then
|
||||
debianName="wheezy"
|
||||
else
|
||||
debianName="unknown"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "A2SERVER: Installing A2SERVER tools..."
|
||||
|
||||
# delete older nulib2 which doesn't correctly handle zero-length forks in GSHK-created archives
|
||||
if hash nulib2 &> /dev/null; then
|
||||
nulib2version=$(nulib2 | sed -n 2p | sed 's|^.*v\([0-9]\)\.\([0-9]\)\.\([0-9]\).*$|\1\2\3|' 2> /dev/null)
|
||||
if (( $nulib2version < 310 )); then
|
||||
sudo apt-get -y purge nulib2 &> /dev/null
|
||||
sudo rm $(command -v nulib2) &> /dev/null
|
||||
fi
|
||||
nulib2version=$(nulib2 | sed -n 2p | sed 's|^.*v\([0-9]\)\.\([0-9]\)\.\([0-9]\).*$|\1\2\3|' 2> /dev/null)
|
||||
if (( $nulib2version < 310 )); then
|
||||
sudo apt-get -y purge nulib2 &> /dev/null
|
||||
sudo rm $(command -v nulib2) &> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! hash nulib2 &> /dev/null; then
|
||||
|
||||
echo "A2SERVER: Installing nulib2..."
|
||||
echo "A2SERVER: Installing nulib2..."
|
||||
|
||||
cd /tmp
|
||||
if [[ $arch && ! -f /tmp/a2server-compileAlways ]]; then
|
||||
{ wget -qO- "${binaryURL}precompiled/nulib2-3.1.0a2-${arch}.tgz" | sudo tar Pzx; } &> /dev/null
|
||||
fi
|
||||
cd /tmp
|
||||
if [[ $arch && ! -f /tmp/a2server-compileAlways ]]; then
|
||||
{ wget -qO- "${binaryURL}precompiled/nulib2-3.1.0a2-${arch}.tgz" | sudo tar Pzx; } &> /dev/null
|
||||
fi
|
||||
|
||||
if ! hash nulib2 &> /dev/null; then
|
||||
if ! hash nulib2 &> /dev/null; then
|
||||
|
||||
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
|
||||
# prepare for installing packages
|
||||
sudo apt-get -y update
|
||||
touch /tmp/a2server-packageReposUpdated
|
||||
fi
|
||||
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
|
||||
# prepare for installing packages
|
||||
sudo apt-get -y update
|
||||
touch /tmp/a2server-packageReposUpdated
|
||||
fi
|
||||
|
||||
# Dependencies: build-dep for nulib
|
||||
sudo apt-get -y install build-essential zlib1g-dev
|
||||
sudo apt-get -y clean
|
||||
# Dependencies: build-dep for nulib
|
||||
sudo apt-get -y install build-essential zlib1g-dev
|
||||
sudo apt-get -y clean
|
||||
|
||||
cd /tmp
|
||||
rm -rf /tmp/nulib2 &> /dev/null
|
||||
mkdir /tmp/nulib2
|
||||
cd /tmp/nulib2
|
||||
if [[ $useExternalURL ]]; then
|
||||
wget -q -O nulib2-3.1.0a2.zip "https://github.com/fadden/nulib2/archive/20fe7efb4d37fedf807416c16d74d51d893ea48a.zip"
|
||||
unzip nulib2-3.1.0a2.zip 2> /dev/null
|
||||
rm nulib2-3.1.0a2.zip &> /dev/null
|
||||
fi
|
||||
if [ ! -d nulib2* ]; then
|
||||
wget -q -O nulib2-3.1.0a2.zip "${binaryURL}external/source/nulib2-3.1.0a2.zip"
|
||||
unzip nulib2-3.1.0a2.zip 2> /dev/null
|
||||
rm nulib2-3.1.0a2.zip &> /dev/null
|
||||
fi
|
||||
cd nulib2*
|
||||
cd nufxlib
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
cd ../nulib2
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
cd
|
||||
rm -rf /tmp/nulib2
|
||||
fi
|
||||
cd /tmp
|
||||
rm -rf /tmp/nulib2 &> /dev/null
|
||||
mkdir /tmp/nulib2
|
||||
cd /tmp/nulib2
|
||||
if [[ $useExternalURL ]]; then
|
||||
wget -q -O nulib2-3.1.0a2.zip "https://github.com/fadden/nulib2/archive/20fe7efb4d37fedf807416c16d74d51d893ea48a.zip"
|
||||
unzip nulib2-3.1.0a2.zip 2> /dev/null
|
||||
rm nulib2-3.1.0a2.zip &> /dev/null
|
||||
fi
|
||||
if [ ! -d nulib2* ]; then
|
||||
wget -q -O nulib2-3.1.0a2.zip "${binaryURL}external/source/nulib2-3.1.0a2.zip"
|
||||
unzip nulib2-3.1.0a2.zip 2> /dev/null
|
||||
rm nulib2-3.1.0a2.zip &> /dev/null
|
||||
fi
|
||||
cd nulib2*
|
||||
cd nufxlib
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
cd ../nulib2
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
cd
|
||||
rm -rf /tmp/nulib2
|
||||
fi
|
||||
|
||||
else
|
||||
echo "A2SERVER: Nulib2 has already been installed."
|
||||
echo "A2SERVER: Nulib2 has already been installed."
|
||||
fi
|
||||
|
||||
# download and install The Unarchiver, for expanding Apple disk images
|
||||
@@ -111,73 +111,73 @@ fi
|
||||
|
||||
if ! hash unar &> /dev/null; then
|
||||
|
||||
echo "A2SERVER: Installing The Unarchiver..."
|
||||
echo "A2SERVER: Installing The Unarchiver..."
|
||||
|
||||
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
|
||||
# prepare for installing packages
|
||||
sudo apt-get -y update
|
||||
touch /tmp/a2server-packageReposUpdated
|
||||
fi
|
||||
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
|
||||
# prepare for installing packages
|
||||
sudo apt-get -y update
|
||||
touch /tmp/a2server-packageReposUpdated
|
||||
fi
|
||||
|
||||
# jessie and later: Just use the unar package
|
||||
if [[ $debianMajor -ge 8 ]]; then
|
||||
sudo apt-get -y install unar
|
||||
sudo apt-get clean
|
||||
fi
|
||||
# jessie and later: Just use the unar package
|
||||
if [[ $debianMajor -ge 8 ]]; then
|
||||
sudo apt-get -y install unar
|
||||
sudo apt-get clean
|
||||
fi
|
||||
|
||||
if ! hash unar &> /dev/null; then
|
||||
if [[ $arch && ! -f /tmp/a2server-compileAlways ]]; then
|
||||
# Dependencies: for unar
|
||||
sudo apt-get -y install libgnustep-base1.22
|
||||
sudo apt-get clean
|
||||
{ wget -qO- "${binaryURL}precompiled/unar-${arch}_${debianName}.tgz" | sudo tar Pzx; } &> /dev/null
|
||||
fi
|
||||
if ! hash unar &> /dev/null; then
|
||||
if [[ $arch && ! -f /tmp/a2server-compileAlways ]]; then
|
||||
# Dependencies: for unar
|
||||
sudo apt-get -y install libgnustep-base1.22
|
||||
sudo apt-get clean
|
||||
{ wget -qO- "${binaryURL}precompiled/unar-${arch}_${debianName}.tgz" | sudo tar Pzx; } &> /dev/null
|
||||
fi
|
||||
|
||||
# If all else fails, compile from source.
|
||||
if ! hash unar &> /dev/null; then
|
||||
# If all else fails, compile from source.
|
||||
if ! hash unar &> /dev/null; then
|
||||
|
||||
# Dependencies: build-deps for unar
|
||||
sudo apt-get -y install build-essential libgnustep-base-dev libz-dev libbz2-dev libssl-dev libicu-dev unzip
|
||||
sudo apt-get clean
|
||||
# Dependencies: build-deps for unar
|
||||
sudo apt-get -y install build-essential libgnustep-base-dev libz-dev libbz2-dev libssl-dev libicu-dev unzip
|
||||
sudo apt-get clean
|
||||
|
||||
rm -rf /tmp/unar &> /dev/null
|
||||
mkdir /tmp/unar
|
||||
cd /tmp/unar
|
||||
if [[ $useExternalURL ]]; then
|
||||
wget -O unar-1.8.1.zip https://github.com/incbee/Unarchiver/archive/unar-1.8.1.zip
|
||||
unzip -o unar-1.8.1.zip &> /dev/null
|
||||
fi
|
||||
if [ ! -d *Unarchiver*/XADMaster ]; then # need single bracket for glob
|
||||
wget -O unar-1.8.1.zip ${binaryURL}external/source/unar-1.8.1.zip
|
||||
unzip -o unar-1.8.1.zip &> /dev/null
|
||||
fi
|
||||
cd *Unarchiver*/XADMaster
|
||||
make -f Makefile.linux
|
||||
sudo mv lsar unar /usr/local/bin
|
||||
cd ../Extra
|
||||
sudo mv lsar.1 unar.1 /usr/local/man/man1
|
||||
cd
|
||||
rm -rf /tmp/unar
|
||||
fi
|
||||
sudo mandb &> /dev/null
|
||||
fi
|
||||
rm -rf /tmp/unar &> /dev/null
|
||||
mkdir /tmp/unar
|
||||
cd /tmp/unar
|
||||
if [[ $useExternalURL ]]; then
|
||||
wget -O unar-1.8.1.zip https://github.com/incbee/Unarchiver/archive/unar-1.8.1.zip
|
||||
unzip -o unar-1.8.1.zip &> /dev/null
|
||||
fi
|
||||
if [ ! -d *Unarchiver*/XADMaster ]; then # need single bracket for glob
|
||||
wget -O unar-1.8.1.zip ${binaryURL}external/source/unar-1.8.1.zip
|
||||
unzip -o unar-1.8.1.zip &> /dev/null
|
||||
fi
|
||||
cd *Unarchiver*/XADMaster
|
||||
make -f Makefile.linux
|
||||
sudo mv lsar unar /usr/local/bin
|
||||
cd ../Extra
|
||||
sudo mv lsar.1 unar.1 /usr/local/man/man1
|
||||
cd
|
||||
rm -rf /tmp/unar
|
||||
fi
|
||||
sudo mandb &> /dev/null
|
||||
fi
|
||||
else
|
||||
echo "A2SERVER: The Unarchiver has already been installed."
|
||||
echo "A2SERVER: The Unarchiver has already been installed."
|
||||
fi
|
||||
|
||||
if ! hash unzip &> /dev/null; then
|
||||
echo "A2SERVER: Installing unzip..."
|
||||
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
|
||||
# prepare for installing packages
|
||||
sudo apt-get -y update
|
||||
touch /tmp/a2server-packageReposUpdated
|
||||
fi
|
||||
echo "A2SERVER: Installing unzip..."
|
||||
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
|
||||
# prepare for installing packages
|
||||
sudo apt-get -y update
|
||||
touch /tmp/a2server-packageReposUpdated
|
||||
fi
|
||||
|
||||
# Dependencies: unzip
|
||||
sudo apt-get -y install unzip
|
||||
sudo apt-get clean
|
||||
# Dependencies: unzip
|
||||
sudo apt-get -y install unzip
|
||||
sudo apt-get clean
|
||||
else
|
||||
echo "A2SERVER: unzip has already been installed."
|
||||
echo "A2SERVER: unzip has already been installed."
|
||||
fi
|
||||
|
||||
sudo wget -q -O /usr/local/bin/afpsync "${scriptURL}scripts/tools/afpsync.txt"
|
||||
@@ -203,9 +203,9 @@ echo "source /usr/local/etc/a2serverrc" | sudo tee -a /etc/bash.bashrc > /dev/nu
|
||||
|
||||
motd="/etc/motd"
|
||||
if [[ ! $(grep A2SERVER $motd) ]]; then
|
||||
echo | sudo tee -a $motd > /dev/null
|
||||
echo "Type 'system-shutdown' to turn off A2SERVER." | sudo tee -a $motd > /dev/null
|
||||
echo "Type 'a2server-setup' to configure network boot." | sudo tee -a $motd > /dev/null
|
||||
echo "Type 'a2server-help' for a list of other commands." | sudo tee -a $motd > /dev/null
|
||||
echo | sudo tee -a $motd > /dev/null
|
||||
echo | sudo tee -a $motd > /dev/null
|
||||
echo "Type 'system-shutdown' to turn off A2SERVER." | sudo tee -a $motd > /dev/null
|
||||
echo "Type 'a2server-setup' to configure network boot." | sudo tee -a $motd > /dev/null
|
||||
echo "Type 'a2server-help' for a list of other commands." | sudo tee -a $motd > /dev/null
|
||||
echo | sudo tee -a $motd > /dev/null
|
||||
fi
|
||||
|
||||
+467
-467
File diff suppressed because it is too large
Load Diff
+993
-993
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# Set up A2SERVER to support Samba (Windows File Sharing)
|
||||
# this script can also be used if new shares are introduced
|
||||
@@ -8,79 +8,79 @@
|
||||
|
||||
if [[ ! $autoAnswerYes || -f /tmp/a2server-setupWindowsSharing ]]; then
|
||||
|
||||
if [[ ! $autoAnswerYes ]]; then
|
||||
echo
|
||||
echo -n "Should Windows computers be able to connect to A2SERVER? "
|
||||
read
|
||||
fi
|
||||
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
if [[ ! $autoAnswerYes ]]; then
|
||||
echo
|
||||
echo -n "Should Windows computers be able to connect to A2SERVER? "
|
||||
read
|
||||
fi
|
||||
if [[ $autoAnswerYes || ${REPLY:0:1} == "Y" || ${REPLY:0:1} == "y" ]]; then
|
||||
|
||||
echo "A2SERVER: Setting up Windows file sharing..."
|
||||
sudo true
|
||||
echo "A2SERVER: Setting up Windows file sharing..."
|
||||
sudo true
|
||||
|
||||
sudo update-rc.d samba defaults &> /dev/null
|
||||
[[ ! -f /etc/init.d/samba ]] && installSamba=1
|
||||
sudo update-rc.d samba defaults &> /dev/null
|
||||
[[ ! -f /etc/init.d/samba ]] && installSamba=1
|
||||
|
||||
if (( $installSamba )); then
|
||||
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
|
||||
# prepare for installing packages
|
||||
sudo apt-get -y update
|
||||
touch /tmp/a2server-packageReposUpdated
|
||||
fi
|
||||
if (( $installSamba )); then
|
||||
if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then
|
||||
# prepare for installing packages
|
||||
sudo apt-get -y update
|
||||
touch /tmp/a2server-packageReposUpdated
|
||||
fi
|
||||
|
||||
# Dependency: samba for Windows/modern Macs
|
||||
# FIXME: Figure out when smbpasswd moved and adjust this as necessary
|
||||
sudo apt-get -y install samba
|
||||
hash smbpasswd &> /dev/null || sudo apt-get -y install samba-common-bin
|
||||
sudo apt-get clean
|
||||
fi
|
||||
# Dependency: samba for Windows/modern Macs
|
||||
# FIXME: Figure out when smbpasswd moved and adjust this as necessary
|
||||
sudo apt-get -y install samba
|
||||
hash smbpasswd &> /dev/null || sudo apt-get -y install samba-common-bin
|
||||
sudo apt-get clean
|
||||
fi
|
||||
|
||||
sudo /etc/init.d/samba start &> /dev/null
|
||||
sudo /etc/init.d/samba start &> /dev/null
|
||||
|
||||
workgroup=$(grep -o "^ workgroup = .*$" /etc/samba/smb.conf 2> /dev/null | cut -c 16-)
|
||||
[[ $workgroup ]] || workgroup="WORKGROUP"
|
||||
if [[ ! $autoAnswerYes ]]; then
|
||||
echo
|
||||
echo "Enter workgroup name (or press return for '${workgroup}'): "
|
||||
read
|
||||
[[ $REPLY ]] && workgroup=$REPLY
|
||||
fi
|
||||
sudo sed -i 's/^ workgroup = .*$/ workgroup = '$workgroup'/' /etc/samba/smb.conf 2> /dev/null
|
||||
sudo sed -i 's/^# security = user/ security = user/' /etc/samba/smb.conf 2> /dev/null
|
||||
workgroup=$(grep -o "^ workgroup = .*$" /etc/samba/smb.conf 2> /dev/null | cut -c 16-)
|
||||
[[ $workgroup ]] || workgroup="WORKGROUP"
|
||||
if [[ ! $autoAnswerYes ]]; then
|
||||
echo
|
||||
echo "Enter workgroup name (or press return for '${workgroup}'): "
|
||||
read
|
||||
[[ $REPLY ]] && workgroup=$REPLY
|
||||
fi
|
||||
sudo sed -i 's/^ workgroup = .*$/ workgroup = '$workgroup'/' /etc/samba/smb.conf 2> /dev/null
|
||||
sudo sed -i 's/^# security = user/ security = user/' /etc/samba/smb.conf 2> /dev/null
|
||||
|
||||
# remove GSFILES if no longer serving it
|
||||
if ! grep ^/srv/A2SERVER/GSFILES /usr/local/etc/netatalk/AppleVolumes.default; then
|
||||
sudo sed -i ':a;N;$!ba;s#\n\[GSFILES\].*\[#\n[#' /etc/samba/smb.conf
|
||||
sudo sed -i ':a;N;$!ba;s#\n\[GSFILES\].*$#\n#' /etc/samba/smb.conf
|
||||
fi
|
||||
# remove GSFILES if no longer serving it
|
||||
if ! grep ^/srv/A2SERVER/GSFILES /usr/local/etc/netatalk/AppleVolumes.default; then
|
||||
sudo sed -i ':a;N;$!ba;s#\n\[GSFILES\].*\[#\n[#' /etc/samba/smb.conf
|
||||
sudo sed -i ':a;N;$!ba;s#\n\[GSFILES\].*$#\n#' /etc/samba/smb.conf
|
||||
fi
|
||||
|
||||
grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | cut -d" " -f2 \
|
||||
| while read sharename; do
|
||||
if [[ $(grep $sharename /etc/samba/smb.conf) ]]; then
|
||||
echo "A2SERVER: $sharename is already set up for Windows file sharing."
|
||||
else
|
||||
echo "[$sharename]" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " path = /srv/A2SERVER/$sharename" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " browsable = yes" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " guest ok = yes" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " read only = no" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " create mask = 0666" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " force user = $USER" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo "A2SERVER: $sharename has been set up for Windows file sharing."
|
||||
fi
|
||||
done
|
||||
grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | cut -d" " -f2 \
|
||||
| while read sharename; do
|
||||
if [[ $(grep $sharename /etc/samba/smb.conf) ]]; then
|
||||
echo "A2SERVER: $sharename is already set up for Windows file sharing."
|
||||
else
|
||||
echo "[$sharename]" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " path = /srv/A2SERVER/$sharename" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " browsable = yes" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " guest ok = yes" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " read only = no" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " create mask = 0666" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo " force user = $USER" | sudo tee -a /etc/samba/smb.conf > /dev/null
|
||||
echo "A2SERVER: $sharename has been set up for Windows file sharing."
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
echo "A2SERVER: Setting Windows file sharing password to 'apple2'."
|
||||
echo -e 'apple2\napple2' | sudo smbpasswd -s -a $USER
|
||||
echo
|
||||
echo "A2SERVER: Setting Windows file sharing password to 'apple2'."
|
||||
echo -e 'apple2\napple2' | sudo smbpasswd -s -a $USER
|
||||
|
||||
echo
|
||||
echo "A2SERVER: Windows file sharing is now running."
|
||||
else
|
||||
sudo /etc/init.d/samba stop &> /dev/null
|
||||
sudo update-rc.d -f samba remove &> /dev/null
|
||||
echo "A2SERVER: Windows file sharing has been turned off."
|
||||
fi
|
||||
echo
|
||||
echo "A2SERVER: Windows file sharing is now running."
|
||||
else
|
||||
sudo /etc/init.d/samba stop &> /dev/null
|
||||
sudo update-rc.d -f samba remove &> /dev/null
|
||||
echo "A2SERVER: Windows file sharing has been turned off."
|
||||
fi
|
||||
|
||||
echo
|
||||
echo
|
||||
fi
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# This script helps when running on the Linux console within a VirtualBox VM.
|
||||
|
||||
@@ -17,11 +17,11 @@ isDebian=
|
||||
b_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian' && [[ ( -f /etc/debian_version ) && ( $(cut -d . -f 1 < /etc/debian_version) -ge "7" ) ]] && isDebian=1
|
||||
|
||||
if [[ $isDebian ]]; then
|
||||
if { lspci 2> /dev/null | grep -q VirtualBox; }; then
|
||||
echo "A2SERVER: Disabling VirtualBox console screen blanking..."
|
||||
sudo sed -i 's/^BLANK_DPMS=off/BLANK_DPMS=on/' /etc/kbd/config
|
||||
sudo sed -i 's/^BLANK_TIME=[^0].$/BLANK_TIME=0/' /etc/kbd/config
|
||||
sudo /etc/init.d/kbd restart &> /dev/null
|
||||
sudo /etc/init.d/console-setup restart &> /dev/null
|
||||
fi
|
||||
if { lspci 2> /dev/null | grep -q VirtualBox; }; then
|
||||
echo "A2SERVER: Disabling VirtualBox console screen blanking..."
|
||||
sudo sed -i 's/^BLANK_DPMS=off/BLANK_DPMS=on/' /etc/kbd/config
|
||||
sudo sed -i 's/^BLANK_TIME=[^0].$/BLANK_TIME=0/' /etc/kbd/config
|
||||
sudo /etc/init.d/kbd restart &> /dev/null
|
||||
sudo /etc/init.d/console-setup restart &> /dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
+168
-167
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# raspbian-update
|
||||
# updates Raspbian to latest version, including NOOBS if installed
|
||||
@@ -6,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=
|
||||
@@ -15,30 +16,30 @@ 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=
|
||||
@@ -49,138 +50,138 @@ if [[ \
|
||||
${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"
|
||||
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; } &> /dev/null
|
||||
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; } &> /dev/null
|
||||
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; } &> /dev/null
|
||||
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; } &> /dev/null
|
||||
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
|
||||
@@ -190,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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
alias a2server-help="more /usr/local/etc/a2server-help.txt"
|
||||
alias a2server-setup='wget -q -O /tmp/a2server-setup ${A2SERVER_SCRIPT_URL:-https://raw.githubusercontent.com/RasppleII/a2server/current/}setup/index.txt || { echo "Can'"'"'t download A2SERVER setup scripts. Do you has internet?"; false; } && source /tmp/a2server-setup'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
export A2SERVER_SCRIPT_URL="${A2SERVER_SCRIPT_URL:-https://raw.githubusercontent.com/RasppleII/a2server/current/}"
|
||||
export A2SERVER_BINARY_URL="${A2SERVER_BINARY_URL:-http://ivanx.com/a2server/files/}"
|
||||
|
||||
+88
-88
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# afpsync: updates .AppleDouble components of files on shared volumes
|
||||
|
||||
@@ -15,102 +15,102 @@
|
||||
# /usr/local/etc/netatalk/AppleVolumes.default are synced.
|
||||
|
||||
processPath () {
|
||||
if [[ ! -d $sharepath ]]; then
|
||||
echo "$sharepath does not exist."
|
||||
else
|
||||
volinfo="$sharepath/.AppleDesktop/.volinfo"
|
||||
if [[ ! -f $volinfo ]]; then
|
||||
if [[ ! $force ]]; then
|
||||
echo "Cannot update AppleDouble files for volume $sharepath,"
|
||||
echo "because its .volinfo file does not exist. To create it, log"
|
||||
echo "into the volume from an Apple II or Mac client computer,"
|
||||
echo "or use \"afpsync -v\"."
|
||||
else
|
||||
if (( $1 )); then
|
||||
mkvolinfo -f -c $sharepath
|
||||
else
|
||||
mkvolinfo -f $sharepath
|
||||
fi
|
||||
$0 $sharepath
|
||||
fi
|
||||
else
|
||||
IFS=''
|
||||
result=$(sudo dbd -r $sharepath | grep encoding)
|
||||
f=$(wc -l <<< $result)
|
||||
[[ $(wc -w <<< $result) == 0 ]] && f=0
|
||||
[[ $f -eq 1 && $(grep AppleDesktop <<< "$result") && $(grep MTOULOWER $sharepath/.AppleDesktop/.volinfo) ]] && (( f-- ))
|
||||
if (( f == 0 )); then
|
||||
echo "AppleDouble files have been updated for volume $sharepath."
|
||||
else
|
||||
[[ ! $renameLower ]] && echo "Could not update all files on volume $sharepath."
|
||||
if [[ $showerrors ]]; then
|
||||
echo $result \
|
||||
| while read LINE; do
|
||||
[[ ! $(echo $LINE | grep APPLEDESKTOP) ]] && echo $LINE
|
||||
done
|
||||
elif [[ $renameLower ]]; then
|
||||
echo $result \
|
||||
| while read LINE; do
|
||||
if [[ ! $(echo $LINE | grep APPLEDESKTOP) ]]; then
|
||||
filepath=$(echo $LINE | sed "s/^Bad\ encoding\ for\ '//" | sed s/\'//)
|
||||
filename=${filepath##*/}
|
||||
filedir=${filepath%/*}
|
||||
mv $filepath $filedir/${filename^^}
|
||||
echo "Renamed $filedir/${filename^^}."
|
||||
fi
|
||||
done
|
||||
$0 $sharepath
|
||||
else
|
||||
echo "Use afpsync -e to see error details."
|
||||
fi
|
||||
fi
|
||||
unset IFS
|
||||
fi
|
||||
fi
|
||||
if [[ ! -d $sharepath ]]; then
|
||||
echo "$sharepath does not exist."
|
||||
else
|
||||
volinfo="$sharepath/.AppleDesktop/.volinfo"
|
||||
if [[ ! -f $volinfo ]]; then
|
||||
if [[ ! $force ]]; then
|
||||
echo "Cannot update AppleDouble files for volume $sharepath,"
|
||||
echo "because its .volinfo file does not exist. To create it, log"
|
||||
echo "into the volume from an Apple II or Mac client computer,"
|
||||
echo "or use \"afpsync -v\"."
|
||||
else
|
||||
if (( $1 )); then
|
||||
mkvolinfo -f -c $sharepath
|
||||
else
|
||||
mkvolinfo -f $sharepath
|
||||
fi
|
||||
$0 $sharepath
|
||||
fi
|
||||
else
|
||||
IFS=''
|
||||
result=$(sudo dbd -r $sharepath | grep encoding)
|
||||
f=$(wc -l <<< $result)
|
||||
[[ $(wc -w <<< $result) == 0 ]] && f=0
|
||||
[[ $f -eq 1 && $(grep AppleDesktop <<< "$result") && $(grep MTOULOWER $sharepath/.AppleDesktop/.volinfo) ]] && (( f-- ))
|
||||
if (( f == 0 )); then
|
||||
echo "AppleDouble files have been updated for volume $sharepath."
|
||||
else
|
||||
[[ ! $renameLower ]] && echo "Could not update all files on volume $sharepath."
|
||||
if [[ $showerrors ]]; then
|
||||
echo $result \
|
||||
| while read LINE; do
|
||||
[[ ! $(echo $LINE | grep APPLEDESKTOP) ]] && echo $LINE
|
||||
done
|
||||
elif [[ $renameLower ]]; then
|
||||
echo $result \
|
||||
| while read LINE; do
|
||||
if [[ ! $(echo $LINE | grep APPLEDESKTOP) ]]; then
|
||||
filepath=$(echo $LINE | sed "s/^Bad\ encoding\ for\ '//" | sed s/\'//)
|
||||
filename=${filepath##*/}
|
||||
filedir=${filepath%/*}
|
||||
mv $filepath $filedir/${filename^^}
|
||||
echo "Renamed $filedir/${filename^^}."
|
||||
fi
|
||||
done
|
||||
$0 $sharepath
|
||||
else
|
||||
echo "Use afpsync -e to see error details."
|
||||
fi
|
||||
fi
|
||||
unset IFS
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
while [[ $1 == "-r" || $1 == "-e" || $1 = "-v" ]]; do
|
||||
|
||||
if [[ $1 == "-v" ]]; then
|
||||
force=1
|
||||
shift
|
||||
fi
|
||||
if [[ $1 == "-v" ]]; then
|
||||
force=1
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ $1 == "-e" ]]; then
|
||||
showerrors=1
|
||||
shift
|
||||
fi
|
||||
if [[ $1 == "-e" ]]; then
|
||||
showerrors=1
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ $1 == "-r" ]]; then
|
||||
renameLower=1
|
||||
shift
|
||||
fi
|
||||
if [[ $1 == "-r" ]]; then
|
||||
renameLower=1
|
||||
shift
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if [[ ${1:0:1} == "-" ]]; then
|
||||
echo "Usage: afpsync [-e|-r] [-v] [shared volume path]"
|
||||
echo
|
||||
echo "-e: show error details"
|
||||
echo "-r: rename lowercase filenames to uppercase"
|
||||
echo "-v: create .volinfo file if none exists"
|
||||
echo "If no directory is specified, all found in"
|
||||
echo " /usr/local/etc/netatalk/AppleVolumes.default are processed."
|
||||
echo
|
||||
echo "Usage: afpsync [-e|-r] [-v] [shared volume path]"
|
||||
echo
|
||||
echo "-e: show error details"
|
||||
echo "-r: rename lowercase filenames to uppercase"
|
||||
echo "-v: create .volinfo file if none exists"
|
||||
echo "If no directory is specified, all found in"
|
||||
echo " /usr/local/etc/netatalk/AppleVolumes.default are processed."
|
||||
echo
|
||||
else
|
||||
sudo true
|
||||
if [[ $1 ]]; then
|
||||
sharepath=$(readlink -m $1)
|
||||
# behavior change in 1.3.0: now defaults to mixed case
|
||||
# on a volume when specifying a folder and -v
|
||||
# (as opposed to defaulting to casefold:toupper previously)
|
||||
processPath 1
|
||||
else
|
||||
grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | \
|
||||
while read line; do
|
||||
[[ $(echo $line | grep toupper) ]]; nocasefold=$?
|
||||
sharepath=$(echo $line | cut -d" " -f1)
|
||||
processPath nocasefold
|
||||
done
|
||||
fi
|
||||
sudo true
|
||||
if [[ $1 ]]; then
|
||||
sharepath=$(readlink -m $1)
|
||||
# behavior change in 1.3.0: now defaults to mixed case
|
||||
# on a volume when specifying a folder and -v
|
||||
# (as opposed to defaulting to casefold:toupper previously)
|
||||
processPath 1
|
||||
else
|
||||
grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | \
|
||||
while read line; do
|
||||
[[ $(echo $line | grep toupper) ]]; nocasefold=$?
|
||||
sharepath=$(echo $line | cut -d" " -f1)
|
||||
processPath nocasefold
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
+276
-276
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# 2-25-11: tested on 10.6.5 and Ubuntu 10.10. Final.
|
||||
|
||||
@@ -56,12 +56,12 @@ decToHex () {
|
||||
# arg: decimal value from 0-255
|
||||
# out: two-digit hex value from 00-FF
|
||||
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ( $(printf %d "$1" 2> /dev/null) == $1 ) \
|
||||
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
|
||||
# args are valid
|
||||
printf %02X "$1"
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ( $(printf %d "$1" 2> /dev/null) == $1 ) \
|
||||
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
|
||||
# args are valid
|
||||
printf %02X "$1"
|
||||
}
|
||||
|
||||
hexToDec () {
|
||||
@@ -69,13 +69,13 @@ hexToDec () {
|
||||
# arg: two-digit hex value from 00-FF
|
||||
# out: decimal value
|
||||
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ${#1} -eq 2 ]] || return 21
|
||||
[[ $(printf %02X "0x$1" 2> /dev/null) == \
|
||||
$(echo -n "$1" | tr [a-z] [A-Z]) ]] || return 21
|
||||
# args are valid
|
||||
printf %d "0x$1"
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ${#1} -eq 2 ]] || return 21
|
||||
[[ $(printf %02X "0x$1" 2> /dev/null) == \
|
||||
$(echo -n "$1" | tr [a-z] [A-Z]) ]] || return 21
|
||||
# args are valid
|
||||
printf %d "0x$1"
|
||||
}
|
||||
|
||||
charToDec () {
|
||||
@@ -85,15 +85,15 @@ charToDec () {
|
||||
# out: decimal value from 0-255
|
||||
#exit: 8=extraneous arg, 9=invalid stdin,
|
||||
# 11=missing stdin/arg, 21=invalid arg
|
||||
[[ ( ! -t 0 ) && $1 ]] && { cat > /dev/null; return 8; }
|
||||
[[ ( -t 0 ) ]] && { [[ $2 ]] && return 8; [[ $1 ]] || return 11; }
|
||||
# arg/stdin is potentially valid (additional check below)
|
||||
charX="$1X"; [[ $1 ]] || charX="$(cat; echo -n 'X';)"
|
||||
[[ ${#charX} -le 2 ]] || return $(( $([[ $1 ]]; echo $?) ? 9 : 21 ))
|
||||
# above line verifies that arg/stdin is valid
|
||||
[[ ${#charX} -ne 2 ]] && { echo -n 0; return 0; }
|
||||
echo -n "${charX:0:1}" | od -t u1 | \
|
||||
head -1 | sed 's/[0\ ]*//' | tr -d ' \n'
|
||||
[[ ( ! -t 0 ) && $1 ]] && { cat > /dev/null; return 8; }
|
||||
[[ ( -t 0 ) ]] && { [[ $2 ]] && return 8; [[ $1 ]] || return 11; }
|
||||
# arg/stdin is potentially valid (additional check below)
|
||||
charX="$1X"; [[ $1 ]] || charX="$(cat; echo -n 'X';)"
|
||||
[[ ${#charX} -le 2 ]] || return $(( $([[ $1 ]]; echo $?) ? 9 : 21 ))
|
||||
# above line verifies that arg/stdin is valid
|
||||
[[ ${#charX} -ne 2 ]] && { echo -n 0; return 0; }
|
||||
echo -n "${charX:0:1}" | od -t u1 | \
|
||||
head -1 | sed 's/[0\ ]*//' | tr -d ' \n'
|
||||
}
|
||||
|
||||
charToHex () {
|
||||
@@ -103,15 +103,15 @@ charToHex () {
|
||||
# out: decimal value from 0-255
|
||||
#exit: 8=extraneous arg, 9=invalid stdin,
|
||||
# 11=missing stdin/arg, 21=invalid arg
|
||||
[[ ( ! -t 0 ) && $1 ]] && { cat > /dev/null; return 8; }
|
||||
[[ ( -t 0 ) ]] && { [[ $2 ]] && return 8; [[ $1 ]] || return 11; }
|
||||
# arg/stdin is potentially valid (additional check below)
|
||||
charX="$1X"; [[ $1 ]] || charX="$(cat; echo -n 'X';)"
|
||||
[[ ${#charX} -le 2 ]] || return $(( $([[ $1 ]]; echo $?) ? 9 : 21 ))
|
||||
# above line verifies that stdin/arg is valid
|
||||
[[ ${#charX} -ne 2 ]] && { echo -n "00"; return 0; }
|
||||
printf %02X $(echo -n "${charX:0:1}" | od -t u1 | \
|
||||
head -1 | sed 's/[0\ ]*//' | tr -d ' \n')
|
||||
[[ ( ! -t 0 ) && $1 ]] && { cat > /dev/null; return 8; }
|
||||
[[ ( -t 0 ) ]] && { [[ $2 ]] && return 8; [[ $1 ]] || return 11; }
|
||||
# arg/stdin is potentially valid (additional check below)
|
||||
charX="$1X"; [[ $1 ]] || charX="$(cat; echo -n 'X';)"
|
||||
[[ ${#charX} -le 2 ]] || return $(( $([[ $1 ]]; echo $?) ? 9 : 21 ))
|
||||
# above line verifies that stdin/arg is valid
|
||||
[[ ${#charX} -ne 2 ]] && { echo -n "00"; return 0; }
|
||||
printf %02X $(echo -n "${charX:0:1}" | od -t u1 | \
|
||||
head -1 | sed 's/[0\ ]*//' | tr -d ' \n')
|
||||
}
|
||||
|
||||
decToChar () {
|
||||
@@ -119,12 +119,12 @@ decToChar () {
|
||||
# arg: decimal number from 0-255
|
||||
# out: one character
|
||||
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ( $(printf %d "$1" 2> /dev/null ) == $1 ) \
|
||||
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
|
||||
# args are valid
|
||||
echo -n -e "\x$(printf %02X "$1")"
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ( $(printf %d "$1" 2> /dev/null ) == $1 ) \
|
||||
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
|
||||
# args are valid
|
||||
echo -n -e "\x$(printf %02X "$1")"
|
||||
}
|
||||
|
||||
hexToChar () {
|
||||
@@ -132,13 +132,13 @@ hexToChar () {
|
||||
# arg: two-digit hexadecimal number from 00-FF
|
||||
# out: one character
|
||||
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ${#1} -eq 2 ]] || return 21
|
||||
[[ $(printf %02X "0x$1" 2> /dev/null) == \
|
||||
$(echo -n "$1" | tr [a-z] [A-Z]) ]] || return 21
|
||||
# args are valid
|
||||
echo -n -e "\x$1"
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ${#1} -eq 2 ]] || return 21
|
||||
[[ $(printf %02X "0x$1" 2> /dev/null) == \
|
||||
$(echo -n "$1" | tr [a-z] [A-Z]) ]] || return 21
|
||||
# args are valid
|
||||
echo -n -e "\x$1"
|
||||
}
|
||||
|
||||
readchars () {
|
||||
@@ -149,16 +149,16 @@ readchars () {
|
||||
# out: sequence of characters
|
||||
# exit: 8=extraneous arg, 11=missing arg1,
|
||||
# 21=invalid arg1, 22=invalid arg2, 23=invalid arg3
|
||||
[[ $1 ]] || return 11
|
||||
[[ $4 ]] && return 8
|
||||
[[ -f $1 ]] || return 21
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) \
|
||||
&& ( $2 -ge 0 ) ]] || return 22; }
|
||||
[[ $3 ]] && { [[ ( $(printf %d "$3" 2> /dev/null) == $3 ) \
|
||||
&& ( $3 -ge 0 ) ]] || return 23; }
|
||||
# args are valid
|
||||
dd if="$1" bs=1 skip=$(($2)) $([[ $3 ]] && echo -n "count=$3") \
|
||||
2> /dev/null
|
||||
[[ $1 ]] || return 11
|
||||
[[ $4 ]] && return 8
|
||||
[[ -f $1 ]] || return 21
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) \
|
||||
&& ( $2 -ge 0 ) ]] || return 22; }
|
||||
[[ $3 ]] && { [[ ( $(printf %d "$3" 2> /dev/null) == $3 ) \
|
||||
&& ( $3 -ge 0 ) ]] || return 23; }
|
||||
# args are valid
|
||||
dd if="$1" bs=1 skip=$(($2)) $([[ $3 ]] && echo -n "count=$3") \
|
||||
2> /dev/null
|
||||
}
|
||||
|
||||
readcharDec () {
|
||||
@@ -168,17 +168,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 () {
|
||||
@@ -188,17 +188,17 @@ 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')
|
||||
}
|
||||
|
||||
### 2-15-11 above tested on OS X and Linux
|
||||
@@ -212,18 +212,18 @@ writechars () {
|
||||
# out: nothing
|
||||
# exit: 8=extraneous arg, 11=missing arg1,
|
||||
# 13=missing stdin/arg3, 22=invalid arg2
|
||||
[[ $1 ]] || { [[ -t 0 ]] || cat > /dev/null; return 11; }
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) && \
|
||||
( $2 -ge 0 ) ]] || { [[ -t 0 ]] || cat > /dev/null; return 22; } }
|
||||
[[ ( ! -t 0 ) && $3 ]] && { cat > /dev/null; return 8; }
|
||||
[[ ( -t 0 ) ]] && { [[ $4 ]] && return 8; [[ $3 ]] || return 13; }
|
||||
# args are valid
|
||||
if [[ -t 0 ]]; then
|
||||
echo -n "$3" | \
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
else
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
fi
|
||||
[[ $1 ]] || { [[ -t 0 ]] || cat > /dev/null; return 11; }
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) && \
|
||||
( $2 -ge 0 ) ]] || { [[ -t 0 ]] || cat > /dev/null; return 22; } }
|
||||
[[ ( ! -t 0 ) && $3 ]] && { cat > /dev/null; return 8; }
|
||||
[[ ( -t 0 ) ]] && { [[ $4 ]] && return 8; [[ $3 ]] || return 13; }
|
||||
# args are valid
|
||||
if [[ -t 0 ]]; then
|
||||
echo -n "$3" | \
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
else
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
writecharDec () {
|
||||
@@ -234,15 +234,15 @@ writecharDec () {
|
||||
# exit: 8=extraneous arg, 11=missing arg1, 12=missing arg2,
|
||||
# 13=missing arg3, 22=invalid arg2, 23=invalid arg3
|
||||
# out: nothing
|
||||
[[ $1 ]] || return 11; [[ $2 ]] || return 12; [[ $3 ]] || return 13
|
||||
[[ $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
|
||||
# args are valid
|
||||
echo -n -e "\x$(printf %02X "$3")" | \
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
[[ $1 ]] || return 11; [[ $2 ]] || return 12; [[ $3 ]] || return 13
|
||||
[[ $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
|
||||
# args are valid
|
||||
echo -n -e "\x$(printf %02X "$3")" | \
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
}
|
||||
|
||||
writecharHex () {
|
||||
@@ -253,23 +253,23 @@ writecharHex () {
|
||||
# out: nothing
|
||||
# exit: 8=extraneous arg, 11=missing arg1, 12=missing arg2,
|
||||
# 13=missing arg3, 22=invalid arg2, 23=invalid arg3
|
||||
[[ $1 ]] || return 11; [[ $2 ]] || return 12; [[ $3 ]] || return 13
|
||||
[[ $4 ]] && return 8
|
||||
[[ ( $(printf %d "$2" 2> /dev/null) == $2 ) \
|
||||
&& ( $2 -ge 0 ) ]] || return 22
|
||||
[[ $(printf %02X "0x$3" 2> /dev/null) == \
|
||||
$(echo -n "$3" | tr [a-z] [A-Z]) ]] || return 23
|
||||
# args are valid
|
||||
echo -n -e "\x$3" | \
|
||||
dd of="$1" bs=1 seek=$2 conv=notrunc 2> /dev/null
|
||||
[[ $1 ]] || return 11; [[ $2 ]] || return 12; [[ $3 ]] || return 13
|
||||
[[ $4 ]] && return 8
|
||||
[[ ( $(printf %d "$2" 2> /dev/null) == $2 ) \
|
||||
&& ( $2 -ge 0 ) ]] || return 22
|
||||
[[ $(printf %02X "0x$3" 2> /dev/null) == \
|
||||
$(echo -n "$3" | tr [a-z] [A-Z]) ]] || return 23
|
||||
# args are valid
|
||||
echo -n -e "\x$3" | \
|
||||
dd of="$1" bs=1 seek=$2 conv=notrunc 2> /dev/null
|
||||
}
|
||||
|
||||
|
||||
# --- afptype is below this line
|
||||
|
||||
isHexByte () {
|
||||
[[ $(printf %02X "0x$1" 2> /dev/null) == \
|
||||
$(echo -n "$1" | tr [a-z] [A-Z]) ]] || return 1
|
||||
[[ $(printf %02X "0x$1" 2> /dev/null) == \
|
||||
$(echo -n "$1" | tr [a-z] [A-Z]) ]] || return 1
|
||||
}
|
||||
|
||||
# support 00 and 0A as filetype chars?
|
||||
@@ -278,27 +278,27 @@ debug=1
|
||||
ptypes="04:TXT 06:BIN B3:S16 E0:SHK F9:P16 FA:INT FC:BAS FF:SYS"
|
||||
|
||||
quit () {
|
||||
if [[ $2 && $debug ]]; then
|
||||
echo "$1" "$2"
|
||||
else
|
||||
echo -e "Error: $1"
|
||||
fi
|
||||
exit_usage
|
||||
if [[ $2 && $debug ]]; then
|
||||
echo "$1" "$2"
|
||||
else
|
||||
echo -e "Error: $1"
|
||||
fi
|
||||
exit_usage
|
||||
}
|
||||
|
||||
exit_usage () {
|
||||
echo "Usage:"
|
||||
echo
|
||||
echo "show types: afptype filename"
|
||||
echo "set Mac OS: afptype [-t 'type'] [-c 'creator'] [-q] filename"
|
||||
echo "set ProDOS: afptype [-p type] [-a auxtype] [-q] filename"
|
||||
echo "Mac OS type or creator must be four characters; use \x plus"
|
||||
echo " two hex digits for untypeables (note: use '\xZZ' for 00)."
|
||||
echo "ProDOS type should be two hex digits, and auxtype should be four;"
|
||||
echo " type can alternatively be BAS, BIN, INT, P16, S16, SHK, SYS, TXT."
|
||||
echo "-q skips recheck of file (show types) after setting"
|
||||
echo
|
||||
exit 1
|
||||
echo "Usage:"
|
||||
echo
|
||||
echo "show types: afptype filename"
|
||||
echo "set Mac OS: afptype [-t 'type'] [-c 'creator'] [-q] filename"
|
||||
echo "set ProDOS: afptype [-p type] [-a auxtype] [-q] filename"
|
||||
echo "Mac OS type or creator must be four characters; use \x plus"
|
||||
echo " two hex digits for untypeables (note: use '\xZZ' for 00)."
|
||||
echo "ProDOS type should be two hex digits, and auxtype should be four;"
|
||||
echo " type can alternatively be BAS, BIN, INT, P16, S16, SHK, SYS, TXT."
|
||||
echo "-q skips recheck of file (show types) after setting"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
lookupPdosType () {
|
||||
@@ -306,65 +306,65 @@ lookupPdosType () {
|
||||
# arg: three-character code
|
||||
# out: two-digit hex value
|
||||
#exit: 0=type found, 1=error, 2=type not found
|
||||
ptypes="04:TXT 06:BIN B3:S16 E0:SHK F9:P16 FA:INT FC:BAS FF:SYS"
|
||||
[[ $1 ]] || quit "lookupPdosType:" "no argument supplied ($1)"
|
||||
[[ ${#1} -eq 3 ]] || return 1
|
||||
arg=$(echo -n "$1" | tr [a-z] [A-Z])
|
||||
for ptype in $ptypes; do
|
||||
if [[ ${ptype:3:3} == $arg ]]; then
|
||||
echo -n "${ptype:0:2}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo "$1"
|
||||
return 1
|
||||
ptypes="04:TXT 06:BIN B3:S16 E0:SHK F9:P16 FA:INT FC:BAS FF:SYS"
|
||||
[[ $1 ]] || quit "lookupPdosType:" "no argument supplied ($1)"
|
||||
[[ ${#1} -eq 3 ]] || return 1
|
||||
arg=$(echo -n "$1" | tr [a-z] [A-Z])
|
||||
for ptype in $ptypes; do
|
||||
if [[ ${ptype:3:3} == $arg ]]; then
|
||||
echo -n "${ptype:0:2}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo "$1"
|
||||
return 1
|
||||
}
|
||||
|
||||
verifyTC () {
|
||||
[[ $1 ]] || return 1
|
||||
tcX="$(echo -e -n "$1"X)"
|
||||
[[ ${#tcX} -eq 5 ]] || return 1
|
||||
echo "$tcX"
|
||||
[[ $1 ]] || return 1
|
||||
tcX="$(echo -e -n "$1"X)"
|
||||
[[ ${#tcX} -eq 5 ]] || return 1
|
||||
echo "$tcX"
|
||||
}
|
||||
|
||||
while [[ $1 && ( "${1:0:1}" == '-' ) ]]; do
|
||||
if [[ $1 == "-p" ]]; then
|
||||
[[ $p ]] && exit_usage
|
||||
shift
|
||||
p="$1"
|
||||
shift
|
||||
continue
|
||||
elif [[ $1 == "-a" ]]; then
|
||||
[[ $a ]] && exit_usage
|
||||
shift
|
||||
a="$1"
|
||||
shift
|
||||
continue
|
||||
elif [[ $1 == "-t" ]]; then
|
||||
[[ $t ]] && exit_usage
|
||||
shift
|
||||
t="$1"
|
||||
shift
|
||||
continue
|
||||
elif [[ $1 == "-c" ]]; then
|
||||
[[ $c ]] && exit_usage
|
||||
shift
|
||||
c="$1"
|
||||
shift
|
||||
continue
|
||||
elif [[ $1 == "-q" ]]; then
|
||||
[[ $q ]] && exit_usage
|
||||
q=1
|
||||
shift
|
||||
continue
|
||||
else
|
||||
exit_usage
|
||||
break
|
||||
fi
|
||||
if [[ $1 == "-p" ]]; then
|
||||
[[ $p ]] && exit_usage
|
||||
shift
|
||||
p="$1"
|
||||
shift
|
||||
continue
|
||||
elif [[ $1 == "-a" ]]; then
|
||||
[[ $a ]] && exit_usage
|
||||
shift
|
||||
a="$1"
|
||||
shift
|
||||
continue
|
||||
elif [[ $1 == "-t" ]]; then
|
||||
[[ $t ]] && exit_usage
|
||||
shift
|
||||
t="$1"
|
||||
shift
|
||||
continue
|
||||
elif [[ $1 == "-c" ]]; then
|
||||
[[ $c ]] && exit_usage
|
||||
shift
|
||||
c="$1"
|
||||
shift
|
||||
continue
|
||||
elif [[ $1 == "-q" ]]; then
|
||||
[[ $q ]] && exit_usage
|
||||
q=1
|
||||
shift
|
||||
continue
|
||||
else
|
||||
exit_usage
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ( ( $p || $a ) && ( $t || $c ) ) || ( -z $1 ) ]]; then
|
||||
exit_usage
|
||||
exit_usage
|
||||
fi
|
||||
|
||||
#filename="$1"
|
||||
@@ -372,119 +372,119 @@ fi
|
||||
|
||||
for filename in $@; do
|
||||
|
||||
[[ ${#@} -gt 1 ]] && linestart="($filename) "
|
||||
[[ ${#@} -gt 1 ]] && linestart="($filename) "
|
||||
|
||||
if [[ ! -f $filename ]]; then
|
||||
echo "${linestart}Not found."
|
||||
continue
|
||||
fi
|
||||
if [[ ! -f $filename ]]; then
|
||||
echo "${linestart}Not found."
|
||||
continue
|
||||
fi
|
||||
|
||||
adname="$(dirname "$filename")/.AppleDouble/$(basename "$filename")"
|
||||
[[ -f $adname ]] && filename=$adname
|
||||
ADversion=$(readcharDec "$filename" 5)
|
||||
if [[ ( ( $ADversion -ne 1 ) && ( $ADversion -ne 2 ) ) \
|
||||
|| ( "$(readchars "$filename" 1 3)" != "$(echo -e -n "\x05\x16\x07")" ) \
|
||||
|| ( $(readcharDec "$filename" 0) -ne 0 ) \
|
||||
|| ( $(readcharDec "$filename" 4) -ne 0 ) \
|
||||
|| ( $(readcharDec "$filename" 6) -ne 0 ) \
|
||||
|| ( $(readcharDec "$filename" 7) -ne 0 ) ]]; then
|
||||
echo "${linestart}Not an AppleDouble file."
|
||||
continue
|
||||
fi
|
||||
adname="$(dirname "$filename")/.AppleDouble/$(basename "$filename")"
|
||||
[[ -f $adname ]] && filename=$adname
|
||||
ADversion=$(readcharDec "$filename" 5)
|
||||
if [[ ( ( $ADversion -ne 1 ) && ( $ADversion -ne 2 ) ) \
|
||||
|| ( "$(readchars "$filename" 1 3)" != "$(echo -e -n "\x05\x16\x07")" ) \
|
||||
|| ( $(readcharDec "$filename" 0) -ne 0 ) \
|
||||
|| ( $(readcharDec "$filename" 4) -ne 0 ) \
|
||||
|| ( $(readcharDec "$filename" 6) -ne 0 ) \
|
||||
|| ( $(readcharDec "$filename" 7) -ne 0 ) ]]; then
|
||||
echo "${linestart}Not an AppleDouble file."
|
||||
continue
|
||||
fi
|
||||
|
||||
entrycount=`readcharDec "$filename" 25`
|
||||
entrycount=`readcharDec "$filename" 25`
|
||||
|
||||
entry=1
|
||||
offset=29
|
||||
entry=1
|
||||
offset=29
|
||||
|
||||
while [[ $(readcharDec "$filename" $offset) -ne 9 ]]; do
|
||||
(( entry = entry + 1 ))
|
||||
if (( entry > entrycount )); then
|
||||
echo "${linestart}Finder Info entry not found in AppleDouble file."
|
||||
break
|
||||
fi
|
||||
(( offset = (entry * 12 + 29) - 12 ))
|
||||
done
|
||||
(( entry > entrycount )) && continue
|
||||
while [[ $(readcharDec "$filename" $offset) -ne 9 ]]; do
|
||||
(( entry = entry + 1 ))
|
||||
if (( entry > entrycount )); then
|
||||
echo "${linestart}Finder Info entry not found in AppleDouble file."
|
||||
break
|
||||
fi
|
||||
(( offset = (entry * 12 + 29) - 12 ))
|
||||
done
|
||||
(( entry > entrycount )) && continue
|
||||
|
||||
(( offset = offset + 3 ))
|
||||
(( tposHi = $(readcharDec "$filename" $offset) * 256 ))
|
||||
(( offset = offset + 1 ))
|
||||
(( tpos = $(readcharDec "$filename" $offset) + tposHi ))
|
||||
(( cpos = tpos + 4 ))
|
||||
(( ppos = tpos + 1 ))
|
||||
(( apos = tpos + 2 ))
|
||||
(( offset = offset + 3 ))
|
||||
(( tposHi = $(readcharDec "$filename" $offset) * 256 ))
|
||||
(( offset = offset + 1 ))
|
||||
(( tpos = $(readcharDec "$filename" $offset) + tposHi ))
|
||||
(( cpos = tpos + 4 ))
|
||||
(( ppos = tpos + 1 ))
|
||||
(( apos = tpos + 2 ))
|
||||
|
||||
if [[ $p || $a || $t || $c ]]; then # set
|
||||
if [[ $p || $a ]]; then
|
||||
if [[ $p ]]; then
|
||||
[[ ${#p} -eq 3 ]] && { p=$(lookupPdosType $p) || quit "Invalid ProDOS type name ($p)."; }
|
||||
isHexByte "$p" || quit "Invalid ProDOS file type ($p)."
|
||||
writecharHex "$filename" $ppos "$p"
|
||||
fi
|
||||
if [[ $a ]]; then
|
||||
isHexByte "${a:0:2}" && isHexByte "${a:2:2}" || quit "Invalid ProDOS aux type ($a)."
|
||||
writecharHex "$filename" $apos "${a:0:2}"
|
||||
(( apos=apos+1 ))
|
||||
writecharHex "$filename" $apos "${a:2:2}"
|
||||
fi
|
||||
writechars "$filename" $tpos "p"
|
||||
writechars "$filename" $cpos "pdos"
|
||||
elif [[ $t || $c ]]; then
|
||||
if [[ $t ]]; then
|
||||
type=$(verifyTC "$t") || quit "$(echo -n "Invalid Mac file type ($t)."; [[ $t == *x* ]] && echo -n " Try quotes."; echo)"
|
||||
writechars "$filename" $tpos "${type:0:4}"
|
||||
fi
|
||||
if [[ $c ]]; then
|
||||
creator=$(verifyTC "$c") || quit "$(echo -n "Invalid Mac file creator ($c)."; [[ $c == *x* ]] && echo -n " Try quotes."; echo)"
|
||||
writechars "$filename" $cpos "${creator:0:4}"
|
||||
fi
|
||||
fi
|
||||
[[ $q ]] || { echo -n "${linestart}File changed: "; "$0" "$filename"; }
|
||||
if [[ $p || $a || $t || $c ]]; then # set
|
||||
if [[ $p || $a ]]; then
|
||||
if [[ $p ]]; then
|
||||
[[ ${#p} -eq 3 ]] && { p=$(lookupPdosType $p) || quit "Invalid ProDOS type name ($p)."; }
|
||||
isHexByte "$p" || quit "Invalid ProDOS file type ($p)."
|
||||
writecharHex "$filename" $ppos "$p"
|
||||
fi
|
||||
if [[ $a ]]; then
|
||||
isHexByte "${a:0:2}" && isHexByte "${a:2:2}" || quit "Invalid ProDOS aux type ($a)."
|
||||
writecharHex "$filename" $apos "${a:0:2}"
|
||||
(( apos=apos+1 ))
|
||||
writecharHex "$filename" $apos "${a:2:2}"
|
||||
fi
|
||||
writechars "$filename" $tpos "p"
|
||||
writechars "$filename" $cpos "pdos"
|
||||
elif [[ $t || $c ]]; then
|
||||
if [[ $t ]]; then
|
||||
type=$(verifyTC "$t") || quit "$(echo -n "Invalid Mac file type ($t)."; [[ $t == *x* ]] && echo -n " Try quotes."; echo)"
|
||||
writechars "$filename" $tpos "${type:0:4}"
|
||||
fi
|
||||
if [[ $c ]]; then
|
||||
creator=$(verifyTC "$c") || quit "$(echo -n "Invalid Mac file creator ($c)."; [[ $c == *x* ]] && echo -n " Try quotes."; echo)"
|
||||
writechars "$filename" $cpos "${creator:0:4}"
|
||||
fi
|
||||
fi
|
||||
[[ $q ]] || { echo -n "${linestart}File changed: "; "$0" "$filename"; }
|
||||
|
||||
else # show
|
||||
[[ $q ]] && quit "Can only use -q when changing type."
|
||||
else # show
|
||||
[[ $q ]] && quit "Can only use -q when changing type."
|
||||
|
||||
type="$(readchars "$filename" $tpos 4)"
|
||||
creator="$(readchars "$filename" $cpos 4)"
|
||||
type="$(readchars "$filename" $tpos 4)"
|
||||
creator="$(readchars "$filename" $cpos 4)"
|
||||
|
||||
echo -n "$linestart"
|
||||
echo -n "$linestart"
|
||||
|
||||
if [[ $creator != "pdos" || ( ( $type != "TEXT" ) \
|
||||
&& ( $type != "PSYS" ) && ( ${type:0:1} != "p" ) ) ]]; then
|
||||
if [[ $creator || $type ]]; then
|
||||
echo "Mac file. Type:$type Creator:$creator"
|
||||
else
|
||||
echo "This file has no Mac or ProDOS file type information."
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
if [[ $creator != "pdos" || ( ( $type != "TEXT" ) \
|
||||
&& ( $type != "PSYS" ) && ( ${type:0:1} != "p" ) ) ]]; then
|
||||
if [[ $creator || $type ]]; then
|
||||
echo "Mac file. Type:$type Creator:$creator"
|
||||
else
|
||||
echo "This file has no Mac or ProDOS file type information."
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ $type == "TEXT" ]]; then
|
||||
pdosType="\$04 [TXT]"
|
||||
pdosAuxType='$0000'
|
||||
elif [[ $type == "PSYS" ]]; then
|
||||
pdosType="\$FF [SYS]"
|
||||
pdosAuxType='$0000'
|
||||
else
|
||||
(( tpos=tpos+1 ))
|
||||
pdosType=$(readcharHex "$filename" $tpos)
|
||||
for ptype in $ptypes; do
|
||||
if [[ "${ptype:0:2}" == "$pdosType" ]]; then
|
||||
pdosType="$pdosType [${ptype:3:3}]"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ $type == "TEXT" ]]; then
|
||||
pdosType="\$04 [TXT]"
|
||||
pdosAuxType='$0000'
|
||||
elif [[ $type == "PSYS" ]]; then
|
||||
pdosType="\$FF [SYS]"
|
||||
pdosAuxType='$0000'
|
||||
else
|
||||
(( tpos=tpos+1 ))
|
||||
pdosType=$(readcharHex "$filename" $tpos)
|
||||
for ptype in $ptypes; do
|
||||
if [[ "${ptype:0:2}" == "$pdosType" ]]; then
|
||||
pdosType="$pdosType [${ptype:3:3}]"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
(( tpos=tpos+1 ))
|
||||
auxTypeHi=$(readcharHex "$filename" $tpos)
|
||||
(( tpos=tpos+1 ))
|
||||
auxTypeLo=$(readcharHex "$filename" $tpos)
|
||||
pdosAuxType=$auxTypeHi$auxTypeLo
|
||||
fi
|
||||
(( tpos=tpos+1 ))
|
||||
auxTypeHi=$(readcharHex "$filename" $tpos)
|
||||
(( tpos=tpos+1 ))
|
||||
auxTypeLo=$(readcharHex "$filename" $tpos)
|
||||
pdosAuxType=$auxTypeHi$auxTypeLo
|
||||
fi
|
||||
|
||||
echo "ProDOS file. Type:\$$pdosType AuxType:\$$pdosAuxType"
|
||||
fi
|
||||
echo "ProDOS file. Type:\$$pdosType AuxType:\$$pdosAuxType"
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
+1044
-1044
File diff suppressed because it is too large
Load Diff
+199
-199
@@ -1,5 +1,5 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# mkatinit by Ivan Drucker, http://appleii.ivanx.com
|
||||
# not licensed; please modify and redistribute as you like
|
||||
@@ -27,12 +27,12 @@ decToChar () {
|
||||
# arg: decimal number from 0-255
|
||||
# out: one character
|
||||
#exit: 8=extraneous arg, 11=missing arg, 21=invalid arg
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ( $(printf %d "$1" 2> /dev/null ) == $1 ) \
|
||||
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
|
||||
# args are valid
|
||||
echo -n -e "\x$(printf %02X "$1")"
|
||||
[[ $1 ]] || return 11
|
||||
[[ $2 ]] && return 8
|
||||
[[ ( $(printf %d "$1" 2> /dev/null ) == $1 ) \
|
||||
&& ( $1 -ge 0 ) && ( $1 -le 255 ) ]] || return 21
|
||||
# args are valid
|
||||
echo -n -e "\x$(printf %02X "$1")"
|
||||
}
|
||||
|
||||
writechars () {
|
||||
@@ -44,18 +44,18 @@ writechars () {
|
||||
# out: nothing
|
||||
# exit: 8=extraneous arg, 11=missing arg1,
|
||||
# 13=missing stdin/arg3, 22=invalid arg2
|
||||
[[ $1 ]] || { [[ -t 0 ]] || cat > /dev/null; return 11; }
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) && \
|
||||
( $2 -ge 0 ) ]] || { [[ -t 0 ]] || cat > /dev/null; return 22; } }
|
||||
[[ ( ! -t 0 ) && $3 ]] && { cat > /dev/null; return 8; }
|
||||
[[ ( -t 0 ) ]] && { [[ $4 ]] && return 8; [[ $3 ]] || return 13; }
|
||||
# args are valid
|
||||
if [[ -t 0 ]]; then
|
||||
echo -n "$3" | \
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
else
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
fi
|
||||
[[ $1 ]] || { [[ -t 0 ]] || cat > /dev/null; return 11; }
|
||||
[[ $2 ]] && { [[ ( $(printf %d "$2" 2> /dev/null) == $2 ) && \
|
||||
( $2 -ge 0 ) ]] || { [[ -t 0 ]] || cat > /dev/null; return 22; } }
|
||||
[[ ( ! -t 0 ) && $3 ]] && { cat > /dev/null; return 8; }
|
||||
[[ ( -t 0 ) ]] && { [[ $4 ]] && return 8; [[ $3 ]] || return 13; }
|
||||
# args are valid
|
||||
if [[ -t 0 ]]; then
|
||||
echo -n "$3" | \
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
else
|
||||
dd of="$1" bs=1 seek=$(($2)) conv=notrunc 2> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
#---- mkatinit starts here
|
||||
@@ -74,49 +74,49 @@ echo
|
||||
|
||||
usersfolder=1
|
||||
while [ -n "$1" ] && [ "${1:0:1}" = '-' ]; do
|
||||
flag="$1"
|
||||
if [ $flag = "-gs" ]; then
|
||||
gs=1
|
||||
shift
|
||||
continue
|
||||
elif [ $flag = "-d" ]; then
|
||||
noprompt=1
|
||||
shift
|
||||
continue
|
||||
elif [ $flag = "-f" ]; then
|
||||
overwrite=1
|
||||
shift
|
||||
continue
|
||||
elif [ $flag = "-g" ]; then
|
||||
alsoguest=1
|
||||
shift
|
||||
continue
|
||||
elif [ $flag = "-c" ]; then
|
||||
usersfolder=0
|
||||
shift
|
||||
continue
|
||||
else
|
||||
badflag=1
|
||||
break
|
||||
fi
|
||||
flag="$1"
|
||||
if [ $flag = "-gs" ]; then
|
||||
gs=1
|
||||
shift
|
||||
continue
|
||||
elif [ $flag = "-d" ]; then
|
||||
noprompt=1
|
||||
shift
|
||||
continue
|
||||
elif [ $flag = "-f" ]; then
|
||||
overwrite=1
|
||||
shift
|
||||
continue
|
||||
elif [ $flag = "-g" ]; then
|
||||
alsoguest=1
|
||||
shift
|
||||
continue
|
||||
elif [ $flag = "-c" ]; then
|
||||
usersfolder=0
|
||||
shift
|
||||
continue
|
||||
else
|
||||
badflag=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $usersfolder -eq 0 ] && [ -n "$alsoguest" ]; then
|
||||
badflag=1
|
||||
badflag=1
|
||||
fi
|
||||
|
||||
if [ $badflag ]; then
|
||||
echo "usage: mkatinit [-gs] [-d] [-f] [-g | -c] [<username>|guest]"
|
||||
echo
|
||||
echo "<username> should be the name of a netatalk user, or 'guest'"
|
||||
echo "-gs sets the default ProDOS netboot system startup program and"
|
||||
echo " prefix for GS/OS (if omitted, ProDOS 8 defaults are used)"
|
||||
echo "-d use the default start program and prefix, without prompting"
|
||||
echo "-f overwrite existing ATINIT file if present, without warning"
|
||||
echo "-g create an ATINIT file for Guest as well as the specified user"
|
||||
echo "-c write ATNIT to current directory instead of USERS hierarchy"
|
||||
echo
|
||||
exit
|
||||
echo "usage: mkatinit [-gs] [-d] [-f] [-g | -c] [<username>|guest]"
|
||||
echo
|
||||
echo "<username> should be the name of a netatalk user, or 'guest'"
|
||||
echo "-gs sets the default ProDOS netboot system startup program and"
|
||||
echo " prefix for GS/OS (if omitted, ProDOS 8 defaults are used)"
|
||||
echo "-d use the default start program and prefix, without prompting"
|
||||
echo "-f overwrite existing ATINIT file if present, without warning"
|
||||
echo "-g create an ATINIT file for Guest as well as the specified user"
|
||||
echo "-c write ATNIT to current directory instead of USERS hierarchy"
|
||||
echo
|
||||
exit
|
||||
fi
|
||||
|
||||
arg="$1"
|
||||
@@ -125,162 +125,162 @@ arg="$1"
|
||||
|
||||
while : ; do
|
||||
|
||||
if [ ${#arg} -gt 32 ]; then
|
||||
echo "User name is too long. Exiting with no action."
|
||||
exit
|
||||
elif [ -n "$arg" ]; then
|
||||
if [ `echo $arg | tr '[:upper:]' '[:lower:]'` = "guest" ]; then
|
||||
username='<Any User>'
|
||||
alsoguest=
|
||||
if [[ ! $(grep -F -s $(ls -1 /home) /etc/default/netatalk) ]]; then
|
||||
echo 'Warning: The AFPD_GUEST setting in /etc/default/netatalk is not assigned to a'
|
||||
echo 'user with a folder in /home. Guest users may be able to boot over the network'
|
||||
echo 'into ProDOS 8 for read-only access, but will not be able to boot into GS/OS.'
|
||||
if [ $gs ]; then
|
||||
echo ' Using ProDOS 8 defaults.'
|
||||
gs=
|
||||
else
|
||||
echo
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
else
|
||||
username="$arg"
|
||||
if [[ ! $(ls -1 /home | grep -F -s $username) ]]; then
|
||||
echo "Warning: This username ($username) does not have a folder in /home. This user may"
|
||||
echo "not be able to boot over the network into ProDOS 8 or GS/OS."
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
if [ $gs ]; then
|
||||
startprog="$gsstartprog"
|
||||
prefix="$gsprefix"
|
||||
fi
|
||||
fi
|
||||
if [ ${#arg} -gt 32 ]; then
|
||||
echo "User name is too long. Exiting with no action."
|
||||
exit
|
||||
elif [ -n "$arg" ]; then
|
||||
if [ `echo $arg | tr '[:upper:]' '[:lower:]'` = "guest" ]; then
|
||||
username='<Any User>'
|
||||
alsoguest=
|
||||
if [[ ! $(grep -F -s $(ls -1 /home) /etc/default/netatalk) ]]; then
|
||||
echo 'Warning: The AFPD_GUEST setting in /etc/default/netatalk is not assigned to a'
|
||||
echo 'user with a folder in /home. Guest users may be able to boot over the network'
|
||||
echo 'into ProDOS 8 for read-only access, but will not be able to boot into GS/OS.'
|
||||
if [ $gs ]; then
|
||||
echo ' Using ProDOS 8 defaults.'
|
||||
gs=
|
||||
else
|
||||
echo
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
else
|
||||
username="$arg"
|
||||
if [[ ! $(ls -1 /home | grep -F -s $username) ]]; then
|
||||
echo "Warning: This username ($username) does not have a folder in /home. This user may"
|
||||
echo "not be able to boot over the network into ProDOS 8 or GS/OS."
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
if [ $gs ]; then
|
||||
startprog="$gsstartprog"
|
||||
prefix="$gsprefix"
|
||||
fi
|
||||
fi
|
||||
|
||||
# make username all caps
|
||||
username=`echo $username | tr '[:lower:]' '[:upper:]'`
|
||||
# make username all caps
|
||||
username=`echo $username | tr '[:lower:]' '[:upper:]'`
|
||||
|
||||
# prompt for folders
|
||||
if [ ! $doalsoguest ] && [ ! $noprompt ]; then
|
||||
while : ; do
|
||||
echo "Enter the ProDOS path to the startup system program."
|
||||
echo "default (CR to accept): $startprog"
|
||||
read
|
||||
if [ ${#REPLY} -gt 64 ]; then
|
||||
continue
|
||||
elif [ -n "$REPLY" ]; then
|
||||
startprog="`echo $REPLY | tr '[:lower:]' '[:upper:]'`"
|
||||
echo
|
||||
fi
|
||||
break
|
||||
done
|
||||
# prompt for folders
|
||||
if [ ! $doalsoguest ] && [ ! $noprompt ]; then
|
||||
while : ; do
|
||||
echo "Enter the ProDOS path to the startup system program."
|
||||
echo "default (CR to accept): $startprog"
|
||||
read
|
||||
if [ ${#REPLY} -gt 64 ]; then
|
||||
continue
|
||||
elif [ -n "$REPLY" ]; then
|
||||
startprog="`echo $REPLY | tr '[:lower:]' '[:upper:]'`"
|
||||
echo
|
||||
fi
|
||||
break
|
||||
done
|
||||
|
||||
while : ; do
|
||||
echo "Enter the initial ProDOS prefix:"
|
||||
echo "default (CR to accept): $prefix"
|
||||
read
|
||||
if [ ${#REPLY} -gt 64 ]; then
|
||||
continue
|
||||
elif [ -n "$REPLY" ]; then
|
||||
prefix="`echo $REPLY | tr '[:lower:]' '[:upper:]'`"
|
||||
echo
|
||||
fi
|
||||
break
|
||||
done
|
||||
fi
|
||||
while : ; do
|
||||
echo "Enter the initial ProDOS prefix:"
|
||||
echo "default (CR to accept): $prefix"
|
||||
read
|
||||
if [ ${#REPLY} -gt 64 ]; then
|
||||
continue
|
||||
elif [ -n "$REPLY" ]; then
|
||||
prefix="`echo $REPLY | tr '[:lower:]' '[:upper:]'`"
|
||||
echo
|
||||
fi
|
||||
break
|
||||
done
|
||||
fi
|
||||
|
||||
# create folders if needed
|
||||
filepath="$PWD/$filename"
|
||||
# create folders if needed
|
||||
filepath="$PWD/$filename"
|
||||
|
||||
while [ $usersfolder -eq 1 ]; do
|
||||
# create folders for ATINIT
|
||||
while [ ! -d "$sharepath" ]; do
|
||||
echo "Shared volume '$sharepath' not found. Edit mkatinit to change the default."
|
||||
echo "Enter the local path to the netatalk shared volume used for netboot:"
|
||||
read sharepath
|
||||
done
|
||||
while [ $usersfolder -eq 1 ]; do
|
||||
# create folders for ATINIT
|
||||
while [ ! -d "$sharepath" ]; do
|
||||
echo "Shared volume '$sharepath' not found. Edit mkatinit to change the default."
|
||||
echo "Enter the local path to the netatalk shared volume used for netboot:"
|
||||
read sharepath
|
||||
done
|
||||
|
||||
if [ ! -d "$sharepath/USERS" ]; then
|
||||
mkdir "$sharepath/USERS"
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
if [ ! -d "$sharepath/USERS/$username" ]; then
|
||||
mkdir "$sharepath/USERS/$username"
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
if [ ! -d "$sharepath/USERS/$username/SETUP" ]; then
|
||||
mkdir "$sharepath/USERS/$username/SETUP"
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
if [ ! -w "$sharepath/USERS/$username/SETUP" ]; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
if [ ! -d "$sharepath/USERS" ]; then
|
||||
mkdir "$sharepath/USERS"
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
if [ ! -d "$sharepath/USERS/$username" ]; then
|
||||
mkdir "$sharepath/USERS/$username"
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
if [ ! -d "$sharepath/USERS/$username/SETUP" ]; then
|
||||
mkdir "$sharepath/USERS/$username/SETUP"
|
||||
if [ $? -ne 0 ]; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
if [ ! -w "$sharepath/USERS/$username/SETUP" ]; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
# we have a valid USERS folder target for ATINIT
|
||||
filepath="$sharepath/USERS/$username/SETUP/$filename"
|
||||
usersfolder=2
|
||||
done
|
||||
# we have a valid USERS folder target for ATINIT
|
||||
filepath="$sharepath/USERS/$username/SETUP/$filename"
|
||||
usersfolder=2
|
||||
done
|
||||
|
||||
if [ $usersfolder -eq 1 ]; then
|
||||
echo "Could not write to shared volume. Creating ATINIT in current directory."
|
||||
if [ -n "$alsoguest" ]; then
|
||||
echo "ATINIT for Guest user will not be created."
|
||||
fi
|
||||
echo
|
||||
alsoguest=
|
||||
fi
|
||||
if [ $usersfolder -eq 1 ]; then
|
||||
echo "Could not write to shared volume. Creating ATINIT in current directory."
|
||||
if [ -n "$alsoguest" ]; then
|
||||
echo "ATINIT for Guest user will not be created."
|
||||
fi
|
||||
echo
|
||||
alsoguest=
|
||||
fi
|
||||
|
||||
if [ ! $doalsoguest ]; then
|
||||
echo "netboot start program: $startprog"
|
||||
echo "netboot start prefix : $prefix"
|
||||
echo
|
||||
fi
|
||||
if [ ! $doalsoguest ]; then
|
||||
echo "netboot start program: $startprog"
|
||||
echo "netboot start prefix : $prefix"
|
||||
echo
|
||||
fi
|
||||
|
||||
#remove ATINIT if present
|
||||
if [ ! $overwrite ] && [ -f "$filepath" ]; then
|
||||
echo -n "$filepath already exists. Overwrite? "
|
||||
while read -s -n 1 > /dev/null 2>&1; do
|
||||
if [ -z "$REPLY" ]; then
|
||||
continue
|
||||
elif [ "$REPLY" = "Y" ] || [ "$REPLY" = "y" ]; then
|
||||
echo
|
||||
break
|
||||
elif [ "$REPLY" = "N" ] || [ "$REPLY" = "n" ]; then
|
||||
echo
|
||||
echo "Exiting with no action."
|
||||
exit
|
||||
fi
|
||||
done
|
||||
fi
|
||||
#remove ATINIT if present
|
||||
if [ ! $overwrite ] && [ -f "$filepath" ]; then
|
||||
echo -n "$filepath already exists. Overwrite? "
|
||||
while read -s -n 1 > /dev/null 2>&1; do
|
||||
if [ -z "$REPLY" ]; then
|
||||
continue
|
||||
elif [ "$REPLY" = "Y" ] || [ "$REPLY" = "y" ]; then
|
||||
echo
|
||||
break
|
||||
elif [ "$REPLY" = "N" ] || [ "$REPLY" = "n" ]; then
|
||||
echo
|
||||
echo "Exiting with no action."
|
||||
exit
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
#write the file. start with zeroes
|
||||
dd if=/dev/zero of="$filepath" bs=1 count=276 2> /dev/null
|
||||
#put in startprog, prefix, username (first byte of each field is length)
|
||||
# ( echo -n "${#startprog}" | awk '{printf("%c",$0);}'; echo -n "$startprog"; ) | dd of="$filepath" bs=1 seek=7 conv=notrunc 2> /dev/null
|
||||
# ( echo -n "${#prefix}" | awk '{printf("%c",$0);}'; echo -n "$prefix"; ) | dd of="$filepath" bs=1 seek=78 conv=notrunc 2> /dev/null
|
||||
# ( echo -n "${#username}" | awk '{printf("%c",$0);}'; echo -n "$username"; ) | dd of="$filepath" bs=1 seek=143 conv=notrunc 2> /dev/null
|
||||
( decToChar "${#startprog}"; echo -n "$startprog"; ) | writechars "$filepath" 7
|
||||
( decToChar "${#prefix}"; echo -n "$prefix"; ) | writechars "$filepath" 78
|
||||
( decToChar "${#username}"; echo -n "$username"; ) | writechars "$filepath" 143
|
||||
#write the file. start with zeroes
|
||||
dd if=/dev/zero of="$filepath" bs=1 count=276 2> /dev/null
|
||||
#put in startprog, prefix, username (first byte of each field is length)
|
||||
# ( echo -n "${#startprog}" | awk '{printf("%c",$0);}'; echo -n "$startprog"; ) | dd of="$filepath" bs=1 seek=7 conv=notrunc 2> /dev/null
|
||||
# ( echo -n "${#prefix}" | awk '{printf("%c",$0);}'; echo -n "$prefix"; ) | dd of="$filepath" bs=1 seek=78 conv=notrunc 2> /dev/null
|
||||
# ( echo -n "${#username}" | awk '{printf("%c",$0);}'; echo -n "$username"; ) | dd of="$filepath" bs=1 seek=143 conv=notrunc 2> /dev/null
|
||||
( decToChar "${#startprog}"; echo -n "$startprog"; ) | writechars "$filepath" 7
|
||||
( decToChar "${#prefix}"; echo -n "$prefix"; ) | writechars "$filepath" 78
|
||||
( decToChar "${#username}"; echo -n "$username"; ) | writechars "$filepath" 143
|
||||
|
||||
echo "Created $filepath"
|
||||
if [ ! $alsoguest ]; then
|
||||
break
|
||||
fi
|
||||
echo "Created $filepath"
|
||||
if [ ! $alsoguest ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
if [ $usersfolder -eq 2 ]; then
|
||||
usersfolder=1
|
||||
fi
|
||||
doalsoguest=1
|
||||
arg='guest'
|
||||
if [ $usersfolder -eq 2 ]; then
|
||||
usersfolder=1
|
||||
fi
|
||||
doalsoguest=1
|
||||
arg='guest'
|
||||
done
|
||||
|
||||
echo
|
||||
|
||||
+65
-65
@@ -1,83 +1,83 @@
|
||||
#! /bin/bash
|
||||
# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh:
|
||||
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
||||
|
||||
# mkvolinfo -- creates a (share)/.AppleDesktop/.volinfo file
|
||||
|
||||
makeVolInfoFile () {
|
||||
[[ -d $sharepath/.AppleDesktop ]] || mkdir $sharepath/.AppleDesktop
|
||||
touch $volinfo
|
||||
echo 'MAC_CHARSET:MAC_ROMAN' >> $volinfo
|
||||
echo 'VOL_CHARSET:UTF8' >> $volinfo
|
||||
echo 'ADOUBLE_VER:v2' >> $volinfo
|
||||
echo 'CNIDBACKEND:dbd' >> $volinfo
|
||||
echo 'CNIDDBDHOST:localhost' >> $volinfo
|
||||
echo 'CNIDDBDPORT:4700' >> $volinfo
|
||||
echo "CNID_DBPATH:$sharepath" >> $volinfo
|
||||
echo 'VOLUME_OPTS:PRODOS CACHEID' >> $volinfo
|
||||
if (( $mixedcase )); then
|
||||
echo 'VOLCASEFOLD:' >> $volinfo
|
||||
else
|
||||
echo 'VOLCASEFOLD:MTOULOWER UTOMUPPER' >> $volinfo
|
||||
fi
|
||||
echo 'EXTATTRTYPE:AFPVOL_EA_AD' >> $volinfo
|
||||
echo ".volinfo for $sharepath has been created."
|
||||
[[ -d $sharepath/.AppleDesktop ]] || mkdir $sharepath/.AppleDesktop
|
||||
touch $volinfo
|
||||
echo 'MAC_CHARSET:MAC_ROMAN' >> $volinfo
|
||||
echo 'VOL_CHARSET:UTF8' >> $volinfo
|
||||
echo 'ADOUBLE_VER:v2' >> $volinfo
|
||||
echo 'CNIDBACKEND:dbd' >> $volinfo
|
||||
echo 'CNIDDBDHOST:localhost' >> $volinfo
|
||||
echo 'CNIDDBDPORT:4700' >> $volinfo
|
||||
echo "CNID_DBPATH:$sharepath" >> $volinfo
|
||||
echo 'VOLUME_OPTS:PRODOS CACHEID' >> $volinfo
|
||||
if (( $mixedcase )); then
|
||||
echo 'VOLCASEFOLD:' >> $volinfo
|
||||
else
|
||||
echo 'VOLCASEFOLD:MTOULOWER UTOMUPPER' >> $volinfo
|
||||
fi
|
||||
echo 'EXTATTRTYPE:AFPVOL_EA_AD' >> $volinfo
|
||||
echo ".volinfo for $sharepath has been created."
|
||||
}
|
||||
|
||||
while [[ $1 == "-f" || $1 == "-c" ]]; do
|
||||
if [[ $1 == "-f" ]]; then
|
||||
force=1
|
||||
shift
|
||||
fi
|
||||
if [[ $1 == "-f" ]]; then
|
||||
force=1
|
||||
shift
|
||||
fi
|
||||
|
||||
if [[ $1 == "-c" ]]; then
|
||||
mixedcase=1
|
||||
shift
|
||||
fi
|
||||
if [[ $1 == "-c" ]]; then
|
||||
mixedcase=1
|
||||
shift
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${1:0:1} == "-" ]]; then
|
||||
|
||||
echo "usage: mkvolinfo [-f] [-c] [shared volume path]"
|
||||
echo
|
||||
echo "-c will create the .volinfo file to specify no uppercase filename conversion"
|
||||
echo "-f will create the .volinfo file without prompting, if none exists"
|
||||
echo "If a path is specified, that is what is used, otherwise the last entry"
|
||||
echo "in /usr/local/etc/netatalk/AppleVolumes.default is used."
|
||||
echo "usage: mkvolinfo [-f] [-c] [shared volume path]"
|
||||
echo
|
||||
echo "-c will create the .volinfo file to specify no uppercase filename conversion"
|
||||
echo "-f will create the .volinfo file without prompting, if none exists"
|
||||
echo "If a path is specified, that is what is used, otherwise the last entry"
|
||||
echo "in /usr/local/etc/netatalk/AppleVolumes.default is used."
|
||||
|
||||
else
|
||||
sudo true
|
||||
if [[ $1 ]]; then
|
||||
sharepath=$(readlink -m $1)
|
||||
else
|
||||
sharepath=$(grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | tail -1 | cut -d" " -f1)
|
||||
fi
|
||||
sudo true
|
||||
if [[ $1 ]]; then
|
||||
sharepath=$(readlink -m $1)
|
||||
else
|
||||
sharepath=$(grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | tail -1 | cut -d" " -f1)
|
||||
fi
|
||||
|
||||
volinfo=$sharepath/.AppleDesktop/.volinfo
|
||||
volinfo=$sharepath/.AppleDesktop/.volinfo
|
||||
|
||||
if [[ ! -d $sharepath ]]; then
|
||||
echo "$sharepath does not exist."
|
||||
else
|
||||
if [[ -f $volinfo ]]; then
|
||||
echo "$volinfo already exists."
|
||||
else
|
||||
if [[ $force ]]; then
|
||||
makeVolInfoFile
|
||||
else
|
||||
echo "The .volinfo file is automatically generated when you first"
|
||||
echo "log in from an AFP (Apple II or Mac) client machine."
|
||||
echo "If you can't do this, you can create a .volinfo file now"
|
||||
echo "based on assumed defaults; proceed with caution if you have"
|
||||
echo "customized your AppleVolumes files."
|
||||
echo
|
||||
echo "If the path shown below is incorrect, you can specify"
|
||||
echo "the path to your shared volume as an argument to mkvolinfo."
|
||||
echo
|
||||
echo -n "Make .volinfo for shared volume $sharepath now? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "y" ]] || [[ ${REPLY:0:1} == "Y" ]]; then
|
||||
makeVolInfoFile
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [[ ! -d $sharepath ]]; then
|
||||
echo "$sharepath does not exist."
|
||||
else
|
||||
if [[ -f $volinfo ]]; then
|
||||
echo "$volinfo already exists."
|
||||
else
|
||||
if [[ $force ]]; then
|
||||
makeVolInfoFile
|
||||
else
|
||||
echo "The .volinfo file is automatically generated when you first"
|
||||
echo "log in from an AFP (Apple II or Mac) client machine."
|
||||
echo "If you can't do this, you can create a .volinfo file now"
|
||||
echo "based on assumed defaults; proceed with caution if you have"
|
||||
echo "customized your AppleVolumes files."
|
||||
echo
|
||||
echo "If the path shown below is incorrect, you can specify"
|
||||
echo "the path to your shared volume as an argument to mkvolinfo."
|
||||
echo
|
||||
echo -n "Make .volinfo for shared volume $sharepath now? "
|
||||
read
|
||||
if [[ ${REPLY:0:1} == "y" ]] || [[ ${REPLY:0:1} == "Y" ]]; then
|
||||
makeVolInfoFile
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user