From 024f57985035cf467a719c34017c3167a5b08b07 Mon Sep 17 00:00:00 2001 From: Ivan X Date: Fri, 18 Dec 2015 00:45:01 -0500 Subject: [PATCH] macipgw installed; a2serverc created (macipgw tested on Wheezy and Jessie; works on Raspbian only, not Debian x86) --- README.md | 5 +++-- scripts/a2server-1-storage.txt | 2 +- scripts/a2server-2-tools.txt | 16 ++++++++++--- scripts/a2server-3-sharing.txt | 36 +++++++++++++++++++++++++++++- scripts/a2server-6-samba.txt | 8 ++++++- scripts/tools/a2server-aliases.txt | 8 +++---- scripts/tools/a2serverrc.txt | 4 ++++ scripts/tools/afpsync.txt | 4 ++-- scripts/tools/cppo.txt | 3 ++- scripts/tools/mkvolinfo.txt | 2 +- setup/index.txt | 4 ++-- 11 files changed, 74 insertions(+), 18 deletions(-) create mode 100755 scripts/tools/a2serverrc.txt diff --git a/README.md b/README.md index 36d532a..b4effd8 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,9 @@ wget -O a2server-setup ${A2SERVER_SCRIPT_URL}setup/index.txt; source a2server-se ~~~ A simple method for installing from a local subdirectory is to `cd` to it and -then type `python -m SimpleHTTPServer`. Then export A2SERVER_SCRIPT_URL to -"http://localhost:8000/" or use the IP address of the host machine on your LAN. +then type `python -m SimpleHTTPServer`. Then +`export A2SERVER_SCRIPT_URL="http://localhost:8000/"` +or use the IP address of the host machine on your LAN instead of localhost. You should probably export A2SERVER_SCRIPT_URL in your .bashrc or whatever file configures your development environment. Also be advised that as of diff --git a/scripts/a2server-1-storage.txt b/scripts/a2server-1-storage.txt index 4f5b91c..cd1818d 100755 --- a/scripts/a2server-1-storage.txt +++ b/scripts/a2server-1-storage.txt @@ -24,7 +24,7 @@ else echo "A2SERVER: Preparing the shared files volume..." - sudo mkdir /srv/A2SERVER + sudo mkdir -p /srv/A2SERVER sudo chown $USER:$USER /srv/A2SERVER diff --git a/scripts/a2server-2-tools.txt b/scripts/a2server-2-tools.txt index b7142f8..42cc69a 100755 --- a/scripts/a2server-2-tools.txt +++ b/scripts/a2server-2-tools.txt @@ -121,7 +121,12 @@ fi if ! command -v unzip >/dev/null; then echo "A2SERVER: Installing unzip..." -sudo apt-get -y install unzip + if [[ ! -f /tmp/a2server-packageReposUpdated ]]; then + # prepare for installing packages + sudo apt-get -y update + touch /tmp/a2server-packageReposUpdated + fi + sudo apt-get -y install unzip else echo "A2SERVER: unzip has already been installed." fi @@ -138,9 +143,14 @@ sudo wget -q -O /usr/local/bin/cppo "${scriptURL}scripts/tools/cppo.txt" sudo chmod ugo+x /usr/local/bin/cppo sudo wget -q -O /usr/local/etc/a2server-help.txt "${scriptURL}scripts/tools/a2server-help.txt" sudo wget -q -O /usr/local/etc/a2server-aliases "${scriptURL}scripts/tools/a2server-aliases.txt" +sudo wget -q -O /usr/local/etc/a2serverrc "${scriptURL}scripts/tools/a2serverrc.txt" -grep a2server-aliases /etc/bash.bashrc > /dev/null || \ -echo "source /usr/local/etc/a2server-aliases" | sudo tee -a /etc/bash.bashrc > /dev/null +# 1.3.0: a2serverrc is now called from /etc/bash.bashrc, +# which in turn calls a2server-aliases +grep 'a2server-aliases' /etc/bash.bashrc > /dev/null && \ +sudo sed -i 's/a2server-aliases/a2serverrc/' /etc/bash.bashrc +grep 'a2serverrc' /etc/bash.bashrc > /dev/null || \ +echo "source /usr/local/etc/a2serverrc" | sudo tee -a /etc/bash.bashrc > /dev/null motd="/etc/motd" if [[ ! $(grep A2SERVER $motd) ]]; then diff --git a/scripts/a2server-3-sharing.txt b/scripts/a2server-3-sharing.txt index 1625220..4de7331 100755 --- a/scripts/a2server-3-sharing.txt +++ b/scripts/a2server-3-sharing.txt @@ -177,6 +177,34 @@ else rm -rf /tmp/netatalk fi fi + +# --- Install MacIPgw +if ! command -v macipgw > /dev/null; then + echo "A2SERVER: Installing TCP over AppleTalk (MacIP)..." + + if [[ $isRpi ]]; then + wget -qO- "http://appleii.ivanx.com/a2server/files/macipgw-rpi.tgz" | sudo tar Pzx + elif [[ $isDebian_x86 ]]; then + wget -qO- "http://appleii.ivanx.com/a2server/files/macipgw-debian7_x86.tgz" | sudo tar Pzx + fi + + if ! command -v macipgw > /dev/null; then + wd="$PWD" + sudo apt-get -y install build-essential + rm -rf /tmp/macipgw &> /dev/null + mkdir /tmp/macipgw + cd /tmp/macipgw + wget -qO macipgw-master.zip "https://github.com/zero2sixd/macipgw/archive/master.zip" + unzip macipgw-master.zip + cd macipgw-master + make + sudo make install + cd "$wd" + rm -rf /tmp/macipgw + fi +else + echo "A2SERVER: TCP over AppleTalk (MacIP) has already been installed." +fi # --- Configuring Netatalk @@ -198,6 +226,12 @@ if [[ ! $(grep 'kernelRelease' /etc/init.d/netatalk) ]]; then sudo sed -i 's@\(\tif \[ x\"$ATALKD_RUN\)@\n\t# check for valid AppleTalk kernel module\n\t[[ $ATALKD_RUN == "yes" ]] \&\& { kernelRelease=$(uname -r); kernelMajorRelease=$(cut -d "." -f 1 <<< $kernelRelease); kernelMinorRelease=$(cut -d "." -f 2 <<< $kernelRelease | sed '"'"'s/\\(^[0-9]*\\)[^0-9].*$/\\1/'"'"'); kernelPatchRelease=$(cut -d "." -f 3- <<< $kernelRelease | sed '"'"'s/\\(^[0-9]*\\)[^0-9].*$/\\1/'"'"'); [[ ( $kernelMajorRelease -eq 3 \&\& $kernelMinorRelease -ge 12 \&\& $kernelMinorRelease -le 15 ) \&\& ( ! ( -f /usr/bin/raspi-config \&\& $kernelMinorRelease -eq 12 \&\& $kernelPatchRelease -ge 25 ) ) \&\& ( ( ! -f /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko ) || $(sha1sum /lib/modules/$kernelRelease/kernel/net/appletalk/appletalk.ko | cut -f 1 -d " ") != "ecb239fc084c36de93f6926e7749b80f6024f269" ) ]] \&\& { ATALKD_RUN=no; echo "[AppleTalk networking is not available.]" 1>\&2; } }\n\n\1@' /etc/init.d/netatalk fi +# enable MacIPgw support after launching atalkd +if ! grep -q -i 'macipgw' /etc/init.d/netatalk; then + sudo sed -i ':a;N;$!ba;s@\(echo -n " atalkd"\)\(.*# prepare\)@\1\n\n # start MacIPgw (TCP over AppleTalk) service\n ps aux | grep -q "[m]acipgw" \&\& sudo killall macipgw 2> /dev/null\n atalkd_interface=$(grep "^[^ #]" /etc/netatalk/atalkd.conf | tail -1 | cut -d " " -f 1)\n sysctl -w net.ipv4.ip_forward=1 > /dev/null\n macipgw -n 8.8.8.8 192.168.151.0 255.255.255.0\n /sbin/iptables -t nat -A POSTROUTING -o ${atalkd_interface} -j MASQUERADE\n /sbin/iptables -A FORWARD -i ${atalkd_interface} -o tun0 -m state --state RELATED,ESTABLISHED -j ACCEPT\n /sbin/iptables -A FORWARD -i tun1 -o ${atalkd_interface} -j ACCEPT\n\n echo -n " macipgw"\n\2@' /etc/init.d/netatalk + sudo sed -i 's@\(start-stop-daemon --stop --quiet --oknodo --exec /usr/local/sbin/atalkd.*$\)@\1\n echo -n " macipgw"\n sudo killall macipgw 2> /dev/null@' /etc/init.d/netatalk +fi + # enable network boot support in netatalk sudo sed -i 's/timelord/a2boot/g' /etc/init.d/netatalk sudo sed -i 's/TIMELORD/A2BOOT/g' /etc/init.d/netatalk @@ -319,7 +353,7 @@ fi # set up A2FILES case-insensitive share (for ProDOS 8 files, and GS/OS system) sudo sed -i \ - 's/^#share2/\/media\/A2SHARED\/A2FILES\ A2FILES options:prodos\ ea:ad/' \ + 's/^#share2/\/srv\/A2SERVER\/A2FILES\ A2FILES options:prodos\ ea:ad/' \ /usr/local/etc/netatalk/AppleVolumes.default [[ -d /srv/A2SERVER/A2FILES ]] || mkdir -p /srv/A2SERVER/A2FILES [[ -d /srv/A2SERVER/.a2files ]] || mkdir -p /srv/A2SERVER/.a2files diff --git a/scripts/a2server-6-samba.txt b/scripts/a2server-6-samba.txt index d6dcc14..ebec934 100755 --- a/scripts/a2server-6-samba.txt +++ b/scripts/a2server-6-samba.txt @@ -46,7 +46,13 @@ if [[ ! $autoAnswerYes || -f /tmp/a2server-setupWindowsSharing ]]; then 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 - grep ^/media /usr/local/etc/netatalk/AppleVolumes.default | cut -d" " -f2 \ + # 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." diff --git a/scripts/tools/a2server-aliases.txt b/scripts/tools/a2server-aliases.txt index 5c0dc78..752b117 100755 --- a/scripts/tools/a2server-aliases.txt +++ b/scripts/tools/a2server-aliases.txt @@ -24,8 +24,8 @@ alias showmac-wifi='ifconfig wlan0 | grep "HWaddr" | cut -dH -f2 | cut -c7-23' alias ifreset='sudo rm /etc/udev/rules.d/70-persistent-net.rules; echo Interfaces removed. You should system-restart now.' alias netatalk-stop="sudo /etc/init.d/netatalk stop; bonjour-off" -alias netatalk-start="sudo /etc/init.d/netatalk start; bonjour-on" -alias netatalk-restart="sudo /etc/init.d/netatalk restart; bonjour-on" +alias netatalk-start="sudo /etc/init.d/netatalk start; bonjour-on; grep -q 'ATALKD_RUN=yes' /etc/default/netatalk" +alias netatalk-restart="sudo /etc/init.d/netatalk restart; bonjour-on; grep -q 'ATALKD_RUN=yes' /etc/default/netatalk" alias netatalk-off='sudo /etc/init.d/netatalk stop; bonjour-off; sudo update-rc.d -f netatalk remove &> /dev/null' alias netatalk-on='sudo update-rc.d netatalk defaults &> /dev/null; bonjour-on; sudo /etc/init.d/netatalk restart' @@ -42,8 +42,8 @@ alias netatalk-wifi='sudo sed -i 's/^eth0/wlan0/' /usr/local/etc/netatalk/atalkd -alias appletalk-off='sudo sed -i "s/ATALKD_RUN=yes/ATALKD_RUN=no/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart' -alias appletalk-on='sudo sed -i "s/ATALKD_RUN=no/ATALKD_RUN=yes/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart' +alias appletalk-off='sudo sed -i "s/ATALKD_RUN=yes/ATALKD_RUN=no/" /etc/default/netatalk; sudo killall macipgw > /dev/null; /etc/init.d/netatalk restart' +alias appletalk-on='sudo sed -i "s/ATALKD_RUN=no/ATALKD_RUN=yes/" /etc/default/netatalk; sudo /etc/init.d/netatalk restart; sudo macip-start' NETATALK="/usr/local/etc/netatalk" diff --git a/scripts/tools/a2serverrc.txt b/scripts/tools/a2serverrc.txt new file mode 100755 index 0000000..30c74fc --- /dev/null +++ b/scripts/tools/a2serverrc.txt @@ -0,0 +1,4 @@ +#! /bin/bash +# vim: set tabstop=4 shiftwidth=4 expandtab filetype=sh: + +source /usr/local/etc/a2server-aliases diff --git a/scripts/tools/afpsync.txt b/scripts/tools/afpsync.txt index d8dd752..0b0b3a5 100755 --- a/scripts/tools/afpsync.txt +++ b/scripts/tools/afpsync.txt @@ -11,7 +11,7 @@ # # -v will silently create a .volinfo file if none exists. # If a path is specified, only that volume is synced; otherwise, all -# all paths in /media which appear in +# all paths in /srv/A2SERVER which appear in # /usr/local/etc/netatalk/AppleVolumes.default are synced. processPath () { @@ -108,7 +108,7 @@ else # (as opposed to defaulting to casefold:toupper previously) processPath 1 else - grep ^/media /usr/local/etc/netatalk/AppleVolumes.default | \ + grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | \ while read line; do [[ $(echo $line | grep toupper) ]]; nocasefold=$? sharepath=$(echo $line | cut -d" " -f1) diff --git a/scripts/tools/cppo.txt b/scripts/tools/cppo.txt index 5c3acd6..66242a4 100755 --- a/scripts/tools/cppo.txt +++ b/scripts/tools/cppo.txt @@ -333,7 +333,8 @@ def processEntry(arg1, arg2): g.activeFileName = getFileName(arg1 ,arg2).decode("L1") g.activeFileSize = getFileLength(arg1, arg2) - if ((not g.PDOSPATH_INDEX) or (g.activeFileName == g.PDOSPATH_SEGMENT)): + if ((not g.PDOSPATH_INDEX) or + (g.activeFileName.upper() == g.PDOSPATH_SEGMENT.upper())): if (getStorageType(arg1, arg2) == 13): # if ProDOS directory if not g.PDOSPATH_INDEX: diff --git a/scripts/tools/mkvolinfo.txt b/scripts/tools/mkvolinfo.txt index 54b9cbd..f4811d4 100755 --- a/scripts/tools/mkvolinfo.txt +++ b/scripts/tools/mkvolinfo.txt @@ -49,7 +49,7 @@ else if [[ $1 ]]; then sharepath=$(readlink -m $1) else - sharepath=$(grep ^/media /usr/local/etc/netatalk/AppleVolumes.default | tail -1 | cut -d" " -f1) + sharepath=$(grep ^/srv/A2SERVER /usr/local/etc/netatalk/AppleVolumes.default | tail -1 | cut -d" " -f1) fi volinfo=$sharepath/.AppleDesktop/.volinfo diff --git a/setup/index.txt b/setup/index.txt index 9491498..99c7caa 100755 --- a/setup/index.txt +++ b/setup/index.txt @@ -9,7 +9,7 @@ # to download and execute, type: # wget appleii.ivanx.com/a2server/setup; source setup -a2serverVersion="128d1" +a2serverVersion="128d2" # Ensure URL we'll use ends in a / case "$A2SERVER_SCRIPT_URL" in @@ -216,7 +216,7 @@ if (( $doSetup )); then echo "$a2serverVersion" | sudo tee /usr/local/etc/A2SERVER-version &> /dev/null fi - source /usr/local/etc/a2server-aliases + source /usr/local/etc/a2serverrc # get Kernel release (e.g. 3.6.11+) and version (e.g. #557) kernelRelease=$(uname -r)